ob-metaflow-extensions 1.1.146__py2.py3-none-any.whl → 1.1.147__py2.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 ob-metaflow-extensions might be problematic. Click here for more details.

@@ -0,0 +1,2 @@
1
+ from .nebius import nebius_checkpoints
2
+ from .coreweave import coreweave_checkpoints
@@ -0,0 +1,139 @@
1
+ from metaflow.user_configs.config_decorators import (
2
+ MutableFlow,
3
+ MutableStep,
4
+ CustomFlowDecorator,
5
+ )
6
+ import os
7
+
8
+
9
+ class coreweave_checkpoints(CustomFlowDecorator):
10
+
11
+ """
12
+
13
+ This decorator is used for setting the coreweave object store as the artifact store for checkpoints/models created by the flow.
14
+
15
+ Parameters
16
+ ----------
17
+ secrets: list
18
+ A list of secrets to be added to the step. These secrets should contain any secrets that are required globally and the secret
19
+ for the coreweave object store. The secret should contain the following keys:
20
+ - COREWEAVE_ACCESS_KEY
21
+ - COREWEAVE_SECRET_KEY
22
+
23
+ bucket_path: str
24
+ The path to the bucket to store the checkpoints/models.
25
+
26
+ Usage
27
+ -----
28
+ ```python
29
+ from metaflow import checkpoint, step, FlowSpec, coreweave_checkpoints
30
+
31
+ @coreweave_checkpoints(secrets=[], bucket_path=None)
32
+ class MyFlow(FlowSpec):
33
+ @checkpoint
34
+ @step
35
+ def start(self):
36
+ # Saves the checkpoint in the coreweave object store
37
+ current.checkpoint.save("./foo.txt")
38
+
39
+ @step
40
+ def end(self):
41
+ pass
42
+ ```
43
+ """
44
+
45
+ def __init__(self, *args, **kwargs):
46
+ super().__init__(*args, **kwargs)
47
+
48
+ def init(self, *args, **kwargs):
49
+ self.bucket_path = kwargs.get("bucket_path", None)
50
+
51
+ self.secrets = kwargs.get("secrets", [])
52
+ if self.bucket_path is None:
53
+ raise ValueError(
54
+ "`bucket_path` keyword argument is required for the coreweave_datastore"
55
+ )
56
+ if not self.bucket_path.startswith("s3://"):
57
+ raise ValueError(
58
+ "`bucket_path` must start with `s3://` for the coreweave_datastore"
59
+ )
60
+
61
+ self.coreweave_endpoint_url = f"https://cwobject.com"
62
+ if self.secrets is None:
63
+ raise ValueError(
64
+ "`secrets` keyword argument is required for the coreweave_datastore"
65
+ )
66
+
67
+ def evaluate(self, mutable_flow: MutableFlow) -> None:
68
+ from metaflow import (
69
+ checkpoint,
70
+ model,
71
+ huggingface_hub,
72
+ secrets,
73
+ with_artifact_store,
74
+ )
75
+
76
+ def _add_secrets(step: MutableStep) -> None:
77
+ decos_to_add = []
78
+ swapping_decos = {
79
+ "huggingface_hub": huggingface_hub,
80
+ "model": model,
81
+ "checkpoint": checkpoint,
82
+ }
83
+ already_has_secrets = False
84
+ secrets_present_in_deco = []
85
+ for d in step.decorators:
86
+ if d.name in swapping_decos:
87
+ decos_to_add.append((d.name, d.attributes))
88
+ elif d.name == "secrets":
89
+ already_has_secrets = True
90
+ secrets_present_in_deco.extend(d.attributes["sources"])
91
+
92
+ # If the step aleady has secrets then take all the sources in
93
+ # the secrets and add the addtional secrets to the existing secrets
94
+ secrets_to_add = self.secrets
95
+ if already_has_secrets:
96
+ secrets_to_add.extend(secrets_present_in_deco)
97
+
98
+ secrets_to_add = list(set(secrets_to_add))
99
+
100
+ if len(decos_to_add) == 0:
101
+ if already_has_secrets:
102
+ step.remove_decorator("secrets")
103
+
104
+ step.add_decorator(
105
+ secrets,
106
+ sources=secrets_to_add,
107
+ )
108
+ return
109
+
110
+ for d, _ in decos_to_add:
111
+ step.remove_decorator(d)
112
+
113
+ step.add_decorator(
114
+ secrets,
115
+ sources=secrets_to_add,
116
+ )
117
+ for d, attrs in decos_to_add:
118
+ _deco_to_add = swapping_decos[d]
119
+ step.add_decorator(_deco_to_add, **attrs)
120
+
121
+ def _coreweave_config():
122
+ return {
123
+ "root": self.bucket_path,
124
+ "client_params": {
125
+ "aws_access_key_id": os.environ.get("COREWEAVE_ACCESS_KEY"),
126
+ "aws_secret_access_key": os.environ.get("COREWEAVE_SECRET_KEY"),
127
+ "endpoint_url": self.coreweave_endpoint_url,
128
+ "config": dict(s3={"addressing_style": "virtual"}),
129
+ },
130
+ }
131
+
132
+ mutable_flow.add_decorator(
133
+ with_artifact_store,
134
+ type="coreweave",
135
+ config=_coreweave_config,
136
+ )
137
+
138
+ for step_name, step in mutable_flow.steps:
139
+ _add_secrets(step)
@@ -0,0 +1,144 @@
1
+ from metaflow.user_configs.config_decorators import (
2
+ MutableFlow,
3
+ MutableStep,
4
+ CustomFlowDecorator,
5
+ )
6
+ import os
7
+
8
+ NEBIUS_ENDPOINT_URL = "https://storage.eu-north1.nebius.cloud:443"
9
+
10
+
11
+ class nebius_checkpoints(CustomFlowDecorator):
12
+
13
+ """
14
+
15
+ This decorator is used for setting the nebius's S3 compatible object store as the artifact store for
16
+ checkpoints/models created by the flow.
17
+
18
+ Parameters
19
+ ----------
20
+ secrets: list
21
+ A list of secrets to be added to the step. These secrets should contain any secrets that are required globally and the secret
22
+ for the nebius object store. The secret should contain the following keys:
23
+ - NEBIUS_ACCESS_KEY
24
+ - NEBIUS_SECRET_KEY
25
+
26
+ bucket_path: str
27
+ The path to the bucket to store the checkpoints/models.
28
+
29
+ endpoint_url: str
30
+ The endpoint url for the nebius object store. Defaults to `https://storage.eu-north1.nebius.cloud:443`
31
+
32
+ Usage
33
+ -----
34
+ ```python
35
+ from metaflow import checkpoint, step, FlowSpec, nebius_checkpoints
36
+
37
+ @nebius_checkpoints(secrets=[], bucket_path=None)
38
+ class MyFlow(FlowSpec):
39
+ @checkpoint
40
+ @step
41
+ def start(self):
42
+ # Saves the checkpoint in the nebius object store
43
+ current.checkpoint.save("./foo.txt")
44
+
45
+ @step
46
+ def end(self):
47
+ pass
48
+ ```
49
+ """
50
+
51
+ def __init__(self, *args, **kwargs):
52
+ super().__init__(*args, **kwargs)
53
+
54
+ def init(self, *args, **kwargs):
55
+ self.bucket_path = kwargs.get("bucket_path", None)
56
+
57
+ self.secrets = kwargs.get("secrets", [])
58
+ if self.bucket_path is None:
59
+ raise ValueError(
60
+ "`bucket_path` keyword argument is required for the coreweave_datastore"
61
+ )
62
+ if not self.bucket_path.startswith("s3://"):
63
+ raise ValueError(
64
+ "`bucket_path` must start with `s3://` for the coreweave_datastore"
65
+ )
66
+
67
+ self.nebius_endpoint_url = kwargs.get("endpoint_url", NEBIUS_ENDPOINT_URL)
68
+ if self.secrets is None:
69
+ raise ValueError(
70
+ "`secrets` keyword argument is required for the coreweave_datastore"
71
+ )
72
+
73
+ def evaluate(self, mutable_flow: MutableFlow) -> None:
74
+ from metaflow import (
75
+ checkpoint,
76
+ model,
77
+ huggingface_hub,
78
+ secrets,
79
+ with_artifact_store,
80
+ )
81
+
82
+ def _add_secrets(step: MutableStep) -> None:
83
+ decos_to_add = []
84
+ swapping_decos = {
85
+ "huggingface_hub": huggingface_hub,
86
+ "model": model,
87
+ "checkpoint": checkpoint,
88
+ }
89
+ already_has_secrets = False
90
+ secrets_present_in_deco = []
91
+ for d in step.decorators:
92
+ if d.name in swapping_decos:
93
+ decos_to_add.append((d.name, d.attributes))
94
+ elif d.name == "secrets":
95
+ already_has_secrets = True
96
+ secrets_present_in_deco.extend(d.attributes["sources"])
97
+
98
+ # If the step aleady has secrets then take all the sources in
99
+ # the secrets and add the addtional secrets to the existing secrets
100
+ secrets_to_add = self.secrets
101
+ if already_has_secrets:
102
+ secrets_to_add.extend(secrets_present_in_deco)
103
+
104
+ secrets_to_add = list(set(secrets_to_add))
105
+
106
+ if len(decos_to_add) == 0:
107
+ if already_has_secrets:
108
+ step.remove_decorator("secrets")
109
+
110
+ step.add_decorator(
111
+ secrets,
112
+ sources=secrets_to_add,
113
+ )
114
+ return
115
+
116
+ for d, _ in decos_to_add:
117
+ step.remove_decorator(d)
118
+
119
+ step.add_decorator(
120
+ secrets,
121
+ sources=secrets_to_add,
122
+ )
123
+ for d, attrs in decos_to_add:
124
+ _deco_to_add = swapping_decos[d]
125
+ step.add_decorator(_deco_to_add, **attrs)
126
+
127
+ def _nebius_config():
128
+ return {
129
+ "root": self.bucket_path,
130
+ "client_params": {
131
+ "aws_access_key_id": os.environ.get("NEBIUS_ACCESS_KEY"),
132
+ "aws_secret_access_key": os.environ.get("NEBIUS_SECRET_KEY"),
133
+ "endpoint_url": self.nebius_endpoint_url,
134
+ },
135
+ }
136
+
137
+ mutable_flow.add_decorator(
138
+ with_artifact_store,
139
+ type="s3",
140
+ config=_nebius_config,
141
+ )
142
+
143
+ for step_name, step in mutable_flow.steps:
144
+ _add_secrets(step)
@@ -198,7 +198,12 @@ class NvcfDecorator(StepDecorator):
198
198
  meta["nvcf-nspectid"] = os.environ.get("NVCF_NSPECTID")
