diff --git a/torchx/runner/api.py b/torchx/runner/api.py index f38367ecd..4efc8a83b 100644 --- a/torchx/runner/api.py +++ b/torchx/runner/api.py @@ -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 @@ -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] @@ -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( @@ -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 diff --git a/torchx/workspace/api.py b/torchx/workspace/api.py index 4805a14af..694e3fb57 100644 --- a/torchx/workspace/api.py +++ b/torchx/workspace/api.py @@ -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 @@ -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]: """