torchx-nightly 2024.2.12__py3-none-any.whl → 2024.4.10__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/__init__.py +2 -0
- torchx/apps/serve/serve.py +2 -0
- torchx/apps/utils/booth_main.py +2 -0
- torchx/apps/utils/copy_main.py +2 -0
- torchx/apps/utils/process_monitor.py +2 -0
- torchx/cli/__init__.py +2 -0
- torchx/cli/argparse_util.py +38 -3
- torchx/cli/cmd_base.py +2 -0
- torchx/cli/cmd_cancel.py +2 -0
- torchx/cli/cmd_configure.py +2 -0
- torchx/cli/cmd_describe.py +2 -0
- torchx/cli/cmd_list.py +2 -0
- torchx/cli/cmd_log.py +2 -0
- torchx/cli/cmd_run.py +5 -1
- torchx/cli/cmd_runopts.py +2 -0
- torchx/cli/cmd_status.py +2 -0
- torchx/cli/cmd_tracker.py +2 -0
- torchx/cli/colors.py +2 -0
- torchx/cli/main.py +2 -0
- torchx/components/__init__.py +2 -0
- torchx/components/component_test_base.py +2 -0
- torchx/components/dist.py +2 -0
- torchx/components/integration_tests/component_provider.py +2 -0
- torchx/components/integration_tests/integ_tests.py +2 -0
- torchx/components/serve.py +2 -0
- torchx/components/structured_arg.py +2 -0
- torchx/components/utils.py +2 -0
- torchx/examples/apps/datapreproc/datapreproc.py +2 -0
- torchx/examples/apps/lightning/data.py +2 -0
- torchx/examples/apps/lightning/model.py +2 -0
- torchx/examples/apps/lightning/profiler.py +2 -0
- torchx/examples/apps/lightning/train.py +2 -0
- torchx/examples/pipelines/kfp/advanced_pipeline.py +2 -0
- torchx/examples/pipelines/kfp/dist_pipeline.py +2 -0
- torchx/examples/pipelines/kfp/intro_pipeline.py +2 -0
- torchx/notebook.py +2 -0
- torchx/pipelines/kfp/__init__.py +2 -0
- torchx/pipelines/kfp/adapter.py +3 -2
- torchx/pipelines/kfp/version.py +2 -0
- torchx/runner/__init__.py +2 -0
- torchx/runner/api.py +4 -2
- torchx/runner/config.py +14 -0
- torchx/runner/events/__init__.py +2 -0
- torchx/runner/events/api.py +2 -0
- torchx/runner/events/handlers.py +2 -0
- torchx/runtime/tracking/__init__.py +2 -0
- torchx/runtime/tracking/api.py +2 -0
- torchx/schedulers/__init__.py +4 -2
- torchx/schedulers/api.py +2 -0
- torchx/schedulers/aws_batch_scheduler.py +2 -0
- torchx/schedulers/aws_sagemaker_scheduler.py +590 -0
- torchx/schedulers/devices.py +2 -0
- torchx/schedulers/docker_scheduler.py +18 -3
- torchx/schedulers/gcp_batch_scheduler.py +7 -8
- torchx/schedulers/ids.py +2 -0
- torchx/schedulers/kubernetes_scheduler.py +3 -1
- torchx/schedulers/local_scheduler.py +24 -2
- torchx/schedulers/lsf_scheduler.py +2 -0
- torchx/schedulers/ray/ray_driver.py +6 -6
- torchx/schedulers/slurm_scheduler.py +2 -0
- torchx/schedulers/streams.py +2 -0
- torchx/specs/__init__.py +2 -0
- torchx/specs/api.py +14 -3
- torchx/specs/builders.py +68 -19
- torchx/specs/file_linter.py +8 -2
- torchx/specs/finder.py +2 -0
- torchx/specs/named_resources_aws.py +2 -0
- torchx/specs/named_resources_generic.py +2 -0
- torchx/specs/test/components/__init__.py +2 -0
- torchx/specs/test/components/a/__init__.py +2 -0
- torchx/specs/test/components/a/b/__init__.py +2 -0
- torchx/specs/test/components/a/b/c.py +2 -0
- torchx/specs/test/components/c/__init__.py +2 -0
- torchx/specs/test/components/c/d.py +2 -0
- torchx/tracker/__init__.py +2 -0
- torchx/tracker/api.py +4 -4
- torchx/tracker/backend/fsspec.py +2 -0
- torchx/util/cuda.py +2 -0
- torchx/util/datetime.py +2 -0
- torchx/util/entrypoints.py +2 -0
- torchx/util/io.py +2 -0
- torchx/util/modules.py +2 -0
- torchx/util/shlex.py +2 -0
- torchx/util/strings.py +2 -0
- torchx/util/types.py +12 -0
- torchx/version.py +2 -0
- torchx/workspace/__init__.py +2 -0
- torchx/workspace/api.py +2 -0
- torchx/workspace/dir_workspace.py +2 -0
- torchx/workspace/docker_workspace.py +2 -0
- {torchx_nightly-2024.2.12.dist-info → torchx_nightly-2024.4.10.dist-info}/METADATA +25 -17
- torchx_nightly-2024.4.10.dist-info/RECORD +120 -0
- {torchx_nightly-2024.2.12.dist-info → torchx_nightly-2024.4.10.dist-info}/WHEEL +1 -1
- torchx_nightly-2024.2.12.dist-info/RECORD +0 -119
- {torchx_nightly-2024.2.12.dist-info → torchx_nightly-2024.4.10.dist-info}/LICENSE +0 -0
- {torchx_nightly-2024.2.12.dist-info → torchx_nightly-2024.4.10.dist-info}/entry_points.txt +0 -0
- {torchx_nightly-2024.2.12.dist-info → torchx_nightly-2024.4.10.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
"""
|
|
9
11
|
|
|
10
12
|
This contains the TorchX GCP Batch scheduler which can be used to run TorchX
|
|
@@ -205,14 +207,12 @@ class GCPBatchScheduler(Scheduler[GCPBatchOpts]):
|
|
|
205
207
|
if cpu <= 0:
|
|
206
208
|
cpu = 1
|
|
207
209
|
MILLI = 1000
|
|
208
|
-
# pyre-fixme[8]: Attribute has type `Field`; used as `int`.
|
|
209
210
|
res.cpu_milli = cpu * MILLI
|
|
210
211
|
memMB = resource.memMB
|
|
211
212
|
if memMB < 0:
|
|
212
213
|
raise ValueError(
|
|
213
214
|
f"memMB should to be set to a positive value, got {memMB}"
|
|
214
215
|
)
|
|
215
|
-
# pyre-fixme[8]: Attribute has type `Field`; used as `int`.
|
|
216
216
|
res.memory_mib = memMB
|
|
217
217
|
|
|
218
218
|
# TODO support named resources
|
|
@@ -360,13 +360,11 @@ class GCPBatchScheduler(Scheduler[GCPBatchOpts]):
|
|
|
360
360
|
return None
|
|
361
361
|
|
|
362
362
|
gpu = 0
|
|
363
|
-
# pyre-fixme[16]: `Field` has no attribute `instances`.
|
|
364
363
|
if len(job.allocation_policy.instances) != 0:
|
|
365
364
|
gpu_type = job.allocation_policy.instances[0].policy.machine_type
|
|
366
365
|
gpu = GPU_TYPE_TO_COUNT[gpu_type]
|
|
367
366
|
|
|
368
367
|
roles = {}
|
|
369
|
-
# pyre-fixme[16]: `RepeatedField` has no attribute `__iter__`.
|
|
370
368
|
for tg in job.task_groups:
|
|
371
369
|
env = tg.task_spec.environment.variables
|
|
372
370
|
role = env["TORCHX_ROLE_NAME"]
|
|
@@ -390,7 +388,6 @@ class GCPBatchScheduler(Scheduler[GCPBatchOpts]):
|
|
|
390
388
|
# TODO map role/replica status
|
|
391
389
|
desc = DescribeAppResponse(
|
|
392
390
|
app_id=app_id,
|
|
393
|
-
# pyre-fixme[16]: `Field` has no attribute `state`.
|
|
394
391
|
state=JOB_STATE[job.status.state.name],
|
|
395
392
|
roles=list(roles.values()),
|
|
396
393
|
)
|
|
@@ -415,8 +412,10 @@ class GCPBatchScheduler(Scheduler[GCPBatchOpts]):
|
|
|
415
412
|
raise ValueError(f"app not found: {app_id}")
|
|
416
413
|
|
|
417
414
|
job_uid = job.uid
|
|
418
|
-
filters = [
|
|
419
|
-
|
|
415
|
+
filters = [
|
|
416
|
+
f"labels.job_uid={job_uid}",
|
|
417
|
+
f"labels.task_id:{job_uid}-group0-{k}",
|
|
418
|
+
]
|
|
420
419
|
|
|
421
420
|
if since is not None:
|
|
422
421
|
filters.append(f'timestamp>="{str(since.isoformat())}"')
|
|
@@ -437,7 +436,7 @@ class GCPBatchScheduler(Scheduler[GCPBatchOpts]):
|
|
|
437
436
|
|
|
438
437
|
logger = logging.Client().logger(BATCH_LOGGER_NAME)
|
|
439
438
|
for entry in logger.list_entries(filter_=filter):
|
|
440
|
-
yield entry.payload
|
|
439
|
+
yield entry.payload + "\n"
|
|
441
440
|
|
|
442
441
|
def _job_full_name_to_app_id(self, job_full_name: str) -> str:
|
|
443
442
|
"""
|
torchx/schedulers/ids.py
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
"""
|
|
9
11
|
|
|
10
12
|
This contains the TorchX Kubernetes scheduler which can be used to run TorchX
|
|
@@ -23,7 +25,7 @@ Install Volcano:
|
|
|
23
25
|
kubectl apply -f https://raw.githubusercontent.com/volcano-sh/volcano/v1.6.0/installer/volcano-development.yaml
|
|
24
26
|
|
|
25
27
|
See the
|
|
26
|
-
`Volcano Quickstart <https://github.com/volcano-sh/volcano
|
|
28
|
+
`Volcano Quickstart <https://github.com/volcano-sh/volcano>`_
|
|
27
29
|
for more information.
|
|
28
30
|
"""
|
|
29
31
|
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
"""
|
|
9
11
|
This contains the TorchX local scheduler which can be used to run TorchX
|
|
10
12
|
components locally via subprocesses.
|
|
@@ -35,6 +37,7 @@ from typing import (
|
|
|
35
37
|
Iterable,
|
|
36
38
|
List,
|
|
37
39
|
Optional,
|
|
40
|
+
Protocol,
|
|
38
41
|
TextIO,
|
|
39
42
|
Tuple,
|
|
40
43
|
)
|
|
@@ -262,6 +265,26 @@ AppName = str
|
|
|
262
265
|
RoleName = str
|
|
263
266
|
|
|
264
267
|
|
|
268
|
+
class PopenProtocol(Protocol):
|
|
269
|
+
"""
|
|
270
|
+
Protocol wrapper around python's ``subprocess.Popen``. Keeps track of
|
|
271
|
+
the a list of interface methods that the process scheduled by the `LocalScheduler`
|
|
272
|
+
must implement.
|
|
273
|
+
"""
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def pid(self) -> int: ...
|
|
277
|
+
|
|
278
|
+
@property
|
|
279
|
+
def returncode(self) -> int: ...
|
|
280
|
+
|
|
281
|
+
def wait(self, timeout: Optional[float] = None) -> int: ...
|
|
282
|
+
|
|
283
|
+
def poll(self) -> Optional[int]: ...
|
|
284
|
+
|
|
285
|
+
def kill(self) -> None: ...
|
|
286
|
+
|
|
287
|
+
|
|
265
288
|
@dataclass
|
|
266
289
|
class _LocalReplica:
|
|
267
290
|
"""
|
|
@@ -270,8 +293,7 @@ class _LocalReplica:
|
|
|
270
293
|
|
|
271
294
|
role_name: RoleName
|
|
272
295
|
replica_id: int
|
|
273
|
-
|
|
274
|
-
proc: subprocess.Popen
|
|
296
|
+
proc: PopenProtocol
|
|
275
297
|
|
|
276
298
|
# IO streams:
|
|
277
299
|
# None means no log_dir (out to console)
|
|
@@ -148,12 +148,12 @@ class RayDriver:
|
|
|
148
148
|
else:
|
|
149
149
|
self.min_replicas = replicas[0].min_replicas # pyre-ignore[8]
|
|
150
150
|
|
|
151
|
-
self.placement_groups: List[
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
self.actor_info_of_id: Dict[
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
self.placement_groups: List[PlacementGroup] = (
|
|
152
|
+
[]
|
|
153
|
+
) # all the placement groups, shall never change
|
|
154
|
+
self.actor_info_of_id: Dict[str, ActorInfo] = (
|
|
155
|
+
{}
|
|
156
|
+
) # store the info used to recover an actor
|
|
157
157
|
self.active_tasks: List["ray.ObjectRef"] = [] # list of active tasks
|
|
158
158
|
|
|
159
159
|
self.terminating: bool = False # if the job has finished and being terminated
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
"""
|
|
9
11
|
This contains the TorchX Slurm scheduler which can be used to run TorchX
|
|
10
12
|
components on a Slurm cluster.
|
torchx/schedulers/streams.py
CHANGED
torchx/specs/__init__.py
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
"""
|
|
9
11
|
This contains the TorchX AppDef and related component definitions. These are
|
|
10
12
|
used by components to define the apps which can then be launched via a TorchX
|
torchx/specs/api.py
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
import copy
|
|
9
11
|
import json
|
|
10
12
|
import re
|
|
@@ -637,11 +639,11 @@ class AppStatusError(Exception):
|
|
|
637
639
|
self.status = status
|
|
638
640
|
|
|
639
641
|
|
|
640
|
-
# valid run cfg values; only support primitives (str, int, float, bool, List[str])
|
|
642
|
+
# valid run cfg values; only support primitives (str, int, float, bool, List[str], Dict[str, str])
|
|
641
643
|
# TODO(wilsonhong): python 3.9+ supports list[T] in typing, which can be used directly
|
|
642
644
|
# in isinstance(). Should replace with that.
|
|
643
645
|
# see: https://docs.python.org/3/library/stdtypes.html#generic-alias-type
|
|
644
|
-
CfgVal = Union[str, int, float, bool, List[str], None]
|
|
646
|
+
CfgVal = Union[str, int, float, bool, List[str], Dict[str, str], None]
|
|
645
647
|
|
|
646
648
|
|
|
647
649
|
T = TypeVar("T")
|
|
@@ -755,6 +757,10 @@ class runopts:
|
|
|
755
757
|
except TypeError:
|
|
756
758
|
if isinstance(obj, list):
|
|
757
759
|
return all(isinstance(e, str) for e in obj)
|
|
760
|
+
elif isinstance(obj, dict):
|
|
761
|
+
return all(
|
|
762
|
+
isinstance(k, str) and isinstance(v, str) for k, v in obj.items()
|
|
763
|
+
)
|
|
758
764
|
else:
|
|
759
765
|
return False
|
|
760
766
|
|
|
@@ -863,8 +869,13 @@ class runopts:
|
|
|
863
869
|
# lists may be ; or , delimited
|
|
864
870
|
# also deal with trailing "," by removing empty strings
|
|
865
871
|
return [v for v in value.replace(";", ",").split(",") if v]
|
|
872
|
+
elif opt_type == Dict[str, str]:
|
|
873
|
+
return {
|
|
874
|
+
s.split(":", 1)[0]: s.split(":", 1)[1]
|
|
875
|
+
for s in value.replace(";", ",").split(",")
|
|
876
|
+
}
|
|
866
877
|
else:
|
|
867
|
-
# pyre-ignore[19]
|
|
878
|
+
# pyre-ignore[19, 6] type won't be dict here as we handled it above
|
|
868
879
|
return opt_type(value)
|
|
869
880
|
|
|
870
881
|
cfg: Dict[str, CfgVal] = {}
|
torchx/specs/builders.py
CHANGED
|
@@ -4,25 +4,27 @@
|
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
|
6
6
|
|
|
7
|
+
# pyre-strict
|
|
8
|
+
|
|
7
9
|
import argparse
|
|
8
10
|
import inspect
|
|
11
|
+
import os
|
|
12
|
+
from argparse import Namespace
|
|
9
13
|
from typing import Any, Callable, Dict, List, Mapping, Optional, Union
|
|
10
14
|
|
|
11
15
|
from torchx.specs.api import BindMount, MountType, VolumeMount
|
|
12
16
|
from torchx.specs.file_linter import get_fn_docstring, TorchXArgumentHelpFormatter
|
|
13
|
-
from torchx.util.types import
|
|
14
|
-
decode_from_string,
|
|
15
|
-
decode_optional,
|
|
16
|
-
get_argparse_param_type,
|
|
17
|
-
is_bool,
|
|
18
|
-
is_primitive,
|
|
19
|
-
)
|
|
17
|
+
from torchx.util.types import decode, decode_optional, get_argparse_param_type, is_bool
|
|
20
18
|
|
|
21
19
|
from .api import AppDef, DeviceMount
|
|
22
20
|
|
|
21
|
+
ENV_TORCHX_COMPONENT_ARGS = "TORCHX_COMPONENT_ARGS"
|
|
22
|
+
|
|
23
23
|
|
|
24
24
|
def _create_args_parser(
|
|
25
|
-
cmpnt_fn: Callable[..., AppDef],
|
|
25
|
+
cmpnt_fn: Callable[..., AppDef],
|
|
26
|
+
cmpnt_defaults: Optional[Dict[str, str]] = None,
|
|
27
|
+
config: Optional[Dict[str, Any]] = None,
|
|
26
28
|
) -> argparse.ArgumentParser:
|
|
27
29
|
parameters = inspect.signature(cmpnt_fn).parameters
|
|
28
30
|
function_desc, args_desc = get_fn_docstring(cmpnt_fn)
|
|
@@ -85,15 +87,56 @@ def _create_args_parser(
|
|
|
85
87
|
if len(param_name) == 1:
|
|
86
88
|
arg_names = [f"-{param_name}"] + arg_names
|
|
87
89
|
if "default" not in args:
|
|
88
|
-
|
|
90
|
+
if (config and param_name not in config) or not config:
|
|
91
|
+
args["required"] = True
|
|
92
|
+
|
|
89
93
|
script_parser.add_argument(*arg_names, **args)
|
|
90
94
|
return script_parser
|
|
91
95
|
|
|
92
96
|
|
|
97
|
+
def _merge_config_values_with_args(
|
|
98
|
+
parsed_args: argparse.Namespace, config: Dict[str, Any]
|
|
99
|
+
) -> None:
|
|
100
|
+
for key, val in config.items():
|
|
101
|
+
if key in parsed_args:
|
|
102
|
+
setattr(parsed_args, key, val)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def parse_args(
|
|
106
|
+
cmpnt_fn: Callable[..., AppDef],
|
|
107
|
+
cmpnt_args: List[str],
|
|
108
|
+
cmpnt_defaults: Optional[Dict[str, Any]] = None,
|
|
109
|
+
config: Optional[Dict[str, Any]] = None,
|
|
110
|
+
) -> Namespace:
|
|
111
|
+
"""
|
|
112
|
+
Parse passed arguments, defaults, and config values into a namespace for
|
|
113
|
+
a component function.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
cmpnt_fn: Component function
|
|
117
|
+
cmpnt_args: Function args
|
|
118
|
+
cmpnt_defaults: Additional default values for parameters of ``app_fn``
|
|
119
|
+
(overrides the defaults set on the fn declaration)
|
|
120
|
+
config: Optional dict containing additional configuration for the component from a passed config file
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
A Namespace object with the args, defaults, and config values incorporated.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
script_parser = _create_args_parser(cmpnt_fn, cmpnt_defaults, config)
|
|
127
|
+
parsed_args = script_parser.parse_args(cmpnt_args)
|
|
128
|
+
if config:
|
|
129
|
+
_merge_config_values_with_args(parsed_args, config)
|
|
130
|
+
|
|
131
|
+
return parsed_args
|
|
132
|
+
|
|
133
|
+
|
|
93
134
|
def materialize_appdef(
|
|
94
135
|
cmpnt_fn: Callable[..., AppDef],
|
|
95
136
|
cmpnt_args: List[str],
|
|
96
|
-
cmpnt_defaults: Optional[Dict[str,
|
|
137
|
+
cmpnt_defaults: Optional[Dict[str, Any]] = None,
|
|
138
|
+
config: Optional[Dict[str, Any]] = None,
|
|
139
|
+
component_args_string: Optional[str] = None,
|
|
97
140
|
) -> AppDef:
|
|
98
141
|
"""
|
|
99
142
|
Creates an application by running user defined ``app_fn``.
|
|
@@ -118,26 +161,23 @@ def materialize_appdef(
|
|
|
118
161
|
cmpnt_args: Function args
|
|
119
162
|
cmpnt_defaults: Additional default values for parameters of ``app_fn``
|
|
120
163
|
(overrides the defaults set on the fn declaration)
|
|
164
|
+
config: Optional dict containing additional configuration for the component from a passed config file
|
|
121
165
|
Returns:
|
|
122
166
|
An application spec
|
|
123
167
|
"""
|
|
124
168
|
|
|
125
|
-
script_parser = _create_args_parser(cmpnt_fn, cmpnt_defaults)
|
|
126
|
-
parsed_args = script_parser.parse_args(cmpnt_args)
|
|
127
|
-
|
|
128
169
|
function_args = []
|
|
129
170
|
var_arg = []
|
|
130
171
|
kwargs = {}
|
|
131
172
|
|
|
173
|
+
parsed_args = parse_args(cmpnt_fn, cmpnt_args, cmpnt_defaults, config)
|
|
174
|
+
|
|
132
175
|
parameters = inspect.signature(cmpnt_fn).parameters
|
|
133
176
|
for param_name, parameter in parameters.items():
|
|
134
177
|
arg_value = getattr(parsed_args, param_name)
|
|
135
178
|
parameter_type = parameter.annotation
|
|
136
179
|
parameter_type = decode_optional(parameter_type)
|
|
137
|
-
|
|
138
|
-
arg_value = arg_value and arg_value.lower() == "true"
|
|
139
|
-
elif not is_primitive(parameter_type):
|
|
140
|
-
arg_value = decode_from_string(arg_value, parameter_type)
|
|
180
|
+
arg_value = decode(arg_value, parameter_type)
|
|
141
181
|
if parameter.kind == inspect.Parameter.VAR_POSITIONAL:
|
|
142
182
|
var_arg = arg_value
|
|
143
183
|
elif parameter.kind == inspect.Parameter.KEYWORD_ONLY:
|
|
@@ -149,7 +189,13 @@ def materialize_appdef(
|
|
|
149
189
|
if len(var_arg) > 0 and var_arg[0] == "--":
|
|
150
190
|
var_arg = var_arg[1:]
|
|
151
191
|
|
|
152
|
-
|
|
192
|
+
appdef = cmpnt_fn(*function_args, *var_arg, **kwargs)
|
|
193
|
+
|
|
194
|
+
if component_args_string:
|
|
195
|
+
for role in appdef.roles:
|
|
196
|
+
role.env[ENV_TORCHX_COMPONENT_ARGS] = component_args_string
|
|
197
|
+
|
|
198
|
+
return appdef
|
|
153
199
|
|
|
154
200
|
|
|
155
201
|
def make_app_handle(scheduler_backend: str, session_name: str, app_id: str) -> str:
|
|
@@ -205,9 +251,12 @@ def parse_mounts(opts: List[str]) -> List[Union[BindMount, VolumeMount, DeviceMo
|
|
|
205
251
|
for opts in mount_opts:
|
|
206
252
|
typ = opts.get("type")
|
|
207
253
|
if typ == MountType.BIND:
|
|
254
|
+
src_path = opts["src"]
|
|
255
|
+
if src_path.startswith("~"):
|
|
256
|
+
src_path = os.path.expanduser(src_path)
|
|
208
257
|
mounts.append(
|
|
209
258
|
BindMount(
|
|
210
|
-
src_path=
|
|
259
|
+
src_path=src_path,
|
|
211
260
|
dst_path=opts["dst"],
|
|
212
261
|
read_only="readonly" in opts,
|
|
213
262
|
)
|
torchx/specs/file_linter.py
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# This source code is licensed under the BSD-style license found in the
|
|
6
6
|
# LICENSE file in the root directory of this source tree.
|
|
7
7
|
|
|
8
|
+
# pyre-strict
|
|
9
|
+
|
|
8
10
|
import abc
|
|
9
11
|
import argparse
|
|
10
12
|
import ast
|
|
@@ -29,7 +31,11 @@ def _get_default_arguments_descriptions(fn: Callable[..., object]) -> Dict[str,
|
|
|
29
31
|
return args_decs
|
|
30
32
|
|
|
31
33
|
|
|
32
|
-
class TorchXArgumentHelpFormatter(
|
|
34
|
+
class TorchXArgumentHelpFormatter(
|
|
35
|
+
argparse.RawDescriptionHelpFormatter,
|
|
36
|
+
argparse.ArgumentDefaultsHelpFormatter,
|
|
37
|
+
argparse.MetavarTypeHelpFormatter,
|
|
38
|
+
):
|
|
33
39
|
"""Help message formatter which adds default values and required to argument help.
|
|
34
40
|
|
|
35
41
|
If the argument is required, the class appends `(required)` at the end of the help message.
|
|
@@ -79,7 +85,7 @@ to your component (see: https://pytorch.org/torchx/latest/component_best_practic
|
|
|
79
85
|
args_description[param.arg_name] = param.description
|
|
80
86
|
short_func_description = docstring.short_description or default_fn_desc
|
|
81
87
|
if docstring.long_description:
|
|
82
|
-
short_func_description += "
|
|
88
|
+
short_func_description += "\n" + docstring.long_description
|
|
83
89
|
return (short_func_description or default_fn_desc, args_description)
|
|
84
90
|
|
|
85
91
|
|
torchx/specs/finder.py
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
|
6
6
|
|
|
7
|
+
# pyre-strict
|
|
8
|
+
|
|
7
9
|
r"""
|
|
8
10
|
`torchx.specs.named_resources_aws` contains resource definitions that represent corresponding AWS instance types
|
|
9
11
|
taken from https://aws.amazon.com/ec2/instance-types/. The resources are exposed
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
|
6
6
|
|
|
7
|
+
# pyre-strict
|
|
8
|
+
|
|
7
9
|
"""
|
|
8
10
|
Defines generic named resources that are not specific to any cloud provider's
|
|
9
11
|
instance types. These generic named resources are meant to be used as
|
torchx/tracker/__init__.py
CHANGED
torchx/tracker/api.py
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
|
6
6
|
|
|
7
|
+
# pyre-strict
|
|
8
|
+
|
|
7
9
|
from __future__ import annotations
|
|
8
10
|
|
|
9
11
|
import logging
|
|
@@ -67,8 +69,7 @@ class AppRunTrackableSource:
|
|
|
67
69
|
artifact_name: Optional[str]
|
|
68
70
|
|
|
69
71
|
|
|
70
|
-
class Lineage:
|
|
71
|
-
...
|
|
72
|
+
class Lineage: ...
|
|
72
73
|
|
|
73
74
|
|
|
74
75
|
class TrackerBase(ABC):
|
|
@@ -332,5 +333,4 @@ class AppRun:
|
|
|
332
333
|
|
|
333
334
|
return model_run_sources
|
|
334
335
|
|
|
335
|
-
def children(self) -> Iterable[AppRun]:
|
|
336
|
-
...
|
|
336
|
+
def children(self) -> Iterable[AppRun]: ...
|
torchx/tracker/backend/fsspec.py
CHANGED
torchx/util/cuda.py
CHANGED
torchx/util/datetime.py
CHANGED
torchx/util/entrypoints.py
CHANGED
torchx/util/io.py
CHANGED
torchx/util/modules.py
CHANGED
torchx/util/shlex.py
CHANGED
torchx/util/strings.py
CHANGED
torchx/util/types.py
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
|
6
6
|
|
|
7
|
+
# pyre-strict
|
|
8
|
+
|
|
7
9
|
import inspect
|
|
8
10
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
|
9
11
|
|
|
@@ -120,6 +122,16 @@ def _decode_string_to_list(
|
|
|
120
122
|
return arg_values
|
|
121
123
|
|
|
122
124
|
|
|
125
|
+
def decode(encoded_value: Any, annotation: Any):
|
|
126
|
+
if encoded_value is None:
|
|
127
|
+
return None
|
|
128
|
+
if is_bool(annotation):
|
|
129
|
+
return encoded_value and encoded_value.lower() == "true"
|
|
130
|
+
if not is_primitive(annotation) and type(encoded_value) == str:
|
|
131
|
+
return decode_from_string(encoded_value, annotation)
|
|
132
|
+
return encoded_value
|
|
133
|
+
|
|
134
|
+
|
|
123
135
|
def decode_from_string(
|
|
124
136
|
encoded_value: str, annotation: Any
|
|
125
137
|
) -> Union[Dict[Any, Any], List[Any], None]:
|