Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moved image diff logging to their respective workspace #819

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,6 @@ wordlist.dic
pipeline.yaml

/codecov

# Visual Studio Code
.vscode/
12 changes: 0 additions & 12 deletions torchx/runner/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,13 @@ def dryrun(
resolved_cfg = sched.run_opts().resolve(cfg)
if workspace and isinstance(sched, WorkspaceMixin):
role = app.roles[0]
old_img = role.image

logger.info(f"Checking for changes in workspace `{workspace}`...")
logger.info(
'To disable workspaces pass: --workspace="" from CLI or workspace=None programmatically.'
)
sched.build_workspace_and_update_role(role, workspace, resolved_cfg)

if old_img != role.image:
logger.info(
f"Built new image `{role.image}` based on original image `{old_img}`"
f" and changes in workspace `{workspace}` for role[0]={role.name}."
)
else:
logger.info(
f"Reusing original image `{old_img}` for role[0]={role.name}."
" Either a patch was built or no changes to workspace was detected."
)

sched._validate(app, scheduler)
dryrun_info = sched.submit_dryrun(app, resolved_cfg)
dryrun_info._scheduler = scheduler
Expand Down
11 changes: 11 additions & 0 deletions torchx/workspace/dir_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# pyre-strict

import logging
import os
import posixpath
import shutil
Expand All @@ -17,6 +18,8 @@
from torchx.specs import CfgVal, Role
from torchx.workspace.api import walk_workspace, WorkspaceMixin

logger: logging.Logger = logging.getLogger(__name__)


class TmpDirWorkspaceMixin(WorkspaceMixin[None]):
def build_workspace_and_update_role(
Expand All @@ -31,6 +34,10 @@ def build_workspace_and_update_role(
job_dir = mkdtemp(prefix="torchx_workspace")
_copy_to_dir(workspace, job_dir)
role.image = job_dir
logger.info(
f"Built new temporary directory `{role.image}` based on"
f" and changes in workspace `{workspace}` for role[0]={role.name}."
)


class DirWorkspaceMixin(WorkspaceMixin[None]):
Expand All @@ -51,6 +58,10 @@ def build_workspace_and_update_role(
os.mkdir(job_dir)
_copy_to_dir(workspace, job_dir)
role.image = job_dir
logger.info(
f"Built new directory `{role.image}` based on"
f" and changes in workspace `{workspace}` for role[0]={role.name}."
)


def _copy_to_dir(workspace: str, target: str) -> None:
Expand Down
13 changes: 11 additions & 2 deletions torchx/workspace/docker_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,17 @@ def build_workspace_and_update_role(
self.LABEL_VERSION: torchx.__version__,
},
)
if len(old_imgs) == 0 or role.image not in old_imgs:
role.image = image.id
if cfg["image_repo"] is not None and image.id in old_imgs:
log.info(
f"Reusing previously built image `{image.id}` for role[0]={role.name}."
" Either a patch was built or no changes to workspace was detected."
)
else:
log.info(
f"Built new image `{image.id}` based on original image `{role.image}`"
f" and changes in workspace `{workspace}` for role[0]={role.name}."
)
role.image = image.id
finally:
context.close()

Expand Down