199
199
 
200
200
  entries = [
201
- MetaDatum(field=k, value=v, type=k, tags=[])
201
+ MetaDatum(
202
+ field=k,
203
+ value=v,
204
+ type=k,
205
+ tags=["attempt_id:{0}".format(retry_count)],
206
+ )
202
207
  for k, v in meta.items()
203
208
  if v is not None
204
209
  ]
@@ -52,3 +52,4 @@ def S3(*args, **kwargs):
52
52
 
53
53
  from .. import profilers
54
54
  from ..plugins.snowflake import Snowflake
55
+ from ..plugins.checkpoint_datastores import nebius_checkpoints, coreweave_checkpoints
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ob-metaflow-extensions
3
- Version: 1.1.146
3
+ Version: 1.1.147
4
4
  Summary: Outerbounds Platform Extensions for Metaflow
5
5
  Author: Outerbounds, Inc.
6
6
  License: Commercial
@@ -13,6 +13,9 @@ metaflow_extensions/outerbounds/plugins/card_utilities/__init__.py,sha256=47DEQp
13
13
  metaflow_extensions/outerbounds/plugins/card_utilities/async_cards.py,sha256=6rQhtZXK5DenXPfCRS1ul0jvLJYd48jrJAlnodID21w,4347
14
14
  metaflow_extensions/outerbounds/plugins/card_utilities/extra_components.py,sha256=D8rgCaSc7PuLD0MHJjqsjN0g0PQMN1H-ySOJqi5uIOE,19111
