ob-metaflow-stubs 6.0.3.185__py2.py3-none-any.whl → 6.0.3.186__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.
- metaflow-stubs/__init__.pyi +955 -738
- metaflow-stubs/cards.pyi +2 -2
- metaflow-stubs/cli.pyi +2 -2
- metaflow-stubs/cli_components/__init__.pyi +2 -2
- metaflow-stubs/cli_components/utils.pyi +2 -2
- metaflow-stubs/client/__init__.pyi +2 -2
- metaflow-stubs/client/core.pyi +5 -5
- metaflow-stubs/client/filecache.pyi +3 -3
- metaflow-stubs/events.pyi +3 -3
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +4 -4
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +3 -3
- metaflow-stubs/info_file.pyi +2 -2
- metaflow-stubs/metadata_provider/__init__.pyi +2 -2
- metaflow-stubs/metadata_provider/heartbeat.pyi +2 -2
- metaflow-stubs/metadata_provider/metadata.pyi +2 -2
- metaflow-stubs/metadata_provider/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +2 -2
- metaflow-stubs/metaflow_current.pyi +37 -185
- metaflow-stubs/metaflow_git.pyi +2 -2
- metaflow-stubs/mf_extensions/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +50 -48
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +10 -14
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +86 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +78 -75
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +48 -13
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/assume_role_decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/ob_internal.pyi +2 -2
- metaflow-stubs/parameters.pyi +3 -3
- metaflow-stubs/plugins/__init__.pyi +10 -10
- metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
- metaflow-stubs/plugins/airflow/exception.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +3 -3
- metaflow-stubs/plugins/aws/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
- metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +3 -3
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
- metaflow-stubs/plugins/azure/__init__.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
- metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/cards/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_client.pyi +3 -3
- metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
- metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +2 -2
- metaflow-stubs/plugins/cards/exception.pyi +2 -2
- metaflow-stubs/plugins/catch_decorator.pyi +3 -3
- metaflow-stubs/plugins/datatools/__init__.pyi +2 -2
- metaflow-stubs/plugins/datatools/local.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3.pyi +3 -3
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
- metaflow-stubs/plugins/debug_logger.pyi +2 -2
- metaflow-stubs/plugins/debug_monitor.pyi +2 -2
- metaflow-stubs/plugins/environment_decorator.pyi +2 -2
- metaflow-stubs/plugins/events_decorator.pyi +2 -2
- metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
- metaflow-stubs/plugins/frameworks/pytorch.pyi +2 -2
- metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
- metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +2 -2
- metaflow-stubs/plugins/ollama/__init__.pyi +3 -3
- metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
- metaflow-stubs/plugins/perimeters.pyi +2 -2
- metaflow-stubs/plugins/project_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_environment.pyi +5 -5
- metaflow-stubs/plugins/pypi/parsers.pyi +2 -2
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
- metaflow-stubs/plugins/pypi/utils.pyi +2 -2
- metaflow-stubs/plugins/resources_decorator.pyi +2 -2
- metaflow-stubs/plugins/retry_decorator.pyi +2 -2
- metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
- metaflow-stubs/plugins/snowflake/__init__.pyi +2 -2
- metaflow-stubs/plugins/storage_executor.pyi +2 -2
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
- metaflow-stubs/plugins/timeout_decorator.pyi +3 -3
- metaflow-stubs/plugins/torchtune/__init__.pyi +2 -2
- metaflow-stubs/plugins/uv/__init__.pyi +2 -2
- metaflow-stubs/plugins/uv/uv_environment.pyi +2 -2
- metaflow-stubs/profilers/__init__.pyi +2 -2
- metaflow-stubs/pylint_wrapper.pyi +2 -2
- metaflow-stubs/runner/__init__.pyi +2 -2
- metaflow-stubs/runner/deployer.pyi +28 -28
- metaflow-stubs/runner/deployer_impl.pyi +2 -2
- metaflow-stubs/runner/metaflow_runner.pyi +3 -3
- metaflow-stubs/runner/nbdeploy.pyi +2 -2
- metaflow-stubs/runner/nbrun.pyi +2 -2
- metaflow-stubs/runner/subprocess_manager.pyi +2 -2
- metaflow-stubs/runner/utils.pyi +3 -3
- metaflow-stubs/system/__init__.pyi +2 -2
- metaflow-stubs/system/system_logger.pyi +2 -2
- metaflow-stubs/system/system_monitor.pyi +2 -2
- metaflow-stubs/tagging_util.pyi +2 -2
- metaflow-stubs/tuple_util.pyi +2 -2
- metaflow-stubs/user_configs/__init__.pyi +2 -2
- metaflow-stubs/user_configs/config_decorators.pyi +6 -6
- metaflow-stubs/user_configs/config_options.pyi +2 -2
- metaflow-stubs/user_configs/config_parameters.pyi +5 -5
- {ob_metaflow_stubs-6.0.3.185.dist-info → ob_metaflow_stubs-6.0.3.186.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.3.186.dist-info/RECORD +216 -0
- ob_metaflow_stubs-6.0.3.185.dist-info/RECORD +0 -216
- {ob_metaflow_stubs-6.0.3.185.dist-info → ob_metaflow_stubs-6.0.3.186.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.3.185.dist-info → ob_metaflow_stubs-6.0.3.186.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
######################################################################################################
|
2
2
|
# Auto-generated Metaflow stub file #
|
3
|
-
# MF version: 2.15.18.1+obcheckpoint(0.2.
|
4
|
-
# Generated on 2025-
|
3
|
+
# MF version: 2.15.18.1+obcheckpoint(0.2.4);ob(v1) #
|
4
|
+
# Generated on 2025-07-01T08:40:33.108391 #
|
5
5
|
######################################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
9
|
import typing
|
10
10
|
if typing.TYPE_CHECKING:
|
11
|
-
import datetime
|
12
11
|
import typing
|
12
|
+
import datetime
|
13
13
|
FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
|
14
14
|
StepFlag = typing.NewType("StepFlag", bool)
|
15
15
|
|
@@ -155,78 +155,6 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
155
155
|
"""
|
156
156
|
...
|
157
157
|
|
158
|
-
def nvct(*, gpu: int, gpu_type: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
159
|
-
"""
|
160
|
-
Specifies that this step should execute on DGX cloud.
|
161
|
-
|
162
|
-
|
163
|
-
Parameters
|
164
|
-
----------
|
165
|
-
gpu : int
|
166
|
-
Number of GPUs to use.
|
167
|
-
gpu_type : str
|
168
|
-
Type of Nvidia GPU to use.
|
169
|
-
"""
|
170
|
-
...
|
171
|
-
|
172
|
-
def app_deploy(*, app_port: int, app_name: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
173
|
-
"""
|
174
|
-
Specifies that this step is used to deploy an instance of the app.
|
175
|
-
Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
|
176
|
-
|
177
|
-
|
178
|
-
Parameters
|
179
|
-
----------
|
180
|
-
app_port : int
|
181
|
-
Number of GPUs to use.
|
182
|
-
app_name : str
|
183
|
-
Name of the app to deploy.
|
184
|
-
"""
|
185
|
-
...
|
186
|
-
|
187
|
-
def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
188
|
-
"""
|
189
|
-
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
190
|
-
|
191
|
-
User code call
|
192
|
-
--------------
|
193
|
-
@ollama(
|
194
|
-
models=[...],
|
195
|
-
...
|
196
|
-
)
|
197
|
-
|
198
|
-
Valid backend options
|
199
|
-
---------------------
|
200
|
-
- 'local': Run as a separate process on the local task machine.
|
201
|
-
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
202
|
-
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
203
|
-
|
204
|
-
Valid model options
|
205
|
-
-------------------
|
206
|
-
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
207
|
-
|
208
|
-
|
209
|
-
Parameters
|
210
|
-
----------
|
211
|
-
models: list[str]
|
212
|
-
List of Ollama containers running models in sidecars.
|
213
|
-
backend: str
|
214
|
-
Determines where and how to run the Ollama process.
|
215
|
-
force_pull: bool
|
216
|
-
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
217
|
-
cache_update_policy: str
|
218
|
-
Cache update policy: "auto", "force", or "never".
|
219
|
-
force_cache_update: bool
|
220
|
-
Simple override for "force" cache update policy.
|
221
|
-
debug: bool
|
222
|
-
Whether to turn on verbose debugging logs.
|
223
|
-
circuit_breaker_config: dict
|
224
|
-
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
225
|
-
timeout_config: dict
|
226
|
-
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
227
|
-
"""
|
228
|
-
...
|
229
|
-
|
230
158
|
@typing.overload
|
231
159
|
def pypi(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
232
160
|
"""
|
@@ -278,6 +206,138 @@ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
|
|
278
206
|
"""
|
279
207
|
...
|
280
208
|
|
209
|
+
@typing.overload
|
210
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
211
|
+
"""
|
212
|
+
Internal decorator to support Fast bakery
|
213
|
+
"""
|
214
|
+
...
|
215
|
+
|
216
|
+
@typing.overload
|
217
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
218
|
+
...
|
219
|
+
|
220
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
221
|
+
"""
|
222
|
+
Internal decorator to support Fast bakery
|
223
|
+
"""
|
224
|
+
...
|
225
|
+
|
226
|
+
def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.Union[typing.List[str], typing.List[typing.Tuple[typing.Dict, str]], typing.List[typing.Tuple[str, str]], typing.List[typing.Dict], None]) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
227
|
+
"""
|
228
|
+
Decorator that helps cache, version and store models/datasets from huggingface hub.
|
229
|
+
|
230
|
+
> Examples
|
231
|
+
|
232
|
+
**Usage: creating references of models from huggingface that may be loaded in downstream steps**
|
233
|
+
```python
|
234
|
+
@huggingface_hub
|
235
|
+
@step
|
236
|
+
def pull_model_from_huggingface(self):
|
237
|
+
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
238
|
+
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
239
|
+
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
240
|
+
# value of the function is a reference to the model in the backend storage.
|
241
|
+
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
242
|
+
|
243
|
+
self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
|
244
|
+
self.llama_model = current.huggingface_hub.snapshot_download(
|
245
|
+
repo_id=self.model_id,
|
246
|
+
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
247
|
+
)
|
248
|
+
self.next(self.train)
|
249
|
+
```
|
250
|
+
|
251
|
+
**Usage: loading models directly from huggingface hub or from cache (from metaflow's datastore)**
|
252
|
+
```python
|
253
|
+
@huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
|
254
|
+
@step
|
255
|
+
def pull_model_from_huggingface(self):
|
256
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
257
|
+
```
|
258
|
+
|
259
|
+
```python
|
260
|
+
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora, "/my-lora-directory")])
|
261
|
+
@step
|
262
|
+
def finetune_model(self):
|
263
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
264
|
+
# path_to_model will be /my-directory
|
265
|
+
```
|
266
|
+
|
267
|
+
```python
|
268
|
+
# Takes all the arguments passed to `snapshot_download`
|
269
|
+
# except for `local_dir`
|
270
|
+
@huggingface_hub(load=[
|
271
|
+
{
|
272
|
+
"repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
|
273
|
+
},
|
274
|
+
{
|
275
|
+
"repo_id": "myorg/mistral-lora",
|
276
|
+
"repo_type": "model",
|
277
|
+
},
|
278
|
+
])
|
279
|
+
@step
|
280
|
+
def finetune_model(self):
|
281
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
282
|
+
# path_to_model will be /my-directory
|
283
|
+
```
|
284
|
+
|
285
|
+
|
286
|
+
Parameters
|
287
|
+
----------
|
288
|
+
temp_dir_root : str, optional
|
289
|
+
The root directory that will hold the temporary directory where objects will be downloaded.
|
290
|
+
|
291
|
+
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
292
|
+
The list of repos (models/datasets) to load.
|
293
|
+
|
294
|
+
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
295
|
+
|
296
|
+
- If repo (model/dataset) is not found in the datastore:
|
297
|
+
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
298
|
+
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
299
|
+
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
300
|
+
|
301
|
+
- If repo is found in the datastore:
|
302
|
+
- Loads it directly from datastore to local path (can be temporary directory or specified path)
|
303
|
+
"""
|
304
|
+
...
|
305
|
+
|
306
|
+
@typing.overload
|
307
|
+
def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
308
|
+
"""
|
309
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
310
|
+
the execution of a step.
|
311
|
+
|
312
|
+
|
313
|
+
Parameters
|
314
|
+
----------
|
315
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
316
|
+
List of secret specs, defining how the secrets are to be retrieved
|
317
|
+
"""
|
318
|
+
...
|
319
|
+
|
320
|
+
@typing.overload
|
321
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
322
|
+
...
|
323
|
+
|
324
|
+
@typing.overload
|
325
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
326
|
+
...
|
327
|
+
|
328
|
+
def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
|
329
|
+
"""
|
330
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
331
|
+
the execution of a step.
|
332
|
+
|
333
|
+
|
334
|
+
Parameters
|
335
|
+
----------
|
336
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
337
|
+
List of secret specs, defining how the secrets are to be retrieved
|
338
|
+
"""
|
339
|
+
...
|
340
|
+
|
281
341
|
@typing.overload
|
282
342
|
def catch(*, var: typing.Optional[str] = None, print_exception: bool = True) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
283
343
|
"""
|
@@ -330,92 +390,90 @@ def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
330
390
|
...
|
331
391
|
|
332
392
|
@typing.overload
|
333
|
-
def
|
393
|
+
def timeout(*, seconds: int = 0, minutes: int = 0, hours: int = 0) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
334
394
|
"""
|
335
|
-
|
395
|
+
Specifies a timeout for your step.
|
336
396
|
|
397
|
+
This decorator is useful if this step may hang indefinitely.
|
337
398
|
|
399
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
400
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
401
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
338
402
|
|
339
|
-
|
340
|
-
|
341
|
-
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
342
|
-
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
343
|
-
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
344
|
-
- `current.checkpoint`
|
345
|
-
- `current.model`
|
346
|
-
- `current.huggingface_hub`
|
403
|
+
Note that all the values specified in parameters are added together so if you specify
|
404
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
347
405
|
|
348
|
-
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
349
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
350
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
351
406
|
|
352
|
-
|
353
|
-
|
407
|
+
Parameters
|
408
|
+
----------
|
409
|
+
seconds : int, default 0
|
410
|
+
Number of seconds to wait prior to timing out.
|
411
|
+
minutes : int, default 0
|
412
|
+
Number of minutes to wait prior to timing out.
|
413
|
+
hours : int, default 0
|
414
|
+
Number of hours to wait prior to timing out.
|
354
415
|
"""
|
355
416
|
...
|
356
417
|
|
357
418
|
@typing.overload
|
358
|
-
def
|
419
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
359
420
|
...
|
360
421
|
|
361
422
|
@typing.overload
|
362
|
-
def
|
423
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
363
424
|
...
|
364
425
|
|
365
|
-
def
|
426
|
+
def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, seconds: int = 0, minutes: int = 0, hours: int = 0):
|
366
427
|
"""
|
367
|
-
|
428
|
+
Specifies a timeout for your step.
|
368
429
|
|
430
|
+
This decorator is useful if this step may hang indefinitely.
|
369
431
|
|
432
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
433
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
434
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
370
435
|
|
371
|
-
|
372
|
-
|
373
|
-
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
374
|
-
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
375
|
-
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
376
|
-
- `current.checkpoint`
|
377
|
-
- `current.model`
|
378
|
-
- `current.huggingface_hub`
|
436
|
+
Note that all the values specified in parameters are added together so if you specify
|
437
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
379
438
|
|
380
|
-
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
381
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
382
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
383
439
|
|
384
|
-
|
385
|
-
|
440
|
+
Parameters
|
441
|
+
----------
|
442
|
+
seconds : int, default 0
|
443
|
+
Number of seconds to wait prior to timing out.
|
444
|
+
minutes : int, default 0
|
445
|
+
Number of minutes to wait prior to timing out.
|
446
|
+
hours : int, default 0
|
447
|
+
Number of hours to wait prior to timing out.
|
386
448
|
"""
|
387
449
|
...
|
388
450
|
|
389
|
-
|
390
|
-
def environment(*, vars: typing.Dict[str, str] = {}) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
451
|
+
def nvct(*, gpu: int, gpu_type: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
391
452
|
"""
|
392
|
-
Specifies
|
453
|
+
Specifies that this step should execute on DGX cloud.
|
393
454
|
|
394
455
|
|
395
456
|
Parameters
|
396
457
|
----------
|
397
|
-
|
398
|
-
|
458
|
+
gpu : int
|
459
|
+
Number of GPUs to use.
|
460
|
+
gpu_type : str
|
461
|
+
Type of Nvidia GPU to use.
|
399
462
|
"""
|
400
463
|
...
|
401
464
|
|
402
|
-
|
403
|
-
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
404
|
-
...
|
405
|
-
|
406
|
-
@typing.overload
|
407
|
-
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
408
|
-
...
|
409
|
-
|
410
|
-
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
465
|
+
def app_deploy(*, app_port: int, app_name: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
411
466
|
"""
|
412
|
-
Specifies
|
467
|
+
Specifies that this step is used to deploy an instance of the app.
|
468
|
+
Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
|
413
469
|
|
414
470
|
|
415
471
|
Parameters
|
416
472
|
----------
|
417
|
-
|
418
|
-
|
473
|
+
app_port : int
|
474
|
+
Number of GPUs to use.
|
475
|
+
app_name : str
|
476
|
+
Name of the app to deploy.
|
419
477
|
"""
|
420
478
|
...
|
421
479
|
|
@@ -435,11 +493,99 @@ def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[t
|
|
435
493
|
"""
|
436
494
|
...
|
437
495
|
|
438
|
-
|
439
|
-
def checkpoint(*, load_policy: str = 'fresh', temp_dir_root: str = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
496
|
+
def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
440
497
|
"""
|
441
|
-
|
442
|
-
|
498
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
499
|
+
|
500
|
+
User code call
|
501
|
+
--------------
|
502
|
+
@ollama(
|
503
|
+
models=[...],
|
504
|
+
...
|
505
|
+
)
|
506
|
+
|
507
|
+
Valid backend options
|
508
|
+
---------------------
|
509
|
+
- 'local': Run as a separate process on the local task machine.
|
510
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
511
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
512
|
+
|
513
|
+
Valid model options
|
514
|
+
-------------------
|
515
|
+
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
516
|
+
|
517
|
+
|
518
|
+
Parameters
|
519
|
+
----------
|
520
|
+
models: list[str]
|
521
|
+
List of Ollama containers running models in sidecars.
|
522
|
+
backend: str
|
523
|
+
Determines where and how to run the Ollama process.
|
524
|
+
force_pull: bool
|
525
|
+
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
526
|
+
cache_update_policy: str
|
527
|
+
Cache update policy: "auto", "force", or "never".
|
528
|
+
force_cache_update: bool
|
529
|
+
Simple override for "force" cache update policy.
|
530
|
+
debug: bool
|
531
|
+
Whether to turn on verbose debugging logs.
|
532
|
+
circuit_breaker_config: dict
|
533
|
+
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
534
|
+
timeout_config: dict
|
535
|
+
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
536
|
+
"""
|
537
|
+
...
|
538
|
+
|
539
|
+
@typing.overload
|
540
|
+
def checkpoint(*, load_policy: str = 'fresh', temp_dir_root: str = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
541
|
+
"""
|
542
|
+
Enables checkpointing for a step.
|
543
|
+
|
544
|
+
> Examples
|
545
|
+
|
546
|
+
- Saving Checkpoints
|
547
|
+
|
548
|
+
```python
|
549
|
+
@checkpoint
|
550
|
+
@step
|
551
|
+
def train(self):
|
552
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
553
|
+
for i in range(self.epochs):
|
554
|
+
# some training logic
|
555
|
+
loss = model.train(self.dataset)
|
556
|
+
if i % 10 == 0:
|
557
|
+
model.save(
|
558
|
+
current.checkpoint.directory,
|
559
|
+
)
|
560
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
561
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
562
|
+
self.latest_checkpoint = current.checkpoint.save(
|
563
|
+
name="epoch_checkpoint",
|
564
|
+
metadata={
|
565
|
+
"epoch": i,
|
566
|
+
"loss": loss,
|
567
|
+
}
|
568
|
+
)
|
569
|
+
```
|
570
|
+
|
571
|
+
- Using Loaded Checkpoints
|
572
|
+
|
573
|
+
```python
|
574
|
+
@retry(times=3)
|
575
|
+
@checkpoint
|
576
|
+
@step
|
577
|
+
def train(self):
|
578
|
+
# Assume that the task has restarted and the previous attempt of the task
|
579
|
+
# saved a checkpoint
|
580
|
+
checkpoint_path = None
|
581
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
582
|
+
print("Loaded checkpoint from the previous attempt")
|
583
|
+
checkpoint_path = current.checkpoint.directory
|
584
|
+
|
585
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
586
|
+
for i in range(self.epochs):
|
587
|
+
...
|
588
|
+
```
|
443
589
|
|
444
590
|
|
445
591
|
Parameters
|
@@ -472,6 +618,51 @@ def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None
|
|
472
618
|
"""
|
473
619
|
Enables checkpointing for a step.
|
474
620
|
|
621
|
+
> Examples
|
622
|
+
|
623
|
+
- Saving Checkpoints
|
624
|
+
|
625
|
+
```python
|
626
|
+
@checkpoint
|
627
|
+
@step
|
628
|
+
def train(self):
|
629
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
630
|
+
for i in range(self.epochs):
|
631
|
+
# some training logic
|
632
|
+
loss = model.train(self.dataset)
|
633
|
+
if i % 10 == 0:
|
634
|
+
model.save(
|
635
|
+
current.checkpoint.directory,
|
636
|
+
)
|
637
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
638
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
639
|
+
self.latest_checkpoint = current.checkpoint.save(
|
640
|
+
name="epoch_checkpoint",
|
641
|
+
metadata={
|
642
|
+
"epoch": i,
|
643
|
+
"loss": loss,
|
644
|
+
}
|
645
|
+
)
|
646
|
+
```
|
647
|
+
|
648
|
+
- Using Loaded Checkpoints
|
649
|
+
|
650
|
+
```python
|
651
|
+
@retry(times=3)
|
652
|
+
@checkpoint
|
653
|
+
@step
|
654
|
+
def train(self):
|
655
|
+
# Assume that the task has restarted and the previous attempt of the task
|
656
|
+
# saved a checkpoint
|
657
|
+
checkpoint_path = None
|
658
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
659
|
+
print("Loaded checkpoint from the previous attempt")
|
660
|
+
checkpoint_path = current.checkpoint.directory
|
661
|
+
|
662
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
663
|
+
for i in range(self.epochs):
|
664
|
+
...
|
665
|
+
```
|
475
666
|
|
476
667
|
|
477
668
|
Parameters
|
@@ -492,101 +683,6 @@ def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None
|
|
492
683
|
"""
|
493
684
|
...
|
494
685
|
|
495
|
-
@typing.overload
|
496
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
497
|
-
"""
|
498
|
-
Decorator prototype for all step decorators. This function gets specialized
|
499
|
-
and imported for all decorators types by _import_plugin_decorators().
|
500
|
-
"""
|
501
|
-
...
|
502
|
-
|
503
|
-
@typing.overload
|
504
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
505
|
-
...
|
506
|
-
|
507
|
-
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
508
|
-
"""
|
509
|
-
Decorator prototype for all step decorators. This function gets specialized
|
510
|
-
and imported for all decorators types by _import_plugin_decorators().
|
511
|
-
"""
|
512
|
-
...
|
513
|
-
|
514
|
-
@typing.overload
|
515
|
-
def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
516
|
-
"""
|
517
|
-
Specifies the Conda environment for the step.
|
518
|
-
|
519
|
-
Information in this decorator will augment any
|
520
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
521
|
-
you can use `@conda_base` to set packages required by all
|
522
|
-
steps and use `@conda` to specify step-specific overrides.
|
523
|
-
|
524
|
-
|
525
|
-
Parameters
|
526
|
-
----------
|
527
|
-
packages : Dict[str, str], default {}
|
528
|
-
Packages to use for this step. The key is the name of the package
|
529
|
-
and the value is the version to use.
|
530
|
-
libraries : Dict[str, str], default {}
|
531
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
532
|
-
python : str, optional, default None
|
533
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
534
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
535
|
-
disabled : bool, default False
|
536
|
-
If set to True, disables @conda.
|
537
|
-
"""
|
538
|
-
...
|
539
|
-
|
540
|
-
@typing.overload
|
541
|
-
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
542
|
-
...
|
543
|
-
|
544
|
-
@typing.overload
|
545
|
-
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
546
|
-
...
|
547
|
-
|
548
|
-
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
549
|
-
"""
|
550
|
-
Specifies the Conda environment for the step.
|
551
|
-
|
552
|
-
Information in this decorator will augment any
|
553
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
554
|
-
you can use `@conda_base` to set packages required by all
|
555
|
-
steps and use `@conda` to specify step-specific overrides.
|
556
|
-
|
557
|
-
|
558
|
-
Parameters
|
559
|
-
----------
|
560
|
-
packages : Dict[str, str], default {}
|
561
|
-
Packages to use for this step. The key is the name of the package
|
562
|
-
and the value is the version to use.
|
563
|
-
libraries : Dict[str, str], default {}
|
564
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
565
|
-
python : str, optional, default None
|
566
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
567
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
568
|
-
disabled : bool, default False
|
569
|
-
If set to True, disables @conda.
|
570
|
-
"""
|
571
|
-
...
|
572
|
-
|
573
|
-
@typing.overload
|
574
|
-
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
575
|
-
"""
|
576
|
-
Internal decorator to support Fast bakery
|
577
|
-
"""
|
578
|
-
...
|
579
|
-
|
580
|
-
@typing.overload
|
581
|
-
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
582
|
-
...
|
583
|
-
|
584
|
-
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
585
|
-
"""
|
586
|
-
Internal decorator to support Fast bakery
|
587
|
-
"""
|
588
|
-
...
|
589
|
-
|
590
686
|
def vllm(*, model: str, backend: str, debug: bool, kwargs: typing.Any) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
591
687
|
"""
|
592
688
|
This decorator is used to run vllm APIs as Metaflow task sidecars.
|
@@ -626,127 +722,87 @@ def vllm(*, model: str, backend: str, debug: bool, kwargs: typing.Any) -> typing
|
|
626
722
|
...
|
627
723
|
|
628
724
|
@typing.overload
|
629
|
-
def
|
725
|
+
def resources(*, cpu: int = 1, gpu: typing.Optional[int] = None, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
630
726
|
"""
|
631
|
-
Specifies
|
632
|
-
|
633
|
-
This decorator is useful if this step may hang indefinitely.
|
727
|
+
Specifies the resources needed when executing this step.
|
634
728
|
|
635
|
-
|
636
|
-
|
637
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
729
|
+
Use `@resources` to specify the resource requirements
|
730
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
638
731
|
|
639
|
-
|
640
|
-
|
732
|
+
You can choose the compute layer on the command line by executing e.g.
|
733
|
+
```
|
734
|
+
python myflow.py run --with batch
|
735
|
+
```
|
736
|
+
or
|
737
|
+
```
|
738
|
+
python myflow.py run --with kubernetes
|
739
|
+
```
|
740
|
+
which executes the flow on the desired system using the
|
741
|
+
requirements specified in `@resources`.
|
641
742
|
|
642
743
|
|
643
744
|
Parameters
|
644
745
|
----------
|
645
|
-
|
646
|
-
Number of
|
647
|
-
|
648
|
-
Number of
|
649
|
-
|
650
|
-
|
746
|
+
cpu : int, default 1
|
747
|
+
Number of CPUs required for this step.
|
748
|
+
gpu : int, optional, default None
|
749
|
+
Number of GPUs required for this step.
|
750
|
+
disk : int, optional, default None
|
751
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
752
|
+
memory : int, default 4096
|
753
|
+
Memory size (in MB) required for this step.
|
754
|
+
shared_memory : int, optional, default None
|
755
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
756
|
+
This parameter maps to the `--shm-size` option in Docker.
|
651
757
|
"""
|
652
758
|
...
|
653
759
|
|
654
760
|
@typing.overload
|
655
|
-
def
|
761
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
656
762
|
...
|
657
763
|
|
658
764
|
@typing.overload
|
659
|
-
def
|
765
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
660
766
|
...
|
661
767
|
|
662
|
-
def
|
768
|
+
def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: typing.Optional[int] = None, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None):
|
663
769
|
"""
|
664
|
-
Specifies
|
665
|
-
|
666
|
-
This decorator is useful if this step may hang indefinitely.
|
770
|
+
Specifies the resources needed when executing this step.
|
667
771
|
|
668
|
-
|
669
|
-
|
670
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
772
|
+
Use `@resources` to specify the resource requirements
|
773
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
671
774
|
|
672
|
-
|
673
|
-
|
775
|
+
You can choose the compute layer on the command line by executing e.g.
|
776
|
+
```
|
777
|
+
python myflow.py run --with batch
|
778
|
+
```
|
779
|
+
or
|
780
|
+
```
|
781
|
+
python myflow.py run --with kubernetes
|
782
|
+
```
|
783
|
+
which executes the flow on the desired system using the
|
784
|
+
requirements specified in `@resources`.
|
674
785
|
|
675
786
|
|
676
787
|
Parameters
|
677
788
|
----------
|
678
|
-
|
679
|
-
Number of
|
680
|
-
|
681
|
-
Number of
|
682
|
-
|
683
|
-
|
789
|
+
cpu : int, default 1
|
790
|
+
Number of CPUs required for this step.
|
791
|
+
gpu : int, optional, default None
|
792
|
+
Number of GPUs required for this step.
|
793
|
+
disk : int, optional, default None
|
794
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
795
|
+
memory : int, default 4096
|
796
|
+
Memory size (in MB) required for this step.
|
797
|
+
shared_memory : int, optional, default None
|
798
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
799
|
+
This parameter maps to the `--shm-size` option in Docker.
|
684
800
|
"""
|
685
801
|
...
|
686
802
|
|
687
|
-
def
|
803
|
+
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', image_pull_secrets: typing.List[str] = [], service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
688
804
|
"""
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
Parameters
|
693
|
-
----------
|
694
|
-
temp_dir_root : str, optional
|
695
|
-
The root directory that will hold the temporary directory where objects will be downloaded.
|
696
|
-
|
697
|
-
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
698
|
-
The list of repos (models/datasets) to load.
|
699
|
-
|
700
|
-
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
701
|
-
|
702
|
-
- If repo (model/dataset) is not found in the datastore:
|
703
|
-
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
704
|
-
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
705
|
-
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
706
|
-
|
707
|
-
- If repo is found in the datastore:
|
708
|
-
- Loads it directly from datastore to local path (can be temporary directory or specified path)
|
709
|
-
"""
|
710
|
-
...
|
711
|
-
|
712
|
-
@typing.overload
|
713
|
-
def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
714
|
-
"""
|
715
|
-
Specifies secrets to be retrieved and injected as environment variables prior to
|
716
|
-
the execution of a step.
|
717
|
-
|
718
|
-
|
719
|
-
Parameters
|
720
|
-
----------
|
721
|
-
sources : List[Union[str, Dict[str, Any]]], default: []
|
722
|
-
List of secret specs, defining how the secrets are to be retrieved
|
723
|
-
"""
|
724
|
-
...
|
725
|
-
|
726
|
-
@typing.overload
|
727
|
-
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
728
|
-
...
|
729
|
-
|
730
|
-
@typing.overload
|
731
|
-
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
732
|
-
...
|
733
|
-
|
734
|
-
def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
|
735
|
-
"""
|
736
|
-
Specifies secrets to be retrieved and injected as environment variables prior to
|
737
|
-
the execution of a step.
|
738
|
-
|
739
|
-
|
740
|
-
Parameters
|
741
|
-
----------
|
742
|
-
sources : List[Union[str, Dict[str, Any]]], default: []
|
743
|
-
List of secret specs, defining how the secrets are to be retrieved
|
744
|
-
"""
|
745
|
-
...
|
746
|
-
|
747
|
-
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', image_pull_secrets: typing.List[str] = [], service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
748
|
-
"""
|
749
|
-
Specifies that this step should execute on Kubernetes.
|
805
|
+
Specifies that this step should execute on Kubernetes.
|
750
806
|
|
751
807
|
|
752
808
|
Parameters
|
@@ -833,6 +889,74 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
|
|
833
889
|
"""
|
834
890
|
...
|
835
891
|
|
892
|
+
@typing.overload
|
893
|
+
def card(*, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
894
|
+
"""
|
895
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
896
|
+
|
897
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
898
|
+
|
899
|
+
|
900
|
+
Parameters
|
901
|
+
----------
|
902
|
+
type : str, default 'default'
|
903
|
+
Card type.
|
904
|
+
id : str, optional, default None
|
905
|
+
If multiple cards are present, use this id to identify this card.
|
906
|
+
options : Dict[str, Any], default {}
|
907
|
+
Options passed to the card. The contents depend on the card type.
|
908
|
+
timeout : int, default 45
|
909
|
+
Interrupt reporting if it takes more than this many seconds.
|
910
|
+
"""
|
911
|
+
...
|
912
|
+
|
913
|
+
@typing.overload
|
914
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
915
|
+
...
|
916
|
+
|
917
|
+
@typing.overload
|
918
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
919
|
+
...
|
920
|
+
|
921
|
+
def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45):
|
922
|
+
"""
|
923
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
924
|
+
|
925
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
926
|
+
|
927
|
+
|
928
|
+
Parameters
|
929
|
+
----------
|
930
|
+
type : str, default 'default'
|
931
|
+
Card type.
|
932
|
+
id : str, optional, default None
|
933
|
+
If multiple cards are present, use this id to identify this card.
|
934
|
+
options : Dict[str, Any], default {}
|
935
|
+
Options passed to the card. The contents depend on the card type.
|
936
|
+
timeout : int, default 45
|
937
|
+
Interrupt reporting if it takes more than this many seconds.
|
938
|
+
"""
|
939
|
+
...
|
940
|
+
|
941
|
+
@typing.overload
|
942
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
943
|
+
"""
|
944
|
+
Decorator prototype for all step decorators. This function gets specialized
|
945
|
+
and imported for all decorators types by _import_plugin_decorators().
|
946
|
+
"""
|
947
|
+
...
|
948
|
+
|
949
|
+
@typing.overload
|
950
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
951
|
+
...
|
952
|
+
|
953
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
954
|
+
"""
|
955
|
+
Decorator prototype for all step decorators. This function gets specialized
|
956
|
+
and imported for all decorators types by _import_plugin_decorators().
|
957
|
+
"""
|
958
|
+
...
|
959
|
+
|
836
960
|
@typing.overload
|
837
961
|
def retry(*, times: int = 3, minutes_between_retries: int = 2) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
838
962
|
"""
|
@@ -889,132 +1013,266 @@ def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
889
1013
|
...
|
890
1014
|
|
891
1015
|
@typing.overload
|
892
|
-
def
|
1016
|
+
def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
893
1017
|
"""
|
894
|
-
|
1018
|
+
Specifies the Conda environment for the step.
|
895
1019
|
|
896
|
-
|
1020
|
+
Information in this decorator will augment any
|
1021
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
1022
|
+
you can use `@conda_base` to set packages required by all
|
1023
|
+
steps and use `@conda` to specify step-specific overrides.
|
897
1024
|
|
898
1025
|
|
899
1026
|
Parameters
|
900
1027
|
----------
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
1028
|
+
packages : Dict[str, str], default {}
|
1029
|
+
Packages to use for this step. The key is the name of the package
|
1030
|
+
and the value is the version to use.
|
1031
|
+
libraries : Dict[str, str], default {}
|
1032
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1033
|
+
python : str, optional, default None
|
1034
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1035
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1036
|
+
disabled : bool, default False
|
1037
|
+
If set to True, disables @conda.
|
909
1038
|
"""
|
910
1039
|
...
|
911
1040
|
|
912
1041
|
@typing.overload
|
913
|
-
def
|
1042
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
914
1043
|
...
|
915
1044
|
|
916
1045
|
@typing.overload
|
917
|
-
def
|
1046
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
918
1047
|
...
|
919
1048
|
|
920
|
-
def
|
1049
|
+
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
921
1050
|
"""
|
922
|
-
|
1051
|
+
Specifies the Conda environment for the step.
|
923
1052
|
|
924
|
-
|
1053
|
+
Information in this decorator will augment any
|
1054
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
1055
|
+
you can use `@conda_base` to set packages required by all
|
1056
|
+
steps and use `@conda` to specify step-specific overrides.
|
925
1057
|
|
926
1058
|
|
927
1059
|
Parameters
|
928
1060
|
----------
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
1061
|
+
packages : Dict[str, str], default {}
|
1062
|
+
Packages to use for this step. The key is the name of the package
|
1063
|
+
and the value is the version to use.
|
1064
|
+
libraries : Dict[str, str], default {}
|
1065
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1066
|
+
python : str, optional, default None
|
1067
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1068
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1069
|
+
disabled : bool, default False
|
1070
|
+
If set to True, disables @conda.
|
937
1071
|
"""
|
938
1072
|
...
|
939
1073
|
|
940
1074
|
@typing.overload
|
941
|
-
def
|
1075
|
+
def model(*, load: typing.Union[typing.List[str], str, typing.List[typing.Tuple[str, typing.Optional[str]]]] = None, temp_dir_root: str = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
942
1076
|
"""
|
943
|
-
|
1077
|
+
Enables loading / saving of models within a step.
|
944
1078
|
|
945
|
-
|
946
|
-
|
1079
|
+
> Examples
|
1080
|
+
- Saving Models
|
1081
|
+
```python
|
1082
|
+
@model
|
1083
|
+
@step
|
1084
|
+
def train(self):
|
1085
|
+
# current.model.save returns a dictionary reference to the model saved
|
1086
|
+
self.my_model = current.model.save(
|
1087
|
+
path_to_my_model,
|
1088
|
+
label="my_model",
|
1089
|
+
metadata={
|
1090
|
+
"epochs": 10,
|
1091
|
+
"batch-size": 32,
|
1092
|
+
"learning-rate": 0.001,
|
1093
|
+
}
|
1094
|
+
)
|
1095
|
+
self.next(self.test)
|
947
1096
|
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
1097
|
+
@model(load="my_model")
|
1098
|
+
@step
|
1099
|
+
def test(self):
|
1100
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
1101
|
+
# where the key is the name of the artifact and the value is the path to the model
|
1102
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
1103
|
+
self.next(self.end)
|
953
1104
|
```
|
954
|
-
|
1105
|
+
|
1106
|
+
- Loading models
|
1107
|
+
```python
|
1108
|
+
@step
|
1109
|
+
def train(self):
|
1110
|
+
# current.model.load returns the path to the model loaded
|
1111
|
+
checkpoint_path = current.model.load(
|
1112
|
+
self.checkpoint_key,
|
1113
|
+
)
|
1114
|
+
model_path = current.model.load(
|
1115
|
+
self.model,
|
1116
|
+
)
|
1117
|
+
self.next(self.test)
|
955
1118
|
```
|
956
|
-
which executes the flow on the desired system using the
|
957
|
-
requirements specified in `@resources`.
|
958
1119
|
|
959
1120
|
|
960
1121
|
Parameters
|
961
1122
|
----------
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
972
|
-
This parameter maps to the `--shm-size` option in Docker.
|
1123
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
1124
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
1125
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by `current.checkpoint` / `current.model` / `current.huggingface_hub`.
|
1126
|
+
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
1127
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
1128
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
1129
|
+
|
1130
|
+
temp_dir_root : str, default: None
|
1131
|
+
The root directory under which `current.model.loaded` will store loaded models
|
973
1132
|
"""
|
974
1133
|
...
|
975
1134
|
|
976
1135
|
@typing.overload
|
977
|
-
def
|
1136
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
978
1137
|
...
|
979
1138
|
|
980
1139
|
@typing.overload
|
981
|
-
def
|
1140
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
982
1141
|
...
|
983
1142
|
|
984
|
-
def
|
1143
|
+
def model(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load: typing.Union[typing.List[str], str, typing.List[typing.Tuple[str, typing.Optional[str]]]] = None, temp_dir_root: str = None):
|
985
1144
|
"""
|
986
|
-
|
1145
|
+
Enables loading / saving of models within a step.
|
987
1146
|
|
988
|
-
|
989
|
-
|
1147
|
+
> Examples
|
1148
|
+
- Saving Models
|
1149
|
+
```python
|
1150
|
+
@model
|
1151
|
+
@step
|
1152
|
+
def train(self):
|
1153
|
+
# current.model.save returns a dictionary reference to the model saved
|
1154
|
+
self.my_model = current.model.save(
|
1155
|
+
path_to_my_model,
|
1156
|
+
label="my_model",
|
1157
|
+
metadata={
|
1158
|
+
"epochs": 10,
|
1159
|
+
"batch-size": 32,
|
1160
|
+
"learning-rate": 0.001,
|
1161
|
+
}
|
1162
|
+
)
|
1163
|
+
self.next(self.test)
|
990
1164
|
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
1165
|
+
@model(load="my_model")
|
1166
|
+
@step
|
1167
|
+
def test(self):
|
1168
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
1169
|
+
# where the key is the name of the artifact and the value is the path to the model
|
1170
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
1171
|
+
self.next(self.end)
|
996
1172
|
```
|
997
|
-
|
1173
|
+
|
1174
|
+
- Loading models
|
1175
|
+
```python
|
1176
|
+
@step
|
1177
|
+
def train(self):
|
1178
|
+
# current.model.load returns the path to the model loaded
|
1179
|
+
checkpoint_path = current.model.load(
|
1180
|
+
self.checkpoint_key,
|
1181
|
+
)
|
1182
|
+
model_path = current.model.load(
|
1183
|
+
self.model,
|
1184
|
+
)
|
1185
|
+
self.next(self.test)
|
998
1186
|
```
|
999
|
-
which executes the flow on the desired system using the
|
1000
|
-
requirements specified in `@resources`.
|
1001
1187
|
|
1002
1188
|
|
1003
1189
|
Parameters
|
1004
1190
|
----------
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1191
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
1192
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
1193
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by `current.checkpoint` / `current.model` / `current.huggingface_hub`.
|
1194
|
+
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
1195
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
1196
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
1197
|
+
|
1198
|
+
temp_dir_root : str, default: None
|
1199
|
+
The root directory under which `current.model.loaded` will store loaded models
|
1200
|
+
"""
|
1201
|
+
...
|
1202
|
+
|
1203
|
+
@typing.overload
|
1204
|
+
def environment(*, vars: typing.Dict[str, str] = {}) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
1205
|
+
"""
|
1206
|
+
Specifies environment variables to be set prior to the execution of a step.
|
1207
|
+
|
1208
|
+
|
1209
|
+
Parameters
|
1210
|
+
----------
|
1211
|
+
vars : Dict[str, str], default {}
|
1212
|
+
Dictionary of environment variables to set.
|
1213
|
+
"""
|
1214
|
+
...
|
1215
|
+
|
1216
|
+
@typing.overload
|
1217
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1218
|
+
...
|
1219
|
+
|
1220
|
+
@typing.overload
|
1221
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1222
|
+
...
|
1223
|
+
|
1224
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
1225
|
+
"""
|
1226
|
+
Specifies environment variables to be set prior to the execution of a step.
|
1227
|
+
|
1228
|
+
|
1229
|
+
Parameters
|
1230
|
+
----------
|
1231
|
+
vars : Dict[str, str], default {}
|
1232
|
+
Dictionary of environment variables to set.
|
1233
|
+
"""
|
1234
|
+
...
|
1235
|
+
|
1236
|
+
@typing.overload
|
1237
|
+
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1238
|
+
"""
|
1239
|
+
Specifies the PyPI packages for all steps of the flow.
|
1240
|
+
|
1241
|
+
Use `@pypi_base` to set common packages required by all
|
1242
|
+
steps and use `@pypi` to specify step-specific overrides.
|
1243
|
+
|
1244
|
+
Parameters
|
1245
|
+
----------
|
1246
|
+
packages : Dict[str, str], default: {}
|
1247
|
+
Packages to use for this flow. The key is the name of the package
|
1248
|
+
and the value is the version to use.
|
1249
|
+
python : str, optional, default: None
|
1250
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1251
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1252
|
+
"""
|
1253
|
+
...
|
1254
|
+
|
1255
|
+
@typing.overload
|
1256
|
+
def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1257
|
+
...
|
1258
|
+
|
1259
|
+
def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
1260
|
+
"""
|
1261
|
+
Specifies the PyPI packages for all steps of the flow.
|
1262
|
+
|
1263
|
+
Use `@pypi_base` to set common packages required by all
|
1264
|
+
steps and use `@pypi` to specify step-specific overrides.
|
1265
|
+
|
1266
|
+
Parameters
|
1267
|
+
----------
|
1268
|
+
packages : Dict[str, str], default: {}
|
1269
|
+
Packages to use for this flow. The key is the name of the package
|
1270
|
+
and the value is the version to use.
|
1271
|
+
python : str, optional, default: None
|
1272
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1273
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1274
|
+
"""
|
1275
|
+
...
|
1018
1276
|
|
1019
1277
|
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1020
1278
|
"""
|
@@ -1051,6 +1309,142 @@ def project(*, name: str, branch: typing.Optional[str] = None, production: bool
|
|
1051
1309
|
"""
|
1052
1310
|
...
|
1053
1311
|
|
1312
|
+
def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, exponential_backoff: bool, pool: str, soft_fail: bool, name: str, description: str, bucket_key: typing.Union[str, typing.List[str]], bucket_name: str, wildcard_match: bool, aws_conn_id: str, verify: bool) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1313
|
+
"""
|
1314
|
+
The `@airflow_s3_key_sensor` decorator attaches a Airflow [S3KeySensor](https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_api/airflow/providers/amazon/aws/sensors/s3/index.html#airflow.providers.amazon.aws.sensors.s3.S3KeySensor)
|
1315
|
+
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1316
|
+
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1317
|
+
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1318
|
+
starts only after all sensors finish.
|
1319
|
+
|
1320
|
+
|
1321
|
+
Parameters
|
1322
|
+
----------
|
1323
|
+
timeout : int
|
1324
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1325
|
+
poke_interval : int
|
1326
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1327
|
+
mode : str
|
1328
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1329
|
+
exponential_backoff : bool
|
1330
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1331
|
+
pool : str
|
1332
|
+
the slot pool this task should run in,
|
1333
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1334
|
+
soft_fail : bool
|
1335
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1336
|
+
name : str
|
1337
|
+
Name of the sensor on Airflow
|
1338
|
+
description : str
|
1339
|
+
Description of sensor in the Airflow UI
|
1340
|
+
bucket_key : Union[str, List[str]]
|
1341
|
+
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1342
|
+
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1343
|
+
bucket_name : str
|
1344
|
+
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1345
|
+
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1346
|
+
wildcard_match : bool
|
1347
|
+
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1348
|
+
aws_conn_id : str
|
1349
|
+
a reference to the s3 connection on Airflow. (Default: None)
|
1350
|
+
verify : bool
|
1351
|
+
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1352
|
+
"""
|
1353
|
+
...
|
1354
|
+
|
1355
|
+
@typing.overload
|
1356
|
+
def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1357
|
+
"""
|
1358
|
+
Specifies the event(s) that this flow depends on.
|
1359
|
+
|
1360
|
+
```
|
1361
|
+
@trigger(event='foo')
|
1362
|
+
```
|
1363
|
+
or
|
1364
|
+
```
|
1365
|
+
@trigger(events=['foo', 'bar'])
|
1366
|
+
```
|
1367
|
+
|
1368
|
+
Additionally, you can specify the parameter mappings
|
1369
|
+
to map event payload to Metaflow parameters for the flow.
|
1370
|
+
```
|
1371
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1372
|
+
```
|
1373
|
+
or
|
1374
|
+
```
|
1375
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1376
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1377
|
+
```
|
1378
|
+
|
1379
|
+
'parameters' can also be a list of strings and tuples like so:
|
1380
|
+
```
|
1381
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1382
|
+
```
|
1383
|
+
This is equivalent to:
|
1384
|
+
```
|
1385
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1386
|
+
```
|
1387
|
+
|
1388
|
+
|
1389
|
+
Parameters
|
1390
|
+
----------
|
1391
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
1392
|
+
Event dependency for this flow.
|
1393
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
1394
|
+
Events dependency for this flow.
|
1395
|
+
options : Dict[str, Any], default {}
|
1396
|
+
Backend-specific configuration for tuning eventing behavior.
|
1397
|
+
"""
|
1398
|
+
...
|
1399
|
+
|
1400
|
+
@typing.overload
|
1401
|
+
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1402
|
+
...
|
1403
|
+
|
1404
|
+
def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
|
1405
|
+
"""
|
1406
|
+
Specifies the event(s) that this flow depends on.
|
1407
|
+
|
1408
|
+
```
|
1409
|
+
@trigger(event='foo')
|
1410
|
+
```
|
1411
|
+
or
|
1412
|
+
```
|
1413
|
+
@trigger(events=['foo', 'bar'])
|
1414
|
+
```
|
1415
|
+
|
1416
|
+
Additionally, you can specify the parameter mappings
|
1417
|
+
to map event payload to Metaflow parameters for the flow.
|
1418
|
+
```
|
1419
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1420
|
+
```
|
1421
|
+
or
|
1422
|
+
```
|
1423
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1424
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1425
|
+
```
|
1426
|
+
|
1427
|
+
'parameters' can also be a list of strings and tuples like so:
|
1428
|
+
```
|
1429
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1430
|
+
```
|
1431
|
+
This is equivalent to:
|
1432
|
+
```
|
1433
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1434
|
+
```
|
1435
|
+
|
1436
|
+
|
1437
|
+
Parameters
|
1438
|
+
----------
|
1439
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
1440
|
+
Event dependency for this flow.
|
1441
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
1442
|
+
Events dependency for this flow.
|
1443
|
+
options : Dict[str, Any], default {}
|
1444
|
+
Backend-specific configuration for tuning eventing behavior.
|
1445
|
+
"""
|
1446
|
+
...
|
1447
|
+
|
1054
1448
|
def airflow_external_task_sensor(*, timeout: int, poke_interval: int, mode: str, exponential_backoff: bool, pool: str, soft_fail: bool, name: str, description: str, external_dag_id: str, external_task_ids: typing.List[str], allowed_states: typing.List[str], failed_states: typing.List[str], execution_delta: "datetime.timedelta", check_existence: bool) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1055
1449
|
"""
|
1056
1450
|
The `@airflow_external_task_sensor` decorator attaches a Airflow [ExternalTaskSensor](https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/sensors/external_task/index.html#airflow.sensors.external_task.ExternalTaskSensor) before the start step of the flow.
|
@@ -1094,158 +1488,104 @@ def airflow_external_task_sensor(*, timeout: int, poke_interval: int, mode: str,
|
|
1094
1488
|
"""
|
1095
1489
|
...
|
1096
1490
|
|
1097
|
-
|
1491
|
+
@typing.overload
|
1492
|
+
def trigger_on_finish(*, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1098
1493
|
"""
|
1099
|
-
|
1100
|
-
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
1101
|
-
|
1102
|
-
This decorator is useful when users wish to save data to a different datastore
|
1103
|
-
than what is configured in Metaflow. This can be for variety of reasons:
|
1104
|
-
|
1105
|
-
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
1106
|
-
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
1107
|
-
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
1108
|
-
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
1109
|
-
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
1494
|
+
Specifies the flow(s) that this flow depends on.
|
1110
1495
|
|
1111
|
-
|
1112
|
-
|
1496
|
+
```
|
1497
|
+
@trigger_on_finish(flow='FooFlow')
|
1498
|
+
```
|
1499
|
+
or
|
1500
|
+
```
|
1501
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1502
|
+
```
|
1503
|
+
This decorator respects the @project decorator and triggers the flow
|
1504
|
+
when upstream runs within the same namespace complete successfully
|
1113
1505
|
|
1114
|
-
|
1506
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1507
|
+
by specifying the fully qualified project_flow_name.
|
1508
|
+
```
|
1509
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1510
|
+
```
|
1511
|
+
or
|
1512
|
+
```
|
1513
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1514
|
+
```
|
1115
1515
|
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
"role_arn": ROLE,
|
1122
|
-
},
|
1123
|
-
)
|
1124
|
-
class MyFlow(FlowSpec):
|
1125
|
-
|
1126
|
-
@checkpoint
|
1127
|
-
@step
|
1128
|
-
def start(self):
|
1129
|
-
with open("my_file.txt", "w") as f:
|
1130
|
-
f.write("Hello, World!")
|
1131
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1132
|
-
self.next(self.end)
|
1133
|
-
|
1134
|
-
```
|
1135
|
-
|
1136
|
-
- Using credentials to access the s3-compatible datastore.
|
1137
|
-
|
1138
|
-
```python
|
1139
|
-
@with_artifact_store(
|
1140
|
-
type="s3",
|
1141
|
-
config=lambda: {
|
1142
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
1143
|
-
"client_params": {
|
1144
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1145
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1146
|
-
},
|
1147
|
-
},
|
1148
|
-
)
|
1149
|
-
class MyFlow(FlowSpec):
|
1150
|
-
|
1151
|
-
@checkpoint
|
1152
|
-
@step
|
1153
|
-
def start(self):
|
1154
|
-
with open("my_file.txt", "w") as f:
|
1155
|
-
f.write("Hello, World!")
|
1156
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1157
|
-
self.next(self.end)
|
1158
|
-
|
1159
|
-
```
|
1160
|
-
|
1161
|
-
- Accessing objects stored in external datastores after task execution.
|
1162
|
-
|
1163
|
-
```python
|
1164
|
-
run = Run("CheckpointsTestsFlow/8992")
|
1165
|
-
with artifact_store_from(run=run, config={
|
1166
|
-
"client_params": {
|
1167
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1168
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1169
|
-
},
|
1170
|
-
}):
|
1171
|
-
with Checkpoint() as cp:
|
1172
|
-
latest = cp.list(
|
1173
|
-
task=run["start"].task
|
1174
|
-
)[0]
|
1175
|
-
print(latest)
|
1176
|
-
cp.load(
|
1177
|
-
latest,
|
1178
|
-
"test-checkpoints"
|
1179
|
-
)
|
1180
|
-
|
1181
|
-
task = Task("TorchTuneFlow/8484/train/53673")
|
1182
|
-
with artifact_store_from(run=run, config={
|
1183
|
-
"client_params": {
|
1184
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1185
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1186
|
-
},
|
1187
|
-
}):
|
1188
|
-
load_model(
|
1189
|
-
task.data.model_ref,
|
1190
|
-
"test-models"
|
1191
|
-
)
|
1192
|
-
```
|
1193
|
-
Parameters:
|
1194
|
-
----------
|
1195
|
-
|
1196
|
-
type: str
|
1197
|
-
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
1516
|
+
You can also specify just the project or project branch (other values will be
|
1517
|
+
inferred from the current project or project branch):
|
1518
|
+
```
|
1519
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1520
|
+
```
|
1198
1521
|
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
1205
|
-
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
1206
|
-
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
1207
|
-
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
1208
|
-
"""
|
1209
|
-
...
|
1210
|
-
|
1211
|
-
@typing.overload
|
1212
|
-
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1213
|
-
"""
|
1214
|
-
Specifies the PyPI packages for all steps of the flow.
|
1522
|
+
Note that `branch` is typically one of:
|
1523
|
+
- `prod`
|
1524
|
+
- `user.bob`
|
1525
|
+
- `test.my_experiment`
|
1526
|
+
- `prod.staging`
|
1215
1527
|
|
1216
|
-
Use `@pypi_base` to set common packages required by all
|
1217
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1218
1528
|
|
1219
1529
|
Parameters
|
1220
1530
|
----------
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1531
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1532
|
+
Upstream flow dependency for this flow.
|
1533
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1534
|
+
Upstream flow dependencies for this flow.
|
1535
|
+
options : Dict[str, Any], default {}
|
1536
|
+
Backend-specific configuration for tuning eventing behavior.
|
1227
1537
|
"""
|
1228
1538
|
...
|
1229
1539
|
|
1230
1540
|
@typing.overload
|
1231
|
-
def
|
1541
|
+
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1232
1542
|
...
|
1233
1543
|
|
1234
|
-
def
|
1544
|
+
def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
|
1235
1545
|
"""
|
1236
|
-
Specifies the
|
1546
|
+
Specifies the flow(s) that this flow depends on.
|
1547
|
+
|
1548
|
+
```
|
1549
|
+
@trigger_on_finish(flow='FooFlow')
|
1550
|
+
```
|
1551
|
+
or
|
1552
|
+
```
|
1553
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1554
|
+
```
|
1555
|
+
This decorator respects the @project decorator and triggers the flow
|
1556
|
+
when upstream runs within the same namespace complete successfully
|
1557
|
+
|
1558
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1559
|
+
by specifying the fully qualified project_flow_name.
|
1560
|
+
```
|
1561
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1562
|
+
```
|
1563
|
+
or
|
1564
|
+
```
|
1565
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1566
|
+
```
|
1567
|
+
|
1568
|
+
You can also specify just the project or project branch (other values will be
|
1569
|
+
inferred from the current project or project branch):
|
1570
|
+
```
|
1571
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1572
|
+
```
|
1573
|
+
|
1574
|
+
Note that `branch` is typically one of:
|
1575
|
+
- `prod`
|
1576
|
+
- `user.bob`
|
1577
|
+
- `test.my_experiment`
|
1578
|
+
- `prod.staging`
|
1237
1579
|
|
1238
|
-
Use `@pypi_base` to set common packages required by all
|
1239
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1240
1580
|
|
1241
1581
|
Parameters
|
1242
1582
|
----------
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1583
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1584
|
+
Upstream flow dependency for this flow.
|
1585
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1586
|
+
Upstream flow dependencies for this flow.
|
1587
|
+
options : Dict[str, Any], default {}
|
1588
|
+
Backend-specific configuration for tuning eventing behavior.
|
1249
1589
|
"""
|
1250
1590
|
...
|
1251
1591
|
|
@@ -1351,240 +1691,117 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
|
|
1351
1691
|
"""
|
1352
1692
|
...
|
1353
1693
|
|
1354
|
-
def
|
1355
|
-
"""
|
1356
|
-
The `@airflow_s3_key_sensor` decorator attaches a Airflow [S3KeySensor](https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_api/airflow/providers/amazon/aws/sensors/s3/index.html#airflow.providers.amazon.aws.sensors.s3.S3KeySensor)
|
1357
|
-
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1358
|
-
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1359
|
-
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1360
|
-
starts only after all sensors finish.
|
1361
|
-
|
1362
|
-
|
1363
|
-
Parameters
|
1364
|
-
----------
|
1365
|
-
timeout : int
|
1366
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
1367
|
-
poke_interval : int
|
1368
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
1369
|
-
mode : str
|
1370
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1371
|
-
exponential_backoff : bool
|
1372
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1373
|
-
pool : str
|
1374
|
-
the slot pool this task should run in,
|
1375
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1376
|
-
soft_fail : bool
|
1377
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1378
|
-
name : str
|
1379
|
-
Name of the sensor on Airflow
|
1380
|
-
description : str
|
1381
|
-
Description of sensor in the Airflow UI
|
1382
|
-
bucket_key : Union[str, List[str]]
|
1383
|
-
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1384
|
-
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1385
|
-
bucket_name : str
|
1386
|
-
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1387
|
-
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1388
|
-
wildcard_match : bool
|
1389
|
-
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1390
|
-
aws_conn_id : str
|
1391
|
-
a reference to the s3 connection on Airflow. (Default: None)
|
1392
|
-
verify : bool
|
1393
|
-
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1394
|
-
"""
|
1395
|
-
...
|
1396
|
-
|
1397
|
-
@typing.overload
|
1398
|
-
def trigger_on_finish(*, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1694
|
+
def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
|
1399
1695
|
"""
|
1400
|
-
|
1401
|
-
|
1402
|
-
```
|
1403
|
-
@trigger_on_finish(flow='FooFlow')
|
1404
|
-
```
|
1405
|
-
or
|
1406
|
-
```
|
1407
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1408
|
-
```
|
1409
|
-
This decorator respects the @project decorator and triggers the flow
|
1410
|
-
when upstream runs within the same namespace complete successfully
|
1411
|
-
|
1412
|
-
Additionally, you can specify project aware upstream flow dependencies
|
1413
|
-
by specifying the fully qualified project_flow_name.
|
1414
|
-
```
|
1415
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1416
|
-
```
|
1417
|
-
or
|
1418
|
-
```
|
1419
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1420
|
-
```
|
1421
|
-
|
1422
|
-
You can also specify just the project or project branch (other values will be
|
1423
|
-
inferred from the current project or project branch):
|
1424
|
-
```
|
1425
|
-
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1426
|
-
```
|
1696
|
+
Allows setting external datastores to save data for the
|
1697
|
+
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
1427
1698
|
|
1428
|
-
|
1429
|
-
|
1430
|
-
- `user.bob`
|
1431
|
-
- `test.my_experiment`
|
1432
|
-
- `prod.staging`
|
1699
|
+
This decorator is useful when users wish to save data to a different datastore
|
1700
|
+
than what is configured in Metaflow. This can be for variety of reasons:
|
1433
1701
|
|
1702
|
+
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
1703
|
+
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
1704
|
+
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
1705
|
+
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
1706
|
+
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
1434
1707
|
|
1435
|
-
|
1708
|
+
Usage:
|
1436
1709
|
----------
|
1437
|
-
flow : Union[str, Dict[str, str]], optional, default None
|
1438
|
-
Upstream flow dependency for this flow.
|
1439
|
-
flows : List[Union[str, Dict[str, str]]], default []
|
1440
|
-
Upstream flow dependencies for this flow.
|
1441
|
-
options : Dict[str, Any], default {}
|
1442
|
-
Backend-specific configuration for tuning eventing behavior.
|
1443
|
-
"""
|
1444
|
-
...
|
1445
|
-
|
1446
|
-
@typing.overload
|
1447
|
-
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1448
|
-
...
|
1449
|
-
|
1450
|
-
def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
|
1451
|
-
"""
|
1452
|
-
Specifies the flow(s) that this flow depends on.
|
1453
1710
|
|
1454
|
-
|
1455
|
-
@trigger_on_finish(flow='FooFlow')
|
1456
|
-
```
|
1457
|
-
or
|
1458
|
-
```
|
1459
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1460
|
-
```
|
1461
|
-
This decorator respects the @project decorator and triggers the flow
|
1462
|
-
when upstream runs within the same namespace complete successfully
|
1711
|
+
- Using a custom IAM role to access the datastore.
|
1463
1712
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1713
|
+
```python
|
1714
|
+
@with_artifact_store(
|
1715
|
+
type="s3",
|
1716
|
+
config=lambda: {
|
1717
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
1718
|
+
"role_arn": ROLE,
|
1719
|
+
},
|
1720
|
+
)
|
1721
|
+
class MyFlow(FlowSpec):
|
1473
1722
|
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1723
|
+
@checkpoint
|
1724
|
+
@step
|
1725
|
+
def start(self):
|
1726
|
+
with open("my_file.txt", "w") as f:
|
1727
|
+
f.write("Hello, World!")
|
1728
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1729
|
+
self.next(self.end)
|
1479
1730
|
|
1480
|
-
|
1481
|
-
- `prod`
|
1482
|
-
- `user.bob`
|
1483
|
-
- `test.my_experiment`
|
1484
|
-
- `prod.staging`
|
1731
|
+
```
|
1485
1732
|
|
1733
|
+
- Using credentials to access the s3-compatible datastore.
|
1486
1734
|
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1500
|
-
"""
|
1501
|
-
Specifies the event(s) that this flow depends on.
|
1735
|
+
```python
|
1736
|
+
@with_artifact_store(
|
1737
|
+
type="s3",
|
1738
|
+
config=lambda: {
|
1739
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
1740
|
+
"client_params": {
|
1741
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1742
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1743
|
+
},
|
1744
|
+
},
|
1745
|
+
)
|
1746
|
+
class MyFlow(FlowSpec):
|
1502
1747
|
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1748
|
+
@checkpoint
|
1749
|
+
@step
|
1750
|
+
def start(self):
|
1751
|
+
with open("my_file.txt", "w") as f:
|
1752
|
+
f.write("Hello, World!")
|
1753
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1754
|
+
self.next(self.end)
|
1510
1755
|
|
1511
|
-
|
1512
|
-
to map event payload to Metaflow parameters for the flow.
|
1513
|
-
```
|
1514
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1515
|
-
```
|
1516
|
-
or
|
1517
|
-
```
|
1518
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1519
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1520
|
-
```
|
1756
|
+
```
|
1521
1757
|
|
1522
|
-
|
1523
|
-
```
|
1524
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1525
|
-
```
|
1526
|
-
This is equivalent to:
|
1527
|
-
```
|
1528
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1529
|
-
```
|
1758
|
+
- Accessing objects stored in external datastores after task execution.
|
1530
1759
|
|
1760
|
+
```python
|
1761
|
+
run = Run("CheckpointsTestsFlow/8992")
|
1762
|
+
with artifact_store_from(run=run, config={
|
1763
|
+
"client_params": {
|
1764
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1765
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1766
|
+
},
|
1767
|
+
}):
|
1768
|
+
with Checkpoint() as cp:
|
1769
|
+
latest = cp.list(
|
1770
|
+
task=run["start"].task
|
1771
|
+
)[0]
|
1772
|
+
print(latest)
|
1773
|
+
cp.load(
|
1774
|
+
latest,
|
1775
|
+
"test-checkpoints"
|
1776
|
+
)
|
1531
1777
|
|
1532
|
-
|
1778
|
+
task = Task("TorchTuneFlow/8484/train/53673")
|
1779
|
+
with artifact_store_from(run=run, config={
|
1780
|
+
"client_params": {
|
1781
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1782
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1783
|
+
},
|
1784
|
+
}):
|
1785
|
+
load_model(
|
1786
|
+
task.data.model_ref,
|
1787
|
+
"test-models"
|
1788
|
+
)
|
1789
|
+
```
|
1790
|
+
Parameters:
|
1533
1791
|
----------
|
1534
|
-
event : Union[str, Dict[str, Any]], optional, default None
|
1535
|
-
Event dependency for this flow.
|
1536
|
-
events : List[Union[str, Dict[str, Any]]], default []
|
1537
|
-
Events dependency for this flow.
|
1538
|
-
options : Dict[str, Any], default {}
|
1539
|
-
Backend-specific configuration for tuning eventing behavior.
|
1540
|
-
"""
|
1541
|
-
...
|
1542
|
-
|
1543
|
-
@typing.overload
|
1544
|
-
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1545
|
-
...
|
1546
|
-
|
1547
|
-
def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
|
1548
|
-
"""
|
1549
|
-
Specifies the event(s) that this flow depends on.
|
1550
|
-
|
1551
|
-
```
|
1552
|
-
@trigger(event='foo')
|
1553
|
-
```
|
1554
|
-
or
|
1555
|
-
```
|
1556
|
-
@trigger(events=['foo', 'bar'])
|
1557
|
-
```
|
1558
|
-
|
1559
|
-
Additionally, you can specify the parameter mappings
|
1560
|
-
to map event payload to Metaflow parameters for the flow.
|
1561
|
-
```
|
1562
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1563
|
-
```
|
1564
|
-
or
|
1565
|
-
```
|
1566
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1567
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1568
|
-
```
|
1569
|
-
|
1570
|
-
'parameters' can also be a list of strings and tuples like so:
|
1571
|
-
```
|
1572
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1573
|
-
```
|
1574
|
-
This is equivalent to:
|
1575
|
-
```
|
1576
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1577
|
-
```
|
1578
1792
|
|
1793
|
+
type: str
|
1794
|
+
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
1579
1795
|
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1796
|
+
config: dict or Callable
|
1797
|
+
Dictionary of configuration options for the datastore. The following keys are required:
|
1798
|
+
- root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
|
1799
|
+
- example: 's3://bucket-name/path/to/root'
|
1800
|
+
- example: 'gs://bucket-name/path/to/root'
|
1801
|
+
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
1802
|
+
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
1803
|
+
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
1804
|
+
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
1588
1805
|
"""
|
1589
1806
|
...
|
1590
1807
|
|