From 45a30b9ffd6f31e70e9a916d595d41edb3386323 Mon Sep 17 00:00:00 2001 From: Kiuk Chung Date: Thu, 11 Sep 2025 12:47:04 -0700 Subject: [PATCH 1/2] (torchx/runner)(1/n) remove useless nested event logging - runner.dryrun (#1112) Summary: remove useless event logging for sub-steps of runner.dryrun(). If these need to be logged they should be logged at the APIs that the runner.dryrun() calls. Differential Revision: D82238445 --- torchx/runner/api.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/torchx/runner/api.py b/torchx/runner/api.py index f38367ecd..fec19f0bd 100644 --- a/torchx/runner/api.py +++ b/torchx/runner/api.py @@ -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 From 4142bedb3e5c6215c01697480266097cb98a8962 Mon Sep 17 00:00:00 2001 From: Kiuk Chung Date: Thu, 11 Sep 2025 12:47:04 -0700 Subject: [PATCH 2/2] (torchx/workspace) Add deprecation warning to PkgInfo, WorkspaceBuilder, FbpkgWorkspace Summary: These classes are not used by torchx anywhere. Add deprecation warning so that we can remove them in the next release. Differential Revision: D82245264 --- torchx/runner/api.py | 2 +- torchx/workspace/api.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/torchx/runner/api.py b/torchx/runner/api.py index fec19f0bd..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 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]: """