15
15
  metaflow_extensions/outerbounds/plugins/card_utilities/injector.py,sha256=UQtHrviFs7Z5LBh0nbaIv8aEnHnyXFjs9TiGCjtcIWc,2452
16
+ metaflow_extensions/outerbounds/plugins/checkpoint_datastores/__init__.py,sha256=H96Bdv2XKTewKIU587sjNbU538SKMZOYWQ2qCp1JaNU,84
17
+ metaflow_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.py,sha256=_WzoOROFjoFa8TzsMNFp-r_1Zz7NUp-5ljn_kKlczXA,4534
18
+ metaflow_extensions/outerbounds/plugins/checkpoint_datastores/nebius.py,sha256=zgqDLFewCeF5jqh-hUNKmC_OAjld09ln0bb8Lkeqapc,4659
16
19
  metaflow_extensions/outerbounds/plugins/fast_bakery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
20
  metaflow_extensions/outerbounds/plugins/fast_bakery/docker_environment.py,sha256=Tl520HdBteg-aDOM7mnnJJpdDCZc49BmFFmLUc_vTi8,15018
18
21
  metaflow_extensions/outerbounds/plugins/fast_bakery/fast_bakery.py,sha256=PE81ZB54OAMXkMGSB7JqgvgMg7N9kvoVclrWL-6jc2U,5626
@@ -30,7 +33,7 @@ metaflow_extensions/outerbounds/plugins/nvcf/exceptions.py,sha256=-Pm9cOWUzpv94T
30
33
  metaflow_extensions/outerbounds/plugins/nvcf/heartbeat_store.py,sha256=pOWwm8LFQBbtku0zNBBwCyXxLK8U-hhC4naQcmU69nE,6217
