ob-metaflow-stubs 6.0.3.117__py2.py3-none-any.whl → 6.0.3.118__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- metaflow-stubs/__init__.pyi +319 -2739
- metaflow-stubs/cards.pyi +19 -473
- metaflow-stubs/cli.pyi +17 -81
- metaflow-stubs/client/__init__.pyi +19 -1113
- metaflow-stubs/client/core.pyi +18 -158
- metaflow-stubs/client/filecache.pyi +8 -12
- metaflow-stubs/clone_util.pyi +6 -26
- metaflow-stubs/events.pyi +6 -5
- metaflow-stubs/exception.pyi +8 -6
- metaflow-stubs/flowspec.pyi +22 -106
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +16 -564
- metaflow-stubs/info_file.pyi +6 -5
- metaflow-stubs/metadata_provider/__init__.pyi +16 -0
- metaflow-stubs/metadata_provider/heartbeat.pyi +34 -0
- metaflow-stubs/{metadata → metadata_provider}/metadata.pyi +10 -22
- metaflow-stubs/metadata_provider/util.pyi +19 -0
- metaflow-stubs/metaflow_config.pyi +8 -13
- metaflow-stubs/metaflow_current.pyi +134 -133
- metaflow-stubs/mf_extensions/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +129 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +26 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +156 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +25 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +111 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +188 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +30 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +28 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +19 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +115 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +40 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +71 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +56 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +67 -0
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +49 -0
- metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +130 -0
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +42 -0
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +6 -0
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +17 -0
- metaflow-stubs/mflog/__init__.pyi +6 -0
- metaflow-stubs/mflog/mflog.pyi +52 -5
- metaflow-stubs/multicore_utils.pyi +6 -5
- metaflow-stubs/parameters.pyi +13 -23
- metaflow-stubs/plugins/__init__.pyi +52 -165
- metaflow-stubs/plugins/airflow/__init__.pyi +9 -5
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +7 -6
- metaflow-stubs/plugins/airflow/exception.pyi +7 -11
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +10 -97
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +9 -30
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +9 -40
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +9 -40
- metaflow-stubs/plugins/argo/__init__.pyi +12 -5
- metaflow-stubs/plugins/argo/argo_client.pyi +8 -26
- metaflow-stubs/plugins/argo/argo_events.pyi +7 -11
- metaflow-stubs/plugins/argo/argo_workflows.pyi +18 -130
- metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +22 -460
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +12 -404
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +63 -448
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +165 -0
- metaflow-stubs/plugins/aws/__init__.pyi +11 -5
- metaflow-stubs/plugins/aws/aws_client.pyi +6 -5
- metaflow-stubs/plugins/aws/aws_utils.pyi +6 -11
- metaflow-stubs/plugins/aws/batch/__init__.pyi +9 -5
- metaflow-stubs/plugins/aws/batch/batch.pyi +10 -55
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +7 -11
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +15 -140
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +7 -5
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +10 -21
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +9 -5
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +6 -5
- metaflow-stubs/plugins/aws/step_functions/production_token.pyi +6 -5
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +7 -5
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +11 -65
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +6 -5
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +52 -292
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +127 -0
- metaflow-stubs/plugins/azure/__init__.pyi +12 -7
- metaflow-stubs/plugins/azure/azure_credential.pyi +6 -5
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +7 -11
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +11 -24
- metaflow-stubs/plugins/azure/azure_utils.pyi +11 -29
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +8 -23
- metaflow-stubs/plugins/azure/includefile_support.pyi +7 -17
- metaflow-stubs/plugins/cards/__init__.pyi +15 -5
- metaflow-stubs/plugins/cards/card_cli.pyi +22 -491
- metaflow-stubs/plugins/cards/card_client.pyi +13 -75
- metaflow-stubs/plugins/cards/card_creator.pyi +7 -10
- metaflow-stubs/plugins/cards/card_datastore.pyi +10 -18
- metaflow-stubs/plugins/cards/card_decorator.pyi +10 -126
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +13 -81
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +13 -96
- metaflow-stubs/plugins/cards/card_modules/card.pyi +6 -5
- metaflow-stubs/plugins/cards/card_modules/components.pyi +24 -107
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +6 -5
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +6 -12
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +11 -88
- metaflow-stubs/plugins/cards/card_resolver.pyi +6 -49
- metaflow-stubs/plugins/cards/component_serializer.pyi +13 -63
- metaflow-stubs/plugins/cards/exception.pyi +7 -11
- metaflow-stubs/plugins/catch_decorator.pyi +10 -30
- metaflow-stubs/plugins/datatools/__init__.pyi +13 -392
- metaflow-stubs/plugins/datatools/local.pyi +7 -11
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +19 -653
- metaflow-stubs/plugins/datatools/s3/s3.pyi +16 -264
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +7 -10
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +6 -11
- metaflow-stubs/plugins/debug_logger.pyi +7 -5
- metaflow-stubs/plugins/debug_monitor.pyi +7 -5
- metaflow-stubs/plugins/environment_decorator.pyi +7 -5
- metaflow-stubs/plugins/events_decorator.pyi +8 -14
- metaflow-stubs/plugins/frameworks/__init__.pyi +7 -5
- metaflow-stubs/plugins/frameworks/pytorch.pyi +8 -45
- metaflow-stubs/plugins/gcp/__init__.pyi +11 -7
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +11 -24
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +7 -11
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +6 -5
- metaflow-stubs/plugins/gcp/gs_utils.pyi +8 -20
- metaflow-stubs/plugins/gcp/includefile_support.pyi +7 -17
- metaflow-stubs/plugins/kubernetes/__init__.pyi +12 -5
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +6 -10
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +10 -38
- metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +16 -155
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +7 -11
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +19 -142
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +7 -11
- metaflow-stubs/plugins/logs_cli.pyi +10 -9
- metaflow-stubs/plugins/package_cli.pyi +7 -5
- metaflow-stubs/plugins/parallel_decorator.pyi +11 -59
- metaflow-stubs/plugins/perimeters.pyi +6 -11
- metaflow-stubs/plugins/project_decorator.pyi +8 -14
- metaflow-stubs/plugins/pypi/__init__.pyi +12 -11
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +8 -27
- metaflow-stubs/plugins/pypi/conda_environment.pyi +14 -20
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +7 -5
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +7 -39
- metaflow-stubs/plugins/pypi/utils.pyi +7 -11
- metaflow-stubs/plugins/resources_decorator.pyi +7 -5
- metaflow-stubs/plugins/retry_decorator.pyi +7 -11
- metaflow-stubs/plugins/secrets/__init__.pyi +9 -5
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +8 -13
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +7 -11
- metaflow-stubs/plugins/storage_executor.pyi +6 -11
- metaflow-stubs/plugins/tag_cli.pyi +14 -396
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +8 -33
- metaflow-stubs/plugins/timeout_decorator.pyi +8 -12
- metaflow-stubs/procpoll.pyi +7 -5
- metaflow-stubs/profilers/__init__.pyi +7 -11
- metaflow-stubs/pylint_wrapper.pyi +7 -11
- metaflow-stubs/runner/__init__.pyi +13 -5
- metaflow-stubs/runner/deployer.pyi +99 -223
- metaflow-stubs/runner/deployer_impl.pyi +87 -0
- metaflow-stubs/runner/metaflow_runner.pyi +24 -508
- metaflow-stubs/runner/nbdeploy.pyi +16 -60
- metaflow-stubs/runner/nbrun.pyi +11 -148
- metaflow-stubs/runner/subprocess_manager.pyi +9 -10
- metaflow-stubs/runner/utils.pyi +44 -9
- metaflow-stubs/system/__init__.pyi +9 -107
- metaflow-stubs/system/system_logger.pyi +6 -15
- metaflow-stubs/system/system_monitor.pyi +6 -16
- metaflow-stubs/tagging_util.pyi +6 -10
- metaflow-stubs/tuple_util.pyi +6 -5
- {ob_metaflow_stubs-6.0.3.117.dist-info → ob_metaflow_stubs-6.0.3.118.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.3.118.dist-info/RECORD +174 -0
- metaflow-stubs/metadata/util.pyi +0 -18
- ob_metaflow_stubs-6.0.3.117.dist-info/RECORD +0 -140
- {ob_metaflow_stubs-6.0.3.117.dist-info → ob_metaflow_stubs-6.0.3.118.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.3.117.dist-info → ob_metaflow_stubs-6.0.3.118.dist-info}/top_level.txt +0 -0
@@ -1,31 +1,19 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# MF version: 2.12.
|
4
|
-
# Generated on 2024-11-
|
5
|
-
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.851501 #
|
5
|
+
######################################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
|
+
import metaflow
|
9
10
|
import typing
|
10
11
|
if typing.TYPE_CHECKING:
|
11
|
-
import metaflow.
|
12
|
-
import metaflow.exception
|
12
|
+
import metaflow.metadata_provider.metadata
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
class MetaflowTaggingError(metaflow.exception.MetaflowException, metaclass=type):
|
18
|
-
...
|
19
|
-
|
20
|
-
def validate_tag(tag):
|
21
|
-
"""
|
22
|
-
- Tag must be either of bytes-type or unicode-type.
|
23
|
-
- If tag is of bytes-type, it must be UTF-8 decodable
|
24
|
-
- If tag is of unicode-type, it must be UTF-8 encodable
|
25
|
-
- Tag may not be empty string.
|
26
|
-
- Tag cannot be too long (500 chars)
|
27
|
-
"""
|
28
|
-
...
|
14
|
+
from ..exception import MetaflowInternalError as MetaflowInternalError
|
15
|
+
from ..exception import MetaflowTaggingError as MetaflowTaggingError
|
16
|
+
from ..tagging_util import validate_tag as validate_tag
|
29
17
|
|
30
18
|
class DataArtifact(tuple, metaclass=type):
|
31
19
|
"""
|
@@ -0,0 +1,19 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.851730 #
|
5
|
+
######################################################################################################
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
def copy_tree(src, dst, update = False):
|
12
|
+
...
|
13
|
+
|
14
|
+
def sync_local_metadata_to_datastore(metadata_local_dir, task_ds):
|
15
|
+
...
|
16
|
+
|
17
|
+
def sync_local_metadata_from_datastore(metadata_local_dir, task_ds):
|
18
|
+
...
|
19
|
+
|
@@ -1,18 +1,13 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# MF version: 2.12.
|
4
|
-
# Generated on 2024-11-
|
5
|
-
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.832289 #
|
5
|
+
######################################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
9
|
|
10
|
-
|
11
|
-
def __init__(self, msg = "", lineno = None):
|
12
|
-
...
|
13
|
-
def __str__(self):
|
14
|
-
...
|
15
|
-
...
|
10
|
+
from .exception import MetaflowException as MetaflowException
|
16
11
|
|
17
12
|
DATASTORE_LOCAL_DIR: str
|
18
13
|
|
@@ -40,6 +35,8 @@ DEFAULT_SECRETS_BACKEND_TYPE: None
|
|
40
35
|
|
41
36
|
DEFAULT_SECRETS_ROLE: None
|
42
37
|
|
38
|
+
DEFAULT_FROM_DEPLOYMENT_IMPL: str
|
39
|
+
|
43
40
|
USER: None
|
44
41
|
|
45
42
|
DATASTORE_SYSROOT_LOCAL: None
|
@@ -240,8 +237,6 @@ AIRFLOW_KUBERNETES_KUBECONFIG_FILE: None
|
|
240
237
|
|
241
238
|
AIRFLOW_KUBERNETES_KUBECONFIG_CONTEXT: None
|
242
239
|
|
243
|
-
FROM_DEPLOYMENT_IMPL: str
|
244
|
-
|
245
240
|
CONDA_PACKAGE_S3ROOT: None
|
246
241
|
|
247
242
|
CONDA_PACKAGE_AZUREROOT: None
|
@@ -1,21 +1,22 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# MF version: 2.12.
|
4
|
-
# Generated on 2024-11-
|
5
|
-
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.934305 #
|
5
|
+
######################################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
9
|
import typing
|
10
10
|
if typing.TYPE_CHECKING:
|
11
|
-
import
|
12
|
-
import
|
13
|
-
import metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.modeling_utils.core
|
11
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.hf_hub.decorator
|
12
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.modeling_utils.core
|
14
13
|
import metaflow.plugins.cards.component_serializer
|
15
|
-
import
|
14
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.checkpoints.decorator
|
16
15
|
import metaflow.events
|
17
|
-
import metaflow.metaflow_current
|
18
16
|
import metaflow
|
17
|
+
import typing
|
18
|
+
import metaflow.metaflow_current
|
19
|
+
|
19
20
|
|
20
21
|
TYPE_CHECKING: bool
|
21
22
|
|
@@ -224,10 +225,108 @@ class Current(object, metaclass=type):
|
|
224
225
|
"""
|
225
226
|
...
|
226
227
|
@property
|
227
|
-
def graph(
|
228
|
+
def graph(self):
|
229
|
+
...
|
230
|
+
@property
|
231
|
+
def huggingface_hub(self) -> "metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.hf_hub.decorator.HuggingfaceRegistry":
|
232
|
+
"""
|
233
|
+
(only in the presence of the @huggingface_hub decorator)
|
234
|
+
|
235
|
+
The `@huggingface_hub` injects a `huggingface_hub` object into the `current` object. This object provides syntactic sugar
|
236
|
+
over [huggingface_hub](https://github.com/huggingface/huggingface_hub)'s
|
237
|
+
[snapshot_download](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/file_download#huggingface_hub.snapshot_download) function.
|
238
|
+
The `current.huggingface_hub.snapshot_download` function downloads objects from huggingface hub and saves them to the Metaflow's datastore under the
|
239
|
+
`<repo_type>/<repo_id>` name. The `repo_type` is by default `model` and can be overriden by passing the `repo_type` parameter to the `snapshot_download` function.
|
240
|
+
|
241
|
+
|
242
|
+
Usage:
|
243
|
+
------
|
244
|
+
|
245
|
+
**Usage: creating references of models from huggingface that may be loaded in downstream steps**
|
246
|
+
```python
|
247
|
+
@huggingface_hub
|
248
|
+
@step
|
249
|
+
def pull_model_from_huggingface(self):
|
250
|
+
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
251
|
+
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
252
|
+
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
253
|
+
# value of the function is a reference to the model in the backend storage.
|
254
|
+
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
255
|
+
|
256
|
+
self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
|
257
|
+
self.llama_model = current.huggingface_hub.snapshot_download(
|
258
|
+
repo_id=self.model_id,
|
259
|
+
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
260
|
+
)
|
261
|
+
self.next(self.train)
|
262
|
+
```
|
263
|
+
|
264
|
+
**Usage: loading models directly from huggingface hub or from cache (from metaflow's datastore)**
|
265
|
+
```python
|
266
|
+
@huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
|
267
|
+
@step
|
268
|
+
def pull_model_from_huggingface(self):
|
269
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
270
|
+
```
|
271
|
+
|
272
|
+
```python
|
273
|
+
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora, "/my-lora-directory")])
|
274
|
+
@step
|
275
|
+
def finetune_model(self):
|
276
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
277
|
+
# path_to_model will be /my-directory
|
278
|
+
```
|
279
|
+
|
280
|
+
```python
|
281
|
+
# Takes all the arguments passed to `snapshot_download`
|
282
|
+
# except for `local_dir`
|
283
|
+
@huggingface_hub(load=[
|
284
|
+
{
|
285
|
+
"repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
|
286
|
+
},
|
287
|
+
{
|
288
|
+
"repo_id": "myorg/mistral-lora",
|
289
|
+
"repo_type": "model",
|
290
|
+
},
|
291
|
+
])
|
292
|
+
@step
|
293
|
+
def finetune_model(self):
|
294
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
295
|
+
# path_to_model will be /my-directory
|
296
|
+
```
|
297
|
+
"""
|
298
|
+
...
|
299
|
+
@property
|
300
|
+
def parallel(self) -> "metaflow.metaflow_current.Parallel":
|
301
|
+
"""
|
302
|
+
(only in the presence of the @parallel decorator)
|
303
|
+
|
304
|
+
Returns a namedtuple with relevant information about the parallel task.
|
305
|
+
|
306
|
+
Returns
|
307
|
+
-------
|
308
|
+
Parallel
|
309
|
+
`namedtuple` with the following fields:
|
310
|
+
- main_ip (`str`)
|
311
|
+
The IP address of the control task.
|
312
|
+
- num_nodes (`int`)
|
313
|
+
The total number of tasks created by @parallel
|
314
|
+
- node_index (`int`)
|
315
|
+
The index of the current task in all the @parallel tasks.
|
316
|
+
- control_task_id (`Optional[str]`)
|
317
|
+
The task ID of the control task. Available to all tasks.
|
318
|
+
"""
|
228
319
|
...
|
229
320
|
@property
|
230
|
-
def
|
321
|
+
def is_parallel(self) -> bool:
|
322
|
+
"""
|
323
|
+
(only in the presence of the @parallel decorator)
|
324
|
+
|
325
|
+
True if the current step is a @parallel step.
|
326
|
+
"""
|
327
|
+
...
|
328
|
+
@property
|
329
|
+
def model(self) -> "metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.modeling_utils.core.ModelSerializer":
|
231
330
|
"""
|
232
331
|
(only in the presence of the @model decorator)
|
233
332
|
|
@@ -288,54 +387,7 @@ class Current(object, metaclass=type):
|
|
288
387
|
"""
|
289
388
|
...
|
290
389
|
@property
|
291
|
-
def
|
292
|
-
"""
|
293
|
-
(only in the presence of the @card decorator)
|
294
|
-
|
295
|
-
The `@card` decorator makes the cards available through the `current.card`
|
296
|
-
object. If multiple `@card` decorators are present, you can add an `ID` to
|
297
|
-
distinguish between them using `@card(id=ID)` as the decorator. You will then
|
298
|
-
be able to access that specific card using `current.card[ID].
|
299
|
-
|
300
|
-
Methods available are `append` and `extend`
|
301
|
-
|
302
|
-
Returns
|
303
|
-
-------
|
304
|
-
CardComponentCollector
|
305
|
-
The or one of the cards attached to this step.
|
306
|
-
"""
|
307
|
-
...
|
308
|
-
@property
|
309
|
-
def parallel(self) -> "metaflow.metaflow_current.Parallel":
|
310
|
-
"""
|
311
|
-
(only in the presence of the @parallel decorator)
|
312
|
-
|
313
|
-
Returns a namedtuple with relevant information about the parallel task.
|
314
|
-
|
315
|
-
Returns
|
316
|
-
-------
|
317
|
-
Parallel
|
318
|
-
`namedtuple` with the following fields:
|
319
|
-
- main_ip (`str`)
|
320
|
-
The IP address of the control task.
|
321
|
-
- num_nodes (`int`)
|
322
|
-
The total number of tasks created by @parallel
|
323
|
-
- node_index (`int`)
|
324
|
-
The index of the current task in all the @parallel tasks.
|
325
|
-
- control_task_id (`Optional[str]`)
|
326
|
-
The task ID of the control task. Available to all tasks.
|
327
|
-
"""
|
328
|
-
...
|
329
|
-
@property
|
330
|
-
def is_parallel(self) -> bool:
|
331
|
-
"""
|
332
|
-
(only in the presence of the @parallel decorator)
|
333
|
-
|
334
|
-
True if the current step is a @parallel step.
|
335
|
-
"""
|
336
|
-
...
|
337
|
-
@property
|
338
|
-
def checkpoint(self) -> "metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.checkpoints.decorator.CurrentCheckpointer":
|
390
|
+
def checkpoint(self) -> "metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.checkpoints.decorator.CurrentCheckpointer":
|
339
391
|
"""
|
340
392
|
(only in the presence of the @checkpoint decorator)
|
341
393
|
|
@@ -396,85 +448,21 @@ class Current(object, metaclass=type):
|
|
396
448
|
"""
|
397
449
|
...
|
398
450
|
@property
|
399
|
-
def
|
451
|
+
def card(self) -> "metaflow.plugins.cards.component_serializer.CardComponentCollector":
|
400
452
|
"""
|
401
|
-
(only in the presence of the @
|
402
|
-
|
403
|
-
The `@huggingface_hub` injects a `huggingface_hub` object into the `current` object. This object provides syntactic sugar
|
404
|
-
over [huggingface_hub](https://github.com/huggingface/huggingface_hub)'s
|
405
|
-
[snapshot_download](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/file_download#huggingface_hub.snapshot_download) function.
|
406
|
-
The `current.huggingface_hub.snapshot_download` function downloads objects from huggingface hub and saves them to the Metaflow's datastore under the
|
407
|
-
`<repo_type>/<repo_id>` name. The `repo_type` is by default `model` and can be overriden by passing the `repo_type` parameter to the `snapshot_download` function.
|
408
|
-
|
409
|
-
|
410
|
-
Usage:
|
411
|
-
------
|
412
|
-
|
413
|
-
**Usage: creating references of models from huggingface that may be loaded in downstream steps**
|
414
|
-
```python
|
415
|
-
@huggingface_hub
|
416
|
-
@step
|
417
|
-
def pull_model_from_huggingface(self):
|
418
|
-
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
419
|
-
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
420
|
-
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
421
|
-
# value of the function is a reference to the model in the backend storage.
|
422
|
-
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
423
|
-
|
424
|
-
self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
|
425
|
-
self.llama_model = current.huggingface_hub.snapshot_download(
|
426
|
-
repo_id=self.model_id,
|
427
|
-
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
428
|
-
)
|
429
|
-
self.next(self.train)
|
430
|
-
```
|
431
|
-
|
432
|
-
**Usage: loading models directly from huggingface hub or from cache (from metaflow's datastore)**
|
433
|
-
```python
|
434
|
-
@huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
|
435
|
-
@step
|
436
|
-
def pull_model_from_huggingface(self):
|
437
|
-
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
438
|
-
```
|
439
|
-
|
440
|
-
```python
|
441
|
-
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora, "/my-lora-directory")])
|
442
|
-
@step
|
443
|
-
def finetune_model(self):
|
444
|
-
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
445
|
-
# path_to_model will be /my-directory
|
446
|
-
```
|
453
|
+
(only in the presence of the @card decorator)
|
447
454
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
{
|
453
|
-
"repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
|
454
|
-
},
|
455
|
-
{
|
456
|
-
"repo_id": "myorg/mistral-lora",
|
457
|
-
"repo_type": "model",
|
458
|
-
},
|
459
|
-
])
|
460
|
-
@step
|
461
|
-
def finetune_model(self):
|
462
|
-
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
463
|
-
# path_to_model will be /my-directory
|
464
|
-
```
|
465
|
-
"""
|
466
|
-
...
|
467
|
-
@property
|
468
|
-
def trigger(self) -> "metaflow.events.Trigger":
|
469
|
-
"""
|
470
|
-
(only in the presence of the @trigger_on_finish, or @trigger decorators)
|
455
|
+
The `@card` decorator makes the cards available through the `current.card`
|
456
|
+
object. If multiple `@card` decorators are present, you can add an `ID` to
|
457
|
+
distinguish between them using `@card(id=ID)` as the decorator. You will then
|
458
|
+
be able to access that specific card using `current.card[ID].
|
471
459
|
|
472
|
-
|
460
|
+
Methods available are `append` and `extend`
|
473
461
|
|
474
462
|
Returns
|
475
463
|
-------
|
476
|
-
|
477
|
-
|
464
|
+
CardComponentCollector
|
465
|
+
The or one of the cards attached to this step.
|
478
466
|
"""
|
479
467
|
...
|
480
468
|
@property
|
@@ -544,6 +532,19 @@ class Current(object, metaclass=type):
|
|
544
532
|
True if the flow is deployed with `--production`.
|
545
533
|
"""
|
546
534
|
...
|
535
|
+
@property
|
536
|
+
def trigger(self) -> "metaflow.events.Trigger":
|
537
|
+
"""
|
538
|
+
(only in the presence of the @trigger_on_finish, or @trigger decorators)
|
539
|
+
|
540
|
+
Returns `Trigger` if the current run is triggered by an event
|
541
|
+
|
542
|
+
Returns
|
543
|
+
-------
|
544
|
+
Trigger
|
545
|
+
`Trigger` if triggered by an event
|
546
|
+
"""
|
547
|
+
...
|
547
548
|
...
|
548
549
|
|
549
550
|
current: Current
|
@@ -0,0 +1,6 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.837688 #
|
5
|
+
######################################################################################################
|
6
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.846039 #
|
5
|
+
######################################################################################################
|
6
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.846103 #
|
5
|
+
######################################################################################################
|
6
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.846162 #
|
5
|
+
######################################################################################################
|
6
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.846219 #
|
5
|
+
######################################################################################################
|
6
|
+
|
@@ -0,0 +1,129 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.911726 #
|
5
|
+
######################################################################################################
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
import metaflow
|
10
|
+
import typing
|
11
|
+
if typing.TYPE_CHECKING:
|
12
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures
|
13
|
+
import metaflow.datastore.datastore_storage
|
14
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastore.core
|
15
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.checkpoints.checkpoint_storage
|
16
|
+
|
17
|
+
from ..exceptions import KeyNotCompatibleWithObjectException as KeyNotCompatibleWithObjectException
|
18
|
+
from ..utils.identity_utils import pathspec_hash as pathspec_hash
|
19
|
+
from ..utils.general import replace_start_and_end_slash as replace_start_and_end_slash
|
20
|
+
from ..datastore.core import allow_safe as allow_safe
|
21
|
+
from ..datastore.core import DatastoreInterface as DatastoreInterface
|
22
|
+
from ..datastore.core import ObjectStorage as ObjectStorage
|
23
|
+
from ..datastore.core import STORAGE_FORMATS as STORAGE_FORMATS
|
24
|
+
from ..datastore.exceptions import DatastoreReadInitException as DatastoreReadInitException
|
25
|
+
from ..datastore.exceptions import DatastoreWriteInitException as DatastoreWriteInitException
|
26
|
+
from ..datastore.exceptions import DatastoreNotReadyException as DatastoreNotReadyException
|
27
|
+
from ..datastructures import CheckpointArtifact as CheckpointArtifact
|
28
|
+
from ..datastore.utils import safe_serialize as safe_serialize
|
29
|
+
|
30
|
+
DEFAULT_NAME: str
|
31
|
+
|
32
|
+
CHECKPOINTS_STORAGE_PREFIX: str
|
33
|
+
|
34
|
+
DEFAULT_STORAGE_FORMAT: str
|
35
|
+
|
36
|
+
ARTIFACT_STORE_NAME: str
|
37
|
+
|
38
|
+
METADATA_STORE_NAME: str
|
39
|
+
|
40
|
+
ARTIFACT_METADATA_STORE_NAME: str
|
41
|
+
|
42
|
+
class CheckpointsPathComponents(tuple, metaclass=type):
|
43
|
+
"""
|
44
|
+
CheckpointsPathComponents(flow_name, step_name, scope, task_identifier, pathspec_hash, attempt, name, version_id, is_metadata, key_name, root_prefix)
|
45
|
+
"""
|
46
|
+
@staticmethod
|
47
|
+
def __new__(_cls, flow_name, step_name, scope, task_identifier, pathspec_hash, attempt, name, version_id, is_metadata, key_name, root_prefix):
|
48
|
+
"""
|
49
|
+
Create new instance of CheckpointsPathComponents(flow_name, step_name, scope, task_identifier, pathspec_hash, attempt, name, version_id, is_metadata, key_name, root_prefix)
|
50
|
+
"""
|
51
|
+
...
|
52
|
+
def __repr__(self):
|
53
|
+
"""
|
54
|
+
Return a nicely formatted representation string
|
55
|
+
"""
|
56
|
+
...
|
57
|
+
def __getnewargs__(self):
|
58
|
+
"""
|
59
|
+
Return self as a plain tuple. Used by copy and pickle.
|
60
|
+
"""
|
61
|
+
...
|
62
|
+
...
|
63
|
+
|
64
|
+
def decompose_key_artifact_metadata_store(key) -> CheckpointsPathComponents:
|
65
|
+
...
|
66
|
+
|
67
|
+
def decompose_key_artifact_store(key) -> CheckpointsPathComponents:
|
68
|
+
"""
|
69
|
+
Convert Key into Path Components.
|
70
|
+
PATH COMPONENTS: mf.checkpoints/artifacts/<flow_name>/<step_name>/<scope>/<task_identifier>/<pathspec_hash>.<attempt>.<name>.<version_id>
|
71
|
+
"""
|
72
|
+
...
|
73
|
+
|
74
|
+
def decompose_key_metadata_store(key) -> CheckpointsPathComponents:
|
75
|
+
"""
|
76
|
+
Convert Key into Path Components.
|
77
|
+
PATH COMPONENTS: mf.checkpoints/artifacts/<flow_name>/<step_name>/<scope>/<task_identifier>/<pathspec_hash>.<attempt>.<name>.<version_id>
|
78
|
+
"""
|
79
|
+
...
|
80
|
+
|
81
|
+
class CheckpointDatastore(metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastore.core.DatastoreInterface, metaclass=type):
|
82
|
+
"""
|
83
|
+
Consisits of 3 main components:
|
84
|
+
- `artifact_store`: This is where the checkpoint artifacts are stored.
|
85
|
+
- This key to the checkpoint in this store becomes the "key for the checkpoint"
|
86
|
+
- `metadata_store`: This is where the metadata of the checkpoint is stored it based on the currently executing task (path structure resembles that of a metaflow pathspec).
|
87
|
+
- This store helps retrieve information about all the checkpoints stored for a task during the execution.
|
88
|
+
- `artifact_metadatastore`: This is similar to the metadata store but holds a pathstructure similar to the artifact store.
|
89
|
+
- this store helps reverse lookup the Checkpoint metadata object from the checkpoint key.
|
90
|
+
"""
|
91
|
+
@property
|
92
|
+
def metadata_ready(self):
|
93
|
+
...
|
94
|
+
@property
|
95
|
+
def artifact_ready(self):
|
96
|
+
...
|
97
|
+
def set_root_prefix(self, root_prefix):
|
98
|
+
...
|
99
|
+
@classmethod
|
100
|
+
def init_read_store(cls, storage_backend: metaflow.datastore.datastore_storage.DataStoreStorage, pathspec = None, checkpoint_key = None):
|
101
|
+
"""
|
102
|
+
This will initialize the datastore for reading.
|
103
|
+
|
104
|
+
- If there is only the pathspec that's provided then it can mean the user is doing a list operations
|
105
|
+
- if only the checkpoint_key is provided then it can mean the user is trying to load a specific checkpoint
|
106
|
+
"""
|
107
|
+
...
|
108
|
+
def create_key_name(self, *args):
|
109
|
+
...
|
110
|
+
@classmethod
|
111
|
+
def init_write_store(cls, storage_backend: metaflow.datastore.datastore_storage.DataStoreStorage, pathspec, scope, task_identifier):
|
112
|
+
...
|
113
|
+
def save(self, local_path: str, attempt, version_id, name = 'mfchckpt', metadata = {}, set_latest = True, storage_format = 'files') -> metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures.CheckpointArtifact:
|
114
|
+
...
|
115
|
+
def latest(*args, **kwargs):
|
116
|
+
...
|
117
|
+
def load(self, local_path, version_id, attempt, name, storage_format = 'files'):
|
118
|
+
...
|
119
|
+
def load_metadata(self, attempt, version_id, name = 'mfchckpt') -> dict:
|
120
|
+
...
|
121
|
+
def list(self, name = None, attempt = None, within_task = True):
|
122
|
+
...
|
123
|
+
@classmethod
|
124
|
+
def decompose_key(cls, key) -> CheckpointsPathComponents:
|
125
|
+
...
|
126
|
+
def __init__(self, artifact_store: metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastore.core.ObjectStorage, metadata_store: metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastore.core.ObjectStorage, artifact_metadatastore: metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastore.core.ObjectStorage):
|
127
|
+
...
|
128
|
+
...
|
129
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
######################################################################################################
|
2
|
+
# Auto-generated Metaflow stub file #
|
3
|
+
# MF version: 2.12.30.1+obcheckpoint(0.1.4);ob(v1) #
|
4
|
+
# Generated on 2024-11-13T23:34:52.869613 #
|
5
|
+
######################################################################################################
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
import typing
|
10
|
+
if typing.TYPE_CHECKING:
|
11
|
+
import metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures
|
12
|
+
|
13
|
+
from .core import Checkpointer as Checkpointer
|
14
|
+
from .core import WriteResolver as WriteResolver
|
15
|
+
from .core import ReadResolver as ReadResolver
|
16
|
+
from ..datastructures import CheckpointArtifact as CheckpointArtifact
|
17
|
+
|
18
|
+
TYPE_CHECKING: bool
|
19
|
+
|
20
|
+
CHECKPOINT_UID_ENV_VAR_NAME: str
|
21
|
+
|
22
|
+
DEFAULT_NAME: str
|
23
|
+
|
24
|
+
def load_checkpoint(checkpoint: typing.Union[metaflow.mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures.CheckpointArtifact, dict, str], local_path: str):
|
25
|
+
...
|
26
|
+
|