Skip to content
Merged
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
23 changes: 4 additions & 19 deletions torchx/runner/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from torchx.util.session import get_session_id_or_create_new, TORCHX_INTERNAL_SESSION_ID

from torchx.util.types import none_throws
from torchx.workspace.api import PkgInfo, WorkspaceBuilder, WorkspaceMixin
from torchx.workspace.api import WorkspaceMixin

if TYPE_CHECKING:
from typing_extensions import Self
Expand Down Expand Up @@ -419,12 +419,7 @@ def dryrun(
sched = self._scheduler(scheduler)
resolved_cfg = sched.run_opts().resolve(cfg)

# early validation before build workspace
with log_event(
"pre_build_validate",
scheduler,
):
sched._pre_build_validate(app, scheduler, resolved_cfg)
sched._pre_build_validate(app, scheduler, resolved_cfg)

if workspace and isinstance(sched, WorkspaceMixin):
role = app.roles[0]
Expand All @@ -434,13 +429,7 @@ def dryrun(
logger.info(
'To disable workspaces pass: --workspace="" from CLI or workspace=None programmatically.'
)
with log_event(
"build_workspace_and_update_role",
scheduler,
) as ctx:
sched.build_workspace_and_update_role(role, workspace, resolved_cfg)
ctx._torchx_event.app_image = role.image
ctx._torchx_event.workspace = workspace
sched.build_workspace_and_update_role(role, workspace, resolved_cfg)

if old_img != role.image:
logger.info(
Expand All @@ -453,11 +442,7 @@ def dryrun(
" Either a patch was built or no changes to workspace was detected."
)

with log_event(
"validate",
scheduler,
):
sched._validate(app, scheduler, resolved_cfg)
sched._validate(app, scheduler, resolved_cfg)
dryrun_info = sched.submit_dryrun(app, resolved_cfg)
dryrun_info._scheduler = scheduler
return dryrun_info
Expand Down
23 changes: 23 additions & 0 deletions torchx/workspace/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import abc
import fnmatch
import posixpath
import warnings
from dataclasses import dataclass
from typing import Any, Dict, Generic, Iterable, Mapping, Tuple, TYPE_CHECKING, TypeVar

Expand All @@ -35,11 +36,33 @@ class PkgInfo(Generic[PackageType]):
lazy_overrides: Dict[str, Any]
metadata: PackageType

def __post_init__(self) -> None:
msg = (
f"{self.__class__.__name__} is deprecated and will be removed in the future."
" Consider forking this class if your project depends on it."
)
warnings.warn(
msg,
FutureWarning,
stacklevel=2,
)


@dataclass
class WorkspaceBuilder(Generic[PackageType, WorkspaceConfigType]):
cfg: WorkspaceConfigType

def __post_init__(self) -> None:
msg = (
f"{self.__class__.__name__} is deprecated and will be removed in the future."
" Consider forking this class if your project depends on it."
)
warnings.warn(
msg,
FutureWarning,
stacklevel=2,
)

@abc.abstractmethod
def build_workspace(self, sync: bool = True) -> PkgInfo[PackageType]:
"""
Expand Down
Loading