ob-metaflow-extensions 1.1.149__tar.gz → 1.1.151__tar.gz
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 ob-metaflow-extensions might be problematic. Click here for more details.
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/PKG-INFO +1 -1
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/__init__.py +2 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct/exceptions.py +71 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct/nvct.py +131 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct/nvct_cli.py +289 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct/nvct_decorator.py +262 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct/nvct_runner.py +218 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct/utils.py +29 -0
- ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/snowpark/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/ob_metaflow_extensions.egg-info/PKG-INFO +1 -1
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/ob_metaflow_extensions.egg-info/SOURCES.txt +7 -0
- ob-metaflow-extensions-1.1.151/ob_metaflow_extensions.egg-info/requires.txt +3 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/setup.py +2 -2
- ob-metaflow-extensions-1.1.149/ob_metaflow_extensions.egg-info/requires.txt +0 -3
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/README.md +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/config/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/apps/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/apps/app_utils.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/apps/consts.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/apps/deploy_decorator.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/apps/supervisord_utils.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/auth_server.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/card_utilities/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/card_utilities/async_cards.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/card_utilities/extra_components.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/card_utilities/injector.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/checkpoint_datastores/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/checkpoint_datastores/nebius.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/fast_bakery/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/fast_bakery/docker_environment.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/fast_bakery/fast_bakery.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/fast_bakery/fast_bakery_cli.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/fast_bakery/fast_bakery_decorator.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/kubernetes/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/kubernetes/kubernetes_client.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nim/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nim/card.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nim/nim_manager.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nim/utilities.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/constants.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/exceptions.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/heartbeat_store.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/nvcf.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/nvcf_cli.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/nvcf_decorator.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/nvcf/utils.py +0 -0
- {ob-metaflow-extensions-1.1.149/metaflow_extensions/outerbounds/plugins/secrets → ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/nvct}/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/ollama/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/ollama/ollama.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/perimeters.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/profilers/deco_injector.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/profilers/gpu_profile_decorator.py +0 -0
- {ob-metaflow-extensions-1.1.149/metaflow_extensions/outerbounds/plugins/snowpark → ob-metaflow-extensions-1.1.151/metaflow_extensions/outerbounds/plugins/secrets}/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/secrets/secrets.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowflake/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowflake/snowflake.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark_cli.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark_client.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark_decorator.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark_exceptions.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark_job.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/snowpark/snowpark_service_spec.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/plugins/tensorboard/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/profilers/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/profilers/gpu.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/remote_config.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/plugins/azure/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/plugins/gcp/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/plugins/kubernetes/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/plugins/ollama/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/metaflow_extensions/outerbounds/toplevel/plugins/snowflake/__init__.py +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/ob_metaflow_extensions.egg-info/dependency_links.txt +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/ob_metaflow_extensions.egg-info/top_level.txt +0 -0
- {ob-metaflow-extensions-1.1.149 → ob-metaflow-extensions-1.1.151}/setup.cfg +0 -0
|
@@ -312,11 +312,13 @@ class ObpGcpAuthProvider(object):
|
|
|
312
312
|
GCP_CLIENT_PROVIDERS_DESC = [("obp", ".ObpGcpAuthProvider")]
|
|
313
313
|
CLIS_DESC = [
|
|
314
314
|
("nvidia", ".nvcf.nvcf_cli.cli"),
|
|
315
|
+
("nvct", ".nvct.nvct_cli.cli"),
|
|
315
316
|
("fast-bakery", ".fast_bakery.fast_bakery_cli.cli"),
|
|
316
317
|
("snowpark", ".snowpark.snowpark_cli.cli"),
|
|
317
318
|
]
|
|
318
319
|
STEP_DECORATORS_DESC = [
|
|
319
320
|
("nvidia", ".nvcf.nvcf_decorator.NvcfDecorator"),
|
|
321
|
+
("nvct", ".nvct.nvct_decorator.NvctDecorator"),
|
|
320
322
|
(
|
|
321
323
|
"fast_bakery_internal",
|
|
322
324
|
".fast_bakery.fast_bakery_decorator.InternalFastBakeryDecorator",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from metaflow.exception import MetaflowException
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class NvctExecutionException(MetaflowException):
|
|
5
|
+
headline = "Nvct task couldn't be executed"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class NvctTaskFailedException(MetaflowException):
|
|
9
|
+
headline = "Nvct task failed"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class NvctKilledException(MetaflowException):
|
|
13
|
+
headline = "Nvct job killed"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class RequestedGPUTypeUnavailableException(MetaflowException):
|
|
17
|
+
headline = "[@nvct RequestedGPUTypeUnavailableException] GPU type unavailable."
|
|
18
|
+
|
|
19
|
+
def __init__(self, requested_gpu_type, available_gpus):
|
|
20
|
+
msg = (
|
|
21
|
+
f"The requested GPU type @nvct(..., gpu_type='{requested_gpu_type}') is not available. "
|
|
22
|
+
f"Please choose from the following supported GPU types when using @nvct: {available_gpus}"
|
|
23
|
+
)
|
|
24
|
+
super(RequestedGPUTypeUnavailableException, self).__init__(msg)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class UnsupportedNvctConfigurationException(MetaflowException):
|
|
28
|
+
headline = (
|
|
29
|
+
"[@nvct UnsupportedNvctConfigurationException] Unsupported GPU configuration"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def __init__(self, n_gpu, gpu_type, available_configurations, step):
|
|
33
|
+
msg = f"The requested configuration of @nvct(gpu={n_gpu}, gpu_type='{gpu_type}') for @step {step} is not available."
|
|
34
|
+
if len(available_configurations) == 0:
|
|
35
|
+
msg += (
|
|
36
|
+
"\n\nNo configurations are available in your Outerbounds deployment."
|
|
37
|
+
" Please contact Outerbounds support if you wish to use @nvct."
|
|
38
|
+
)
|
|
39
|
+
else:
|
|
40
|
+
msg += f"\n\nAvailable configurations for your deployment with {gpu_type} include: \n\t- {self._display(gpu_type, available_configurations)}"
|
|
41
|
+
msg += "\n\nPlease contact Outerbounds support if you wish to use a configuration not listed above."
|
|
42
|
+
super(UnsupportedNvctConfigurationException, self).__init__(msg)
|
|
43
|
+
|
|
44
|
+
def _display(self, gpu_type, configs):
|
|
45
|
+
_available_decos = []
|
|
46
|
+
for cfg in configs:
|
|
47
|
+
n_gpu = cfg["n_gpus"]
|
|
48
|
+
_available_decos.append(f"@nvct(gpu={n_gpu}, gpu_type='{gpu_type}')")
|
|
49
|
+
return "\n\t- ".join(_available_decos)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class UnsupportedNvctDatastoreException(MetaflowException):
|
|
53
|
+
headline = "[@nvct UnsupportedNvctDatastoreException] Unsupported datastore"
|
|
54
|
+
|
|
55
|
+
def __init__(self, ds_type):
|
|
56
|
+
msg = (
|
|
57
|
+
"The *@nvct* decorator requires --datastore=s3 or --datastore=azure or --datastore=gs at the moment."
|
|
58
|
+
f"Current datastore type: {ds_type}."
|
|
59
|
+
)
|
|
60
|
+
super(UnsupportedNvctDatastoreException, self).__init__(msg)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class NvctTimeoutTooShortException(MetaflowException):
|
|
64
|
+
headline = "[@nvct NvctTimeoutTooShortException] Timeout too short"
|
|
65
|
+
|
|
66
|
+
def __init__(self, step):
|
|
67
|
+
msg = (
|
|
68
|
+
"The timeout for step *{step}* should be at least 60 seconds for "
|
|
69
|
+
"execution with @nvct".format(step=step)
|
|
70
|
+
)
|
|
71
|
+
super(NvctTimeoutTooShortException, self).__init__(msg)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from requests.adapters import HTTPAdapter, Retry
|
|
3
|
+
|
|
4
|
+
BASE_URL = "https://api.ngc.nvidia.com/v2/orgs/zhxkmsaasxhw/"
|
|
5
|
+
POLL_SEC = 1
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _session(api_key):
|
|
9
|
+
s = requests.Session()
|
|
10
|
+
s.headers.update(
|
|
11
|
+
{
|
|
12
|
+
"Authorization": f"Bearer {api_key}",
|
|
13
|
+
"Content-Type": "application/json",
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
retry = Retry(total=5, backoff_factor=1.5, status_forcelist=[502, 503, 504])
|
|
17
|
+
s.mount("https://", HTTPAdapter(max_retries=retry))
|
|
18
|
+
return s
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _url(path):
|
|
22
|
+
return BASE_URL.rstrip("/") + path
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class NVCTClient:
|
|
26
|
+
def __init__(self, api_key):
|
|
27
|
+
self.sess = _session(api_key)
|
|
28
|
+
|
|
29
|
+
# TODO: Handle https://outerboundsco.slack.com/archives/C05QGNR4E06/p1745970955540289
|
|
30
|
+
def create(self, spec):
|
|
31
|
+
r = self.sess.post(_url("/nvct/tasks"), json=spec, timeout=30)
|
|
32
|
+
r.raise_for_status()
|
|
33
|
+
return r.json().get("task", {}).get("id")
|
|
34
|
+
|
|
35
|
+
def get(self, task_id):
|
|
36
|
+
r = self.sess.get(_url(f"/nvct/tasks/{task_id}"), timeout=30)
|
|
37
|
+
r.raise_for_status()
|
|
38
|
+
return r.json().get("task", {})
|
|
39
|
+
|
|
40
|
+
def cancel(self, task_id):
|
|
41
|
+
r = self.sess.post(_url(f"/nvct/tasks/{task_id}/cancel"), timeout=30)
|
|
42
|
+
r.raise_for_status()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class NVCTRequest(object):
|
|
46
|
+
def __init__(self, name):
|
|
47
|
+
self._spec = {}
|
|
48
|
+
self._spec["name"] = name
|
|
49
|
+
self._spec["gpuSpecification"] = {}
|
|
50
|
+
self._spec["resultHandlingStrategy"] = "NONE"
|
|
51
|
+
self._spec["terminationGracePeriodDuration"] = "PT10M"
|
|
52
|
+
|
|
53
|
+
def container_image(self, image):
|
|
54
|
+
self._spec["containerImage"] = image
|
|
55
|
+
return self
|
|
56
|
+
|
|
57
|
+
def container_args(self, args):
|
|
58
|
+
self._spec["containerArgs"] = args
|
|
59
|
+
return self
|
|
60
|
+
|
|
61
|
+
def env(self, key, value):
|
|
62
|
+
env_list = self._spec.setdefault("containerEnvironment", [])
|
|
63
|
+
env_list.append({"key": key, "value": value})
|
|
64
|
+
return self
|
|
65
|
+
|
|
66
|
+
def gpu(self, gpu, instance_type, backend):
|
|
67
|
+
gpu_spec = self._spec["gpuSpecification"]
|
|
68
|
+
gpu_spec["gpu"] = gpu
|
|
69
|
+
gpu_spec["instanceType"] = instance_type
|
|
70
|
+
gpu_spec["backend"] = backend
|
|
71
|
+
return self
|
|
72
|
+
|
|
73
|
+
def max_runtime(self, iso_duration):
|
|
74
|
+
self._spec["maxRuntimeDuration"] = iso_duration
|
|
75
|
+
return self
|
|
76
|
+
|
|
77
|
+
def max_queued(self, iso_duration="PT72H"):
|
|
78
|
+
self._spec["maxQueuedDuration"] = iso_duration
|
|
79
|
+
return self
|
|
80
|
+
|
|
81
|
+
def termination_grace(self, iso_duration="PT10M"):
|
|
82
|
+
self._spec["terminationGracePeriodDuration"] = iso_duration
|
|
83
|
+
return self
|
|
84
|
+
|
|
85
|
+
def extra(self, key, value):
|
|
86
|
+
self._spec[key] = value
|
|
87
|
+
return self
|
|
88
|
+
|
|
89
|
+
def to_dict(self):
|
|
90
|
+
return self._spec
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class NVCTTask:
|
|
94
|
+
def __init__(self, client: NVCTClient, spec):
|
|
95
|
+
self.client = client
|
|
96
|
+
self.spec = spec
|
|
97
|
+
self.id = None
|
|
98
|
+
self.record = None
|
|
99
|
+
|
|
100
|
+
def submit(self):
|
|
101
|
+
self.id = self.client.create(self.spec)
|
|
102
|
+
return self.id
|
|
103
|
+
|
|
104
|
+
def cancel(self):
|
|
105
|
+
if not self.has_finished:
|
|
106
|
+
self.client.cancel(self.id)
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def status(self):
|
|
110
|
+
self.record = self.client.get(self.id)
|
|
111
|
+
return self.record["status"]
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def is_waiting(self):
|
|
115
|
+
return self.status == "QUEUED"
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def is_running(self):
|
|
119
|
+
return self.status in {"RUNNING", "LAUNCHED"}
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def has_failed(self):
|
|
123
|
+
return self.status in {"ERRORED", "CANCELED"}
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def has_succeeded(self):
|
|
127
|
+
return self.status == "COMPLETED"
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def has_finished(self):
|
|
131
|
+
return self.has_succeeded or self.has_failed
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import time
|
|
5
|
+
import traceback
|
|
6
|
+
|
|
7
|
+
from metaflow import util, Run
|
|
8
|
+
from metaflow._vendor import click
|
|
9
|
+
from metaflow.exception import METAFLOW_EXIT_DISALLOW_RETRY
|
|
10
|
+
from metaflow.metadata_provider.util import sync_local_metadata_from_datastore
|
|
11
|
+
from metaflow.metaflow_config import (
|
|
12
|
+
CARD_S3ROOT,
|
|
13
|
+
DATASTORE_LOCAL_DIR,
|
|
14
|
+
DATASTORE_SYSROOT_S3,
|
|
15
|
+
DATATOOLS_S3ROOT,
|
|
16
|
+
DEFAULT_METADATA,
|
|
17
|
+
SERVICE_HEADERS,
|
|
18
|
+
SERVICE_URL,
|
|
19
|
+
DEFAULT_SECRETS_BACKEND_TYPE,
|
|
20
|
+
DEFAULT_AWS_CLIENT_PROVIDER,
|
|
21
|
+
AWS_SECRETS_MANAGER_DEFAULT_REGION,
|
|
22
|
+
S3_ENDPOINT_URL,
|
|
23
|
+
AZURE_STORAGE_BLOB_SERVICE_ENDPOINT,
|
|
24
|
+
DATASTORE_SYSROOT_AZURE,
|
|
25
|
+
CARD_AZUREROOT,
|
|
26
|
+
DATASTORE_SYSROOT_GS,
|
|
27
|
+
CARD_GSROOT,
|
|
28
|
+
KUBERNETES_SANDBOX_INIT_SCRIPT,
|
|
29
|
+
OTEL_ENDPOINT,
|
|
30
|
+
)
|
|
31
|
+
from metaflow.mflog import TASK_LOG_SOURCE
|
|
32
|
+
from .nvct_runner import NvctRunner
|
|
33
|
+
from .nvct import NVCTClient
|
|
34
|
+
from .utils import get_ngc_api_key
|
|
35
|
+
from .exceptions import NvctKilledException
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@click.group()
|
|
39
|
+
def cli():
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@cli.group(help="Commands related to nvct.")
|
|
44
|
+
def nvct():
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@nvct.command(help="List steps / tasks running as an nvct job.")
|
|
49
|
+
@click.option(
|
|
50
|
+
"--run-id",
|
|
51
|
+
default=None,
|
|
52
|
+
required=True,
|
|
53
|
+
help="List unfinished and running tasks corresponding to the run id.",
|
|
54
|
+
)
|
|
55
|
+
@click.pass_context
|
|
56
|
+
def list(ctx, run_id):
|
|
57
|
+
flow_name = ctx.obj.flow.name
|
|
58
|
+
run_obj = Run(pathspec=f"{flow_name}/{run_id}", _namespace_check=False)
|
|
59
|
+
running_invocations = []
|
|
60
|
+
|
|
61
|
+
for each_step in run_obj:
|
|
62
|
+
for each_task in each_step:
|
|
63
|
+
if not each_task.finished and "nvct-task-id" in each_task.metadata_dict:
|
|
64
|
+
task_pathspec = each_task.pathspec
|
|
65
|
+
attempt = each_task.metadata_dict.get("attempt")
|
|
66
|
+
flow_name, run_id, step_name, task_id = task_pathspec.split("/")
|
|
67
|
+
running_invocations.append(
|
|
68
|
+
f"Flow Name: {flow_name}, Run ID: {run_id}, Step Name: {step_name}, Task ID: {task_id}, Retry Count: {attempt}"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
if running_invocations:
|
|
72
|
+
for each_invocation in running_invocations:
|
|
73
|
+
ctx.obj.echo(each_invocation)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@nvct.command(help="Cancel steps / tasks running as an nvct job.")
|
|
77
|
+
@click.option(
|
|
78
|
+
"--run-id",
|
|
79
|
+
default=None,
|
|
80
|
+
required=True,
|
|
81
|
+
help="Terminate unfinished tasks corresponding to the run id.",
|
|
82
|
+
)
|
|
83
|
+
@click.pass_context
|
|
84
|
+
def kill(ctx, run_id):
|
|
85
|
+
ngc_api_key = get_ngc_api_key()
|
|
86
|
+
nvct_client = NVCTClient(api_key=ngc_api_key)
|
|
87
|
+
|
|
88
|
+
flow_name = ctx.obj.flow.name
|
|
89
|
+
run_obj = Run(pathspec=f"{flow_name}/{run_id}", _namespace_check=False)
|
|
90
|
+
tasks_cancelled = []
|
|
91
|
+
|
|
92
|
+
for each_step in run_obj:
|
|
93
|
+
for each_task in each_step:
|
|
94
|
+
if not each_task.finished and "nvct-task-id" in each_task.metadata_dict:
|
|
95
|
+
task_pathspec = each_task.pathspec
|
|
96
|
+
attempt = each_task.metadata_dict.get("attempt")
|
|
97
|
+
_, _, step_name, task_id = task_pathspec.split("/")
|
|
98
|
+
|
|
99
|
+
nvct_task_id = each_task.metadata_dict.get("nvct-task-id")
|
|
100
|
+
nvct_client.cancel(nvct_task_id)
|
|
101
|
+
|
|
102
|
+
tasks_cancelled.append(
|
|
103
|
+
f"[{nvct_task_id}] -- Flow Name: {flow_name}, Run ID: {run_id}, Step Name: {step_name}, Task ID: {task_id}, Retry Count: {attempt} is cancelled."
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
if tasks_cancelled:
|
|
107
|
+
for each_cancelled_task in tasks_cancelled:
|
|
108
|
+
ctx.obj.echo(each_cancelled_task)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@nvct.command(
|
|
112
|
+
help="Execute a single task using @nvct. This command calls the "
|
|
113
|
+
"top-level step command inside an nvct job with the given options. "
|
|
114
|
+
"Typically you do not call this command directly; it is used internally by "
|
|
115
|
+
"Metaflow."
|
|
116
|
+
)
|
|
117
|
+
@click.argument("step-name")
|
|
118
|
+
@click.argument("code-package-sha")
|
|
119
|
+
@click.argument("code-package-url")
|
|
120
|
+
@click.option("--gpu-type", help="Type of Nvidia GPU to use.")
|
|
121
|
+
@click.option("--instance-type", help="Instance type to use.")
|
|
122
|
+
@click.option("--backend", help="Backend to use.")
|
|
123
|
+
@click.option("--ngc-api-key", help="NGC API key.")
|
|
124
|
+
@click.option("--run-id", help="Passed to the top-level 'step'.")
|
|
125
|
+
@click.option("--task-id", help="Passed to the top-level 'step'.")
|
|
126
|
+
@click.option("--input-paths", help="Passed to the top-level 'step'.")
|
|
127
|
+
@click.option("--split-index", help="Passed to the top-level 'step'.")
|
|
128
|
+
@click.option("--clone-path", help="Passed to the top-level 'step'.")
|
|
129
|
+
@click.option("--clone-run-id", help="Passed to the top-level 'step'.")
|
|
130
|
+
@click.option(
|
|
131
|
+
"--tag", multiple=True, default=None, help="Passed to the top-level 'step'."
|
|
132
|
+
)
|
|
133
|
+
@click.option("--namespace", default=None, help="Passed to the top-level 'step'.")
|
|
134
|
+
@click.option("--retry-count", default=0, help="Passed to the top-level 'step'.")
|
|
135
|
+
@click.option(
|
|
136
|
+
"--max-user-code-retries", default=0, help="Passed to the top-level 'step'."
|
|
137
|
+
)
|
|
138
|
+
@click.pass_context
|
|
139
|
+
def step(
|
|
140
|
+
ctx,
|
|
141
|
+
step_name,
|
|
142
|
+
code_package_sha,
|
|
143
|
+
code_package_url,
|
|
144
|
+
gpu_type,
|
|
145
|
+
instance_type,
|
|
146
|
+
backend,
|
|
147
|
+
ngc_api_key,
|
|
148
|
+
**kwargs,
|
|
149
|
+
):
|
|
150
|
+
def echo(msg, stream="stderr", _id=None, **kwargs):
|
|
151
|
+
msg = util.to_unicode(msg)
|
|
152
|
+
if _id:
|
|
153
|
+
msg = "[%s] %s" % (_id, msg)
|
|
154
|
+
ctx.obj.echo_always(msg, err=(stream == sys.stderr), **kwargs)
|
|
155
|
+
|
|
156
|
+
executable = ctx.obj.environment.executable(step_name)
|
|
157
|
+
entrypoint = "%s -u %s" % (executable, os.path.basename(sys.argv[0]))
|
|
158
|
+
|
|
159
|
+
top_args = " ".join(util.dict_to_cli_options(ctx.parent.parent.params))
|
|
160
|
+
|
|
161
|
+
input_paths = kwargs.get("input_paths")
|
|
162
|
+
split_vars = None
|
|
163
|
+
if input_paths:
|
|
164
|
+
max_size = 30 * 1024
|
|
165
|
+
split_vars = {
|
|
166
|
+
"METAFLOW_INPUT_PATHS_%d" % (i // max_size): input_paths[i : i + max_size]
|
|
167
|
+
for i in range(0, len(input_paths), max_size)
|
|
168
|
+
}
|
|
169
|
+
kwargs["input_paths"] = "".join("${%s}" % s for s in split_vars.keys())
|
|
170
|
+
|
|
171
|
+
step_args = " ".join(util.dict_to_cli_options(kwargs))
|
|
172
|
+
step_cli = "{entrypoint} {top_args} step {step} {step_args}".format(
|
|
173
|
+
entrypoint=entrypoint,
|
|
174
|
+
top_args=top_args,
|
|
175
|
+
step=step_name,
|
|
176
|
+
step_args=step_args,
|
|
177
|
+
)
|
|
178
|
+
node = ctx.obj.graph[step_name]
|
|
179
|
+
|
|
180
|
+
# Get retry information
|
|
181
|
+
retry_count = kwargs.get("retry_count", 0)
|
|
182
|
+
retry_deco = [deco for deco in node.decorators if deco.name == "retry"]
|
|
183
|
+
minutes_between_retries = None
|
|
184
|
+
if retry_deco:
|
|
185
|
+
minutes_between_retries = int(
|
|
186
|
+
retry_deco[0].attributes.get("minutes_between_retries", 1)
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
task_spec = {
|
|
190
|
+
"flow_name": ctx.obj.flow.name,
|
|
191
|
+
"step_name": step_name,
|
|
192
|
+
"run_id": kwargs["run_id"],
|
|
193
|
+
"task_id": kwargs["task_id"],
|
|
194
|
+
"retry_count": str(retry_count),
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
env = {
|
|
198
|
+
"METAFLOW_CODE_SHA": code_package_sha,
|
|
199
|
+
"METAFLOW_CODE_URL": code_package_url,
|
|
200
|
+
"METAFLOW_CODE_DS": ctx.obj.flow_datastore.TYPE,
|
|
201
|
+
"METAFLOW_SERVICE_URL": SERVICE_URL,
|
|
202
|
+
"METAFLOW_SERVICE_HEADERS": json.dumps(SERVICE_HEADERS),
|
|
203
|
+
"METAFLOW_DATASTORE_SYSROOT_S3": DATASTORE_SYSROOT_S3,
|
|
204
|
+
"METAFLOW_DATATOOLS_S3ROOT": DATATOOLS_S3ROOT,
|
|
205
|
+
"METAFLOW_DEFAULT_DATASTORE": ctx.obj.flow_datastore.TYPE,
|
|
206
|
+
"METAFLOW_USER": util.get_username(),
|
|
207
|
+
"METAFLOW_DEFAULT_METADATA": DEFAULT_METADATA,
|
|
208
|
+
"METAFLOW_CARD_S3ROOT": CARD_S3ROOT,
|
|
209
|
+
"METAFLOW_RUNTIME_ENVIRONMENT": "nvct",
|
|
210
|
+
"METAFLOW_DEFAULT_SECRETS_BACKEND_TYPE": DEFAULT_SECRETS_BACKEND_TYPE,
|
|
211
|
+
"METAFLOW_DEFAULT_AWS_CLIENT_PROVIDER": DEFAULT_AWS_CLIENT_PROVIDER,
|
|
212
|
+
"METAFLOW_AWS_SECRETS_MANAGER_DEFAULT_REGION": AWS_SECRETS_MANAGER_DEFAULT_REGION,
|
|
213
|
+
"METAFLOW_S3_ENDPOINT_URL": S3_ENDPOINT_URL,
|
|
214
|
+
"METAFLOW_AZURE_STORAGE_BLOB_SERVICE_ENDPOINT": AZURE_STORAGE_BLOB_SERVICE_ENDPOINT,
|
|
215
|
+
"METAFLOW_DATASTORE_SYSROOT_AZURE": DATASTORE_SYSROOT_AZURE,
|
|
216
|
+
"METAFLOW_CARD_AZUREROOT": CARD_AZUREROOT,
|
|
217
|
+
"METAFLOW_DATASTORE_SYSROOT_GS": DATASTORE_SYSROOT_GS,
|
|
218
|
+
"METAFLOW_CARD_GSROOT": CARD_GSROOT,
|
|
219
|
+
"METAFLOW_INIT_SCRIPT": KUBERNETES_SANDBOX_INIT_SCRIPT,
|
|
220
|
+
"METAFLOW_OTEL_ENDPOINT": OTEL_ENDPOINT,
|
|
221
|
+
"NVCT_CONTEXT": "1",
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
env_deco = [deco for deco in node.decorators if deco.name == "environment"]
|
|
225
|
+
if env_deco:
|
|
226
|
+
env.update(env_deco[0].attributes["vars"])
|
|
227
|
+
|
|
228
|
+
# Add the environment variables related to the input-paths argument
|
|
229
|
+
if split_vars:
|
|
230
|
+
env.update(split_vars)
|
|
231
|
+
|
|
232
|
+
if retry_count:
|
|
233
|
+
ctx.obj.echo_always(
|
|
234
|
+
"Sleeping %d minutes before the next retry" % minutes_between_retries
|
|
235
|
+
)
|
|
236
|
+
time.sleep(minutes_between_retries * 60)
|
|
237
|
+
|
|
238
|
+
# this information is needed for log tailing
|
|
239
|
+
ds = ctx.obj.flow_datastore.get_task_datastore(
|
|
240
|
+
mode="w",
|
|
241
|
+
run_id=kwargs["run_id"],
|
|
242
|
+
step_name=step_name,
|
|
243
|
+
task_id=kwargs["task_id"],
|
|
244
|
+
attempt=int(retry_count),
|
|
245
|
+
)
|
|
246
|
+
stdout_location = ds.get_log_location(TASK_LOG_SOURCE, "stdout")
|
|
247
|
+
stderr_location = ds.get_log_location(TASK_LOG_SOURCE, "stderr")
|
|
248
|
+
|
|
249
|
+
def _sync_metadata():
|
|
250
|
+
if ctx.obj.metadata.TYPE == "local":
|
|
251
|
+
sync_local_metadata_from_datastore(
|
|
252
|
+
DATASTORE_LOCAL_DIR,
|
|
253
|
+
ctx.obj.flow_datastore.get_task_datastore(
|
|
254
|
+
kwargs["run_id"], step_name, kwargs["task_id"]
|
|
255
|
+
),
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
nvct = NvctRunner(
|
|
259
|
+
ctx.obj.metadata,
|
|
260
|
+
ctx.obj.flow_datastore,
|
|
261
|
+
ctx.obj.environment,
|
|
262
|
+
gpu_type,
|
|
263
|
+
instance_type,
|
|
264
|
+
backend,
|
|
265
|
+
ngc_api_key,
|
|
266
|
+
)
|
|
267
|
+
try:
|
|
268
|
+
with ctx.obj.monitor.measure("metaflow.nvct.launch_task"):
|
|
269
|
+
nvct.launch_task(
|
|
270
|
+
step_name,
|
|
271
|
+
step_cli,
|
|
272
|
+
task_spec,
|
|
273
|
+
code_package_sha,
|
|
274
|
+
code_package_url,
|
|
275
|
+
ctx.obj.flow_datastore.TYPE,
|
|
276
|
+
env=env,
|
|
277
|
+
)
|
|
278
|
+
except Exception:
|
|
279
|
+
traceback.print_exc()
|
|
280
|
+
_sync_metadata()
|
|
281
|
+
sys.exit(METAFLOW_EXIT_DISALLOW_RETRY)
|
|
282
|
+
try:
|
|
283
|
+
nvct.wait_for_completion(stdout_location, stderr_location, echo=echo)
|
|
284
|
+
except NvctKilledException:
|
|
285
|
+
# don't retry killed tasks
|
|
286
|
+
traceback.print_exc()
|
|
287
|
+
sys.exit(METAFLOW_EXIT_DISALLOW_RETRY)
|
|
288
|
+
finally:
|
|
289
|
+
_sync_metadata()
|