Skip to content

Commit 9067bb3

Browse files
committed
Minor changes and tests
1 parent 9b8e39d commit 9067bb3

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

arca/backend/docker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def get_image_tag(self, requirements_file: Optional[Path], dependencies: Optiona
182182
183183
* Image type:
184184
185-
* i – Inherit image
185+
* i – Inherited image
186186
* a – Arca base image
187187
188188
* Requirements:
@@ -200,14 +200,14 @@ def get_image_tag(self, requirements_file: Optional[Path], dependencies: Optiona
200200
* Inherited images:
201201
202202
* `ise` – no requirements
203-
* `ide_<requirements_hash>` – with requirements
203+
* `ide_<hash(requirements)>` – with requirements
204204
205205
* From Arca base image:
206206
207207
* `ase` – no requirements and no dependencies
208-
* `asd_<dependencies_hash>` – only dependencies
209-
* `are_<requirements_hash>` – only requirements
210-
* `ard_<hash(dependencies_hash + requirements_hash)>` – both requirements and dependencies
208+
* `asd_<hash(dependencies)>` – only dependencies
209+
* `are_<hash(requirements)>` – only requirements
210+
* `ard_<hash(hash(dependencies) + hash(requirements))>` – both requirements and dependencies
211211
"""
212212

213213
prefix = "i" if self.inherit_image is not None else "a"

arca/backend/vagrant.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,10 @@ def stop_containers(self):
296296
def stop_vm(self):
297297
""" Stops or destroys the VM used to launch tasks.
298298
"""
299-
if self.destroy:
300-
self.vagrant.destroy()
301-
shutil.rmtree(self.vagrant.root, ignore_errors=True)
302-
self.vagrant = None
303-
else:
304-
self.vagrant.halt()
299+
if self.vagrant is not None:
300+
if self.destroy:
301+
self.vagrant.destroy()
302+
shutil.rmtree(self.vagrant.root, ignore_errors=True)
303+
self.vagrant = None
304+
else:
305+
self.vagrant.halt()

tests/test_result.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ def test_success():
1616
def test_error():
1717
with pytest.raises(BuildError):
1818
Result({"success": False, "error": "Error"})
19+
20+
21+
def test_json():
22+
res = Result("""{"success": true, "result": "Message"}""")
23+
assert res.output == "Message"
24+
25+
with pytest.raises(BuildError):
26+
Result("""{"success": false, "error": "Error" """)

tests/test_task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def test_task_json(args, kwargs):
2727
task = Task("library.mod:func", args=args, kwargs=kwargs)
2828

2929
assert isinstance(json.loads(task.json), dict)
30+
assert task.hash
3031

3132

3233
@pytest.mark.parametrize("args", "kwargs", [

0 commit comments

Comments
 (0)