torchx-nightly 2024.10.15__py3-none-any.whl → 2024.10.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of torchx-nightly might be problematic. Click here for more details.

torchx/runner/api.py CHANGED
@@ -14,7 +14,7 @@ import time
14
14
  import warnings
15
15
  from datetime import datetime
16
16
  from types import TracebackType
17
- from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type
17
+ from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar
18
18
 
19
19
  from torchx.runner.events import log_event
20
20
  from torchx.schedulers import get_scheduler_factories, SchedulerFactory
@@ -41,7 +41,7 @@ from torchx.tracker.api import (
41
41
  )
42
42
 
43
43
  from torchx.util.types import none_throws
44
- from torchx.workspace.api import WorkspaceMixin
44
+ from torchx.workspace.api import PkgInfo, WorkspaceBuilder, WorkspaceMixin
45
45
 
46
46
  from .config import get_config, get_configs
47
47
 
@@ -49,6 +49,8 @@ logger: logging.Logger = logging.getLogger(__name__)
49
49
 
50
50
 
51
51
  NONE: str = "<NONE>"
52
+ S = TypeVar("S")
53
+ T = TypeVar("T")
52
54
 
53
55
 
54
56
  def get_configured_trackers() -> Dict[str, Optional[str]]:
@@ -147,6 +149,18 @@ class Runner:
147
149
  for scheduler in self._scheduler_instances.values():
148
150
  scheduler.close()
149
151
 