31
34
  metaflow_extensions/outerbounds/plugins/nvcf/nvcf.py,sha256=3ZFdYItVpFWnHMOeyV1nslUyelfvX5rknh2d2IWxVws,15591
32
35
  metaflow_extensions/outerbounds/plugins/nvcf/nvcf_cli.py,sha256=3D-r5XO88Yh2k1EAZFJTe_PwdbhWp5qXflG8AgE4ZIU,9500
33
- metaflow_extensions/outerbounds/plugins/nvcf/nvcf_decorator.py,sha256=pxxNxW4bW3kbB6ybRam657GyKIhvIkMuidB94iFfCD8,9116
36
+ metaflow_extensions/outerbounds/plugins/nvcf/nvcf_decorator.py,sha256=pSWKaPyGXBEfxG35QA1FQljio8ADjwf-DnPgEsqXoUM,9251
34
37
  metaflow_extensions/outerbounds/plugins/nvcf/utils.py,sha256=DxWSCayfa95e0HJkWacey1s1nxoTpaunGhrb_0Ayv28,133
35
38
  metaflow_extensions/outerbounds/plugins/ollama/__init__.py,sha256=HEsI5U4ckQby7K2NsGBOdizhPY3WWqXSnXx_IHL7_No,2307
36
39
  metaflow_extensions/outerbounds/plugins/ollama/ollama.py,sha256=KlP8_EmnUoi8-PidyU0IDuENYxKjQaHFC33yGsvaeic,13320
@@ -52,13 +55,13 @@ metaflow_extensions/outerbounds/plugins/tensorboard/__init__.py,sha256=9lUM4Cqi5
52
55
  metaflow_extensions/outerbounds/profilers/__init__.py,sha256=wa_jhnCBr82TBxoS0e8b6_6sLyZX0fdHicuGJZNTqKw,29
53
56
  metaflow_extensions/outerbounds/profilers/gpu.py,sha256=3Er8uKQzfm_082uadg4yn_D4Y-iSCgzUfFmguYxZsz4,27485
54
57
  metaflow_extensions/outerbounds/toplevel/__init__.py,sha256=qWUJSv_r5hXJ7jV_On4nEasKIfUCm6_UjkjXWA_A1Ts,90
55
- metaflow_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.py,sha256=2CNRACc2EO-d_OtN7Ob-DlZAhD1ryYKhltB-4dVndAQ,1923
58
+ metaflow_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.py,sha256=oCRFfwoLODDju2-6JU2h74x6O-GCyO7PRRKTZsj-73k,2009
56
59
  metaflow_extensions/outerbounds/toplevel/plugins/azure/__init__.py,sha256=WUuhz2YQfI4fz7nIcipwwWq781eaoHEk7n4GAn1npDg,63
57
60
  metaflow_extensions/outerbounds/toplevel/plugins/gcp/__init__.py,sha256=BbZiaH3uILlEZ6ntBLKeNyqn3If8nIXZFq_Apd7Dhco,70
58
61
  metaflow_extensions/outerbounds/toplevel/plugins/kubernetes/__init__.py,sha256=5zG8gShSj8m7rgF4xgWBZFuY3GDP5n1T0ktjRpGJLHA,69
59
62
  metaflow_extensions/outerbounds/toplevel/plugins/ollama/__init__.py,sha256=GRSz2zwqkvlmFS6bcfYD_CX6CMko9DHQokMaH1iBshA,47
60
63
  metaflow_extensions/outerbounds/toplevel/plugins/snowflake/__init__.py,sha256=LptpH-ziXHrednMYUjIaosS1SXD3sOtF_9_eRqd8SJw,50
61
- ob_metaflow_extensions-1.1.146.dist-info/METADATA,sha256=Vtp-8yJaPeg8Hh33WXQYAerLoLlx5Ldya5M2U1lp5z0,520
62
- ob_metaflow_extensions-1.1.146.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
63
- ob_metaflow_extensions-1.1.146.dist-info/top_level.txt,sha256=NwG0ukwjygtanDETyp_BUdtYtqIA_lOjzFFh1TsnxvI,20
64
- ob_metaflow_extensions-1.1.146.dist-info/RECORD,,
64
+ ob_metaflow_extensions-1.1.147.dist-info/METADATA,sha256=KjFRs8JFmUIUzP-ghZUKxAGefc9i6tpf4GXDpJrSbSE,520
65
+ ob_metaflow_extensions-1.1.147.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
66
+ ob_metaflow_extensions-1.1.147.dist-info/top_level.txt,sha256=NwG0ukwjygtanDETyp_BUdtYtqIA_lOjzFFh1TsnxvI,20
67
+ ob_metaflow_extensions-1.1.147.dist-info/RECORD,,