Skip to content

Commit

Permalink
Docker pull for image change comparison (#809)
Browse files Browse the repository at this point in the history
* Moved logging to within docker_workspace and updated logic

* linter

* logging moved back to api.py, role.image modified if change detected

* fix to pass python unittests

* removing lauch.json that was commited by mistake
  • Loading branch information
ccharest93 authored Jan 30, 2024
1 parent f447bed commit 500911d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion torchx/workspace/docker_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def build_workspace_and_update_role(
workspace: a fsspec path to a directory with contents to be overlaid
"""

old_imgs = [
image.id
for image in self._docker_client.images.list(name=cfg["image_repo"])
]
context = _build_context(role.image, workspace)

try:
Expand All @@ -129,7 +133,8 @@ def build_workspace_and_update_role(
self.LABEL_VERSION: torchx.__version__,
},
)
role.image = image.id
if len(old_imgs) == 0 or role.image not in old_imgs:
role.image = image.id
finally:
context.close()

Expand Down
2 changes: 1 addition & 1 deletion torchx/workspace/test/docker_workspace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_docker_workspace(self) -> None:

workspace = DockerWorkspaceMixin()
workspace.build_workspace_and_update_role(
role, "memory://test_workspace", {}
role, "memory://test_workspace", {"image_repo": "example/repo_name"}
)

self.assertNotEqual("busybox", role.image)
Expand Down

0 comments on commit 500911d

Please sign in to comment.