152
+ def build_standalone_workspace(
153
+ self,
154
+ workspace_builder: WorkspaceBuilder[S, T],
155
+ sync: bool = True,
156
+ ) -> PkgInfo[S]:
157
+ """
158
+ Build a standalone workspace for the given role.
159
+ This method is used to build a workspace for a role independent of the scheduler and
160
+ also enables asynchronous workspace building using the Role overrides.
161
+ """
162
+ return workspace_builder.build_workspace(sync)
163
+
150
164
  def run_component(
151
165
  self,
152
166
  component: str,
@@ -20,7 +20,9 @@ Example of usage:
20
20
 
21
21
  """
22
22
 
23
+ import json
23
24
  import logging
25
+ import sys
24
26
  import time
25
27
  import traceback
26
28
  from types import TracebackType
@@ -123,6 +125,20 @@ class log_event:
123
125
  ) // 1000
124
126
  if traceback_type:
125
127
  self._torchx_event.raw_exception = traceback.format_exc()
128
+ typ, value, tb = sys.exc_info()
129
+ if tb:
130
+ last_frame = traceback.extract_tb(tb)[-1]
131
+ self._torchx_event.exception_source_location = json.dumps(
132
+ {
133
+ "filename": last_frame.filename,
134
+ "lineno": last_frame.lineno,
135
+ "name": last_frame.name,
136
+ }
137
+ )
138
+ if exec_type:
139
+ self._torchx_event.exception_type = exec_type.__name__
140
+ if exec_value:
141
+ self._torchx_event.exception_message = str(exec_value)
126
142
  record(self._torchx_event)
127
143
 
128
144
  def _generate_torchx_event(
@@ -52,6 +52,9 @@ class TorchxEvent:
52
52
  wall_time_usec: Optional[int] = None
53
53
  start_epoch_time_usec: Optional[int] = None
54
54
  workspace: Optional[str] = None
55
+ exception_type: Optional[str] = None
56
+ exception_message: Optional[str] = None
57
+ exception_source_location: Optional[str] = None
55
58
 
56
59
  def __str__(self) -> str:
57
60
  return self.serialize()
torchx/specs/api.py CHANGED
@@ -11,6 +11,7 @@ import asyncio
11
11
  import copy
12
12
  import inspect
13
13
  import json
14
+ import logging as logger
14
15
  import re
15
16
  import typing
16
17
  from dataclasses import asdict, dataclass, field
@@ -189,7 +190,16 @@ class macros:
189
190
  apply applies the values to a copy the specified role and returns it.
190
191
  """
191
192
 
193
+ # Overrides might contain future values which can't be serialized so taken out for the copy
194
+ overrides = role.overrides
195
+ if len(overrides) > 0:
196
+ logger.warning(
197
+ "Role overrides are not supported for macros. Overrides will not be copied"
198
+ )
199
+ role.overrides = {}
192
200
  role = copy.deepcopy(role)
201
+ role.overrides = overrides
202
+
193
203
  role.args = [self.substitute(arg) for arg in role.args]
194
204
  role.env = {key: self.substitute(arg) for key, arg in role.env.items()}
195
205
  role.metadata = self._apply_nested(role.metadata)
torchx/workspace/api.py CHANGED
@@ -9,7 +9,8 @@
9
9
  import abc
10
10
  import fnmatch
11
11
  import posixpath
12
- from typing import Generic, Iterable, Mapping, Tuple, TYPE_CHECKING, TypeVar
12
+ from dataclasses import dataclass
13
+ from typing import Any, Dict, Generic, Iterable, Mapping, Tuple, TYPE_CHECKING, TypeVar
13
14
 
14
15
  from torchx.specs import AppDef, CfgVal, Role, runopts
15
16
 
@@ -20,6 +21,36 @@ TORCHX_IGNORE = ".torchxignore"
20
21
 
21
22
  T = TypeVar("T")
22
23
 
24
+ PackageType = TypeVar("PackageType")
25
+ WorkspaceConfigType = TypeVar("WorkspaceConfigType")
26
+
27
+
28
+ @dataclass
29
+ class PkgInfo(Generic[PackageType]):
30
+ """
31
+ Convenience class used to specify information regarding the built workspace
32
+ """
33
+
34
+ img: str
35
+ lazy_overrides: Dict[str, Any]
36
+ metadata: PackageType
37
+
38
+
39
+ @dataclass
40
+ class WorkspaceBuilder(Generic[PackageType, WorkspaceConfigType]):
41
+ cfg: WorkspaceConfigType
42
+
43
+ @abc.abstractmethod
44
+ def build_workspace(self, sync: bool = True) -> PkgInfo[PackageType]:
45
+ """
46
+ Builds the specified ``workspace`` with respect to ``img``.
47
+ In the simplest case, this method builds a new image.
48
+ Certain (more efficient) implementations build
49
+ incremental diff patches that overlay on top of the role's image.
50
+
51
+ """
52
+ pass
53
+
23
54
 
24
55
  class WorkspaceMixin(abc.ABC, Generic[T]):
25
56
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: torchx-nightly
3
- Version: 2024.10.15
3
+ Version: 2024.10.17
4
4
  Summary: TorchX SDK and Components
5
5
  Home-page: https://github.com/pytorch/torchx
6
6
  Author: TorchX Devs
@@ -56,10 +56,10 @@ torchx/pipelines/kfp/__init__.py,sha256=8iJ8lql_fxwuk9VCYSxXnX6tPL228fB5mDZpOs-k
56
56
  torchx/pipelines/kfp/adapter.py,sha256=V96Rg2ypas0ZpNNn4ojplJMmC5vcBfcuxAITaY8PV_M,8969
57
57
  torchx/pipelines/kfp/version.py,sha256=mYBxd6bm4MeR34D--xo-JLQ9wHeAl_ZQLwbItCf9tr0,539
58
58
  torchx/runner/__init__.py,sha256=x8Sz7s_tLxPgJgvWIhK4ju9BNZU61uBFywGwDY6CqJs,315
59
- torchx/runner/api.py,sha256=17ZFEYeuIK0kUrTUysdgsFaEVc6_-ggvBuSoabQnrcA,28625
59
+ torchx/runner/api.py,sha256=1FlElbo-j5M3n1eivb3vE1RaMCXEXexGWrAlS-Mbi3w,29153
60
60
  torchx/runner/config.py,sha256=fTdCcf-MKlBg6MzXopF4W0hYyDDoPAuvZs2v2bKzwG0,17849
61
- torchx/runner/events/__init__.py,sha256=TtzBLZ9oaHKfr689R4NnjCii3G8kxiRafe7Q0jRE5_k,4649
62
- torchx/runner/events/api.py,sha256=_6mjS5B5FcSMEea1U0M-fD4jErmbpZ1gQOyUHV-4dqY,2527
61
+ torchx/runner/events/__init__.py,sha256=1_y0bojXl3FL0zlAj7BI4Dg5cXKXUmaa2jZbVH0EDUA,5268
62
+ torchx/runner/events/api.py,sha256=pPLfowWTXtN_XcrEDNI45pE6Ijvdc_Gdxq76RduqgGE,2664
63
63
  torchx/runner/events/handlers.py,sha256=ThHCIJW21BfBgB7b6ftyjASJmD1KdizpjuTtsyqnvJs,522
64
64
  torchx/runtime/__init__.py,sha256=Wxje2BryzeQneFu5r6P9JJiEKG-_C9W1CcZ_JNrKT6g,593
65
65
  torchx/runtime/tracking/__init__.py,sha256=dYnAPnrXYREfPXkpHhdOFkcYIODWEbA13PdD-wLQYBo,3055
@@ -83,7 +83,7 @@ torchx/schedulers/ray/__init__.py,sha256=fE0IHi1JJpxsNVBNzWNee2thrNXFFRhY94c80Rx
83
83
  torchx/schedulers/ray/ray_common.py,sha256=pyNYFvTKVwdjDAeCBNbPwAWwVNmlLOJWExfn90XY8u8,610
84
84
  torchx/schedulers/ray/ray_driver.py,sha256=Wl-1jldL8veVKzmYDEeR2va3JSlAjZpFE1h8HWE9YVE,12286
85
85
  torchx/specs/__init__.py,sha256=T8xUCz7iVE6OsUL5P4Pzy2B8ZY_YinCVDwUer5Q-XPc,6179
86
- torchx/specs/api.py,sha256=ipALDCFY83vqZ47HxT73ZAQFhHvUcNnzVcJov2B8nzM,37115
86
+ torchx/specs/api.py,sha256=EI1tXPfDrz8dAyjJsuNK9mL4femS44lUuJFJUCW_oSc,37540
87
87
  torchx/specs/builders.py,sha256=QDcQrnCO4bdSaiP0216XbCgTsnLutO_1_FW5jDiEIWI,9939
88
88
  torchx/specs/file_linter.py,sha256=IeiomB1BgHUlT-ZsvGxar3llY63NOupfLBrOrD_---A,11860
89
89
  torchx/specs/finder.py,sha256=MnwxG_UC4a-3X2wQ37ANEQR6D1TvriCLyuVYBh_-wuI,16249
@@ -112,12 +112,12 @@ torchx/util/shlex.py,sha256=eXEKu8KC3zIcd8tEy9_s8Ds5oma8BORr-0VGWNpG2dk,463
112
112
  torchx/util/strings.py,sha256=GkLWCmYS89Uv6bWc5hH0XwvHy7oQmprv2U7axC4A2e8,678
113
113
  torchx/util/types.py,sha256=een55pV-N8aBc3qUBjHRc1llJcX10JVa19pB8dBE8No,7564
114
114
  torchx/workspace/__init__.py,sha256=FqN8AN4VhR1C_SBY10MggQvNZmyanbbuPuE-JCjkyUY,798
115
- torchx/workspace/api.py,sha256=1heBmPgB-W5Zf9gwViM7NrqvHpZlVYeMN7jpY8Qkytc,5479
115
+ torchx/workspace/api.py,sha256=PtDkGTC5lX03pRoYpuMz2KCmM1ZOycRP1UknqvNb97Y,6341
116
116
  torchx/workspace/dir_workspace.py,sha256=npNW_IjUZm_yS5r-8hrRkH46ndDd9a_eApT64m1S1T4,2268
117
117
  torchx/workspace/docker_workspace.py,sha256=PFu2KQNVC-0p2aKJ-W_BKA9ZOmXdCY2ABEkCExp3udQ,10269
118
- torchx_nightly-2024.10.15.dist-info/LICENSE,sha256=WVHfXhFC0Ia8LTKt_nJVYobdqTJVg_4J3Crrfm2A8KQ,1721
119
- torchx_nightly-2024.10.15.dist-info/METADATA,sha256=1HVUgbu59EwuBqagzVBiQzHHTCBO7yaJ8ZAvvXUbMrU,6170
120
- torchx_nightly-2024.10.15.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
121
- torchx_nightly-2024.10.15.dist-info/entry_points.txt,sha256=T328AMXeKI3JZnnxfkEew2ZcMN1oQDtkXjMz7lkV-P4,169
122
- torchx_nightly-2024.10.15.dist-info/top_level.txt,sha256=pxew3bc2gsiViS0zADs0jb6kC5v8o_Yy_85fhHj_J1A,7
123
- torchx_nightly-2024.10.15.dist-info/RECORD,,
118
+ torchx_nightly-2024.10.17.dist-info/LICENSE,sha256=WVHfXhFC0Ia8LTKt_nJVYobdqTJVg_4J3Crrfm2A8KQ,1721
119
+ torchx_nightly-2024.10.17.dist-info/METADATA,sha256=Zbb7ZcE4TadqUN70RDvZETyDGd6a9QW7wp8Ho2BHFKs,6170
120
+ torchx_nightly-2024.10.17.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
121
+ torchx_nightly-2024.10.17.dist-info/entry_points.txt,sha256=T328AMXeKI3JZnnxfkEew2ZcMN1oQDtkXjMz7lkV-P4,169
122
+ torchx_nightly-2024.10.17.dist-info/top_level.txt,sha256=pxew3bc2gsiViS0zADs0jb6kC5v8o_Yy_85fhHj_J1A,7
123
+ torchx_nightly-2024.10.17.dist-info/RECORD,,