Skip to content

Commit dca99de

Browse files
authored
(torchx/workspace) Add deprecation warning to PkgInfo, WorkspaceBuilder, FbpkgWorkspace
Differential Revision: D82245264 Pull Request resolved: meta-pytorch#1113
1 parent bf7e562 commit dca99de

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

torchx/runner/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from torchx.util.session import get_session_id_or_create_new, TORCHX_INTERNAL_SESSION_ID
5555

5656
from torchx.util.types import none_throws
57-
from torchx.workspace.api import PkgInfo, WorkspaceBuilder, WorkspaceMixin
57+
from torchx.workspace.api import WorkspaceMixin
5858

5959
if TYPE_CHECKING:
6060
from typing_extensions import Self

torchx/workspace/api.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import abc
1010
import fnmatch
1111
import posixpath
12+
import warnings
1213
from dataclasses import dataclass
1314
from typing import Any, Dict, Generic, Iterable, Mapping, Tuple, TYPE_CHECKING, TypeVar
1415

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

39+
def __post_init__(self) -> None:
40+
msg = (
41+
f"{self.__class__.__name__} is deprecated and will be removed in the future."
42+
" Consider forking this class if your project depends on it."
43+
)
44+
warnings.warn(
45+
msg,
46+
FutureWarning,
47+
stacklevel=2,
48+
)
49+
3850

3951
@dataclass
4052
class WorkspaceBuilder(Generic[PackageType, WorkspaceConfigType]):
4153
cfg: WorkspaceConfigType
4254

55+
def __post_init__(self) -> None:
56+
msg = (
57+
f"{self.__class__.__name__} is deprecated and will be removed in the future."
58+
" Consider forking this class if your project depends on it."
59+
)
60+
warnings.warn(
61+
msg,
62+
FutureWarning,
63+
stacklevel=2,
64+
)
65+
4366
@abc.abstractmethod
4467
def build_workspace(self, sync: bool = True) -> PkgInfo[PackageType]:
4568
"""

0 commit comments

Comments
 (0)