ob-metaflow-stubs 6.0.3.163__py2.py3-none-any.whl → 6.0.3.164__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 +724 -710
- metaflow-stubs/cards.pyi +1 -1
- metaflow-stubs/cli.pyi +1 -1
- metaflow-stubs/cli_components/__init__.pyi +1 -1
- metaflow-stubs/cli_components/utils.pyi +1 -1
- metaflow-stubs/client/__init__.pyi +1 -1
- metaflow-stubs/client/core.pyi +4 -4
- metaflow-stubs/client/filecache.pyi +1 -1
- metaflow-stubs/events.pyi +2 -2
- metaflow-stubs/exception.pyi +1 -1
- metaflow-stubs/flowspec.pyi +3 -3
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +2 -2
- metaflow-stubs/info_file.pyi +1 -1
- metaflow-stubs/metadata_provider/__init__.pyi +1 -1
- metaflow-stubs/metadata_provider/heartbeat.pyi +1 -1
- metaflow-stubs/metadata_provider/metadata.pyi +2 -2
- metaflow-stubs/metadata_provider/util.pyi +1 -1
- metaflow-stubs/metaflow_config.pyi +1 -1
- metaflow-stubs/metaflow_current.pyi +136 -136
- metaflow-stubs/metaflow_git.pyi +1 -1
- metaflow-stubs/mf_extensions/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
- 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 +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +1 -1
- 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 +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +1 -1
- 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 +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +1 -1
- 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 +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
- 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 +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
- metaflow-stubs/multicore_utils.pyi +1 -1
- metaflow-stubs/parameters.pyi +2 -2
- metaflow-stubs/plugins/__init__.pyi +9 -9
- metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
- metaflow-stubs/plugins/airflow/exception.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
- metaflow-stubs/plugins/argo/__init__.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_workflows.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +2 -2
- metaflow-stubs/plugins/aws/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
- metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +3 -3
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +3 -3
- metaflow-stubs/plugins/azure/__init__.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
- metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/cards/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_client.pyi +1 -1
- metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
- metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
- metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
- metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
- metaflow-stubs/plugins/cards/exception.pyi +1 -1
- metaflow-stubs/plugins/catch_decorator.pyi +2 -2
- metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/local.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
- metaflow-stubs/plugins/debug_logger.pyi +1 -1
- metaflow-stubs/plugins/debug_monitor.pyi +1 -1
- metaflow-stubs/plugins/environment_decorator.pyi +1 -1
- metaflow-stubs/plugins/events_decorator.pyi +1 -1
- metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
- metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
- metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
- metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
- metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
- metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
- metaflow-stubs/plugins/perimeters.pyi +1 -1
- metaflow-stubs/plugins/project_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_environment.pyi +5 -5
- metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
- metaflow-stubs/plugins/pypi/utils.pyi +1 -1
- metaflow-stubs/plugins/resources_decorator.pyi +1 -1
- metaflow-stubs/plugins/retry_decorator.pyi +1 -1
- metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
- metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/plugins/storage_executor.pyi +1 -1
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
- metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
- metaflow-stubs/plugins/uv/__init__.pyi +1 -1
- metaflow-stubs/plugins/uv/uv_environment.pyi +2 -2
- metaflow-stubs/profilers/__init__.pyi +1 -1
- metaflow-stubs/pylint_wrapper.pyi +1 -1
- metaflow-stubs/runner/__init__.pyi +1 -1
- metaflow-stubs/runner/deployer.pyi +29 -29
- metaflow-stubs/runner/deployer_impl.pyi +2 -2
- metaflow-stubs/runner/metaflow_runner.pyi +2 -2
- metaflow-stubs/runner/nbdeploy.pyi +1 -1
- metaflow-stubs/runner/nbrun.pyi +1 -1
- metaflow-stubs/runner/subprocess_manager.pyi +1 -1
- metaflow-stubs/runner/utils.pyi +2 -2
- metaflow-stubs/system/__init__.pyi +1 -1
- metaflow-stubs/system/system_logger.pyi +2 -2
- metaflow-stubs/system/system_monitor.pyi +1 -1
- metaflow-stubs/tagging_util.pyi +1 -1
- metaflow-stubs/tuple_util.pyi +1 -1
- metaflow-stubs/user_configs/__init__.pyi +1 -1
- metaflow-stubs/user_configs/config_decorators.pyi +5 -5
- metaflow-stubs/user_configs/config_options.pyi +3 -3
- metaflow-stubs/user_configs/config_parameters.pyi +5 -5
- {ob_metaflow_stubs-6.0.3.163.dist-info → ob_metaflow_stubs-6.0.3.164.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.3.164.dist-info/RECORD +206 -0
- ob_metaflow_stubs-6.0.3.163.dist-info/RECORD +0 -206
- {ob_metaflow_stubs-6.0.3.163.dist-info → ob_metaflow_stubs-6.0.3.164.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.3.163.dist-info → ob_metaflow_stubs-6.0.3.164.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
3
|
# MF version: 2.15.11.1+obcheckpoint(0.2.1);ob(v1) #
|
4
|
-
# Generated on 2025-05-
|
4
|
+
# Generated on 2025-05-07T07:24:19.774250 #
|
5
5
|
######################################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
9
|
import typing
|
10
10
|
if typing.TYPE_CHECKING:
|
11
|
-
import typing
|
12
11
|
import datetime
|
12
|
+
import typing
|
13
13
|
FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
|
14
14
|
StepFlag = typing.NewType("StepFlag", bool)
|
15
15
|
|
@@ -35,10 +35,10 @@ from .user_configs.config_parameters import ConfigValue as ConfigValue
|
|
35
35
|
from .user_configs.config_parameters import config_expr as config_expr
|
36
36
|
from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
|
37
37
|
from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
|
38
|
-
from . import cards as cards
|
39
38
|
from . import tuple_util as tuple_util
|
40
|
-
from . import
|
39
|
+
from . import cards as cards
|
41
40
|
from . import metaflow_git as metaflow_git
|
41
|
+
from . import events as events
|
42
42
|
from . import runner as runner
|
43
43
|
from . import plugins as plugins
|
44
44
|
from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
|
@@ -154,111 +154,248 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
154
154
|
...
|
155
155
|
|
156
156
|
@typing.overload
|
157
|
-
def
|
157
|
+
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]]]:
|
158
158
|
"""
|
159
|
-
|
159
|
+
Enables checkpointing for a step.
|
160
160
|
|
161
|
-
The decorator will create an optional artifact, specified by `var`, which
|
162
|
-
contains the exception raised. You can use it to detect the presence
|
163
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
164
|
-
are missing.
|
165
161
|
|
166
162
|
|
167
163
|
Parameters
|
168
164
|
----------
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
165
|
+
load_policy : str, default: "fresh"
|
166
|
+
The policy for loading the checkpoint. The following policies are supported:
|
167
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
168
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
169
|
+
will be loaded at the start of the task.
|
170
|
+
- "none": Do not load any checkpoint
|
171
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
172
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
173
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
174
|
+
created within the task will be loaded when the task is retries execution on failure.
|
175
|
+
|
176
|
+
temp_dir_root : str, default: None
|
177
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
175
178
|
"""
|
176
179
|
...
|
177
180
|
|
178
181
|
@typing.overload
|
179
|
-
def
|
182
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
180
183
|
...
|
181
184
|
|
182
185
|
@typing.overload
|
183
|
-
def
|
186
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
184
187
|
...
|
185
188
|
|
186
|
-
def
|
189
|
+
def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load_policy: str = 'fresh', temp_dir_root: str = None):
|
187
190
|
"""
|
188
|
-
|
191
|
+
Enables checkpointing for a step.
|
189
192
|
|
190
|
-
The decorator will create an optional artifact, specified by `var`, which
|
191
|
-
contains the exception raised. You can use it to detect the presence
|
192
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
193
|
-
are missing.
|
194
193
|
|
195
194
|
|
196
195
|
Parameters
|
197
196
|
----------
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
197
|
+
load_policy : str, default: "fresh"
|
198
|
+
The policy for loading the checkpoint. The following policies are supported:
|
199
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
200
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
201
|
+
will be loaded at the start of the task.
|
202
|
+
- "none": Do not load any checkpoint
|
203
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
204
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
205
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
206
|
+
created within the task will be loaded when the task is retries execution on failure.
|
207
|
+
|
208
|
+
temp_dir_root : str, default: None
|
209
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
204
210
|
"""
|
205
211
|
...
|
206
212
|
|
207
213
|
@typing.overload
|
208
|
-
def
|
214
|
+
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]]]:
|
209
215
|
"""
|
210
|
-
Specifies
|
216
|
+
Specifies the PyPI packages for the step.
|
217
|
+
|
218
|
+
Information in this decorator will augment any
|
219
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
220
|
+
you can use `@pypi_base` to set packages required by all
|
221
|
+
steps and use `@pypi` to specify step-specific overrides.
|
211
222
|
|
212
223
|
|
213
224
|
Parameters
|
214
225
|
----------
|
215
|
-
|
216
|
-
|
226
|
+
packages : Dict[str, str], default: {}
|
227
|
+
Packages to use for this step. The key is the name of the package
|
228
|
+
and the value is the version to use.
|
229
|
+
python : str, optional, default: None
|
230
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
231
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
217
232
|
"""
|
218
233
|
...
|
219
234
|
|
220
235
|
@typing.overload
|
221
|
-
def
|
236
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
222
237
|
...
|
223
238
|
|
224
239
|
@typing.overload
|
225
|
-
def
|
240
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
226
241
|
...
|
227
242
|
|
228
|
-
def
|
243
|
+
def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
229
244
|
"""
|
230
|
-
Specifies
|
245
|
+
Specifies the PyPI packages for the step.
|
246
|
+
|
247
|
+
Information in this decorator will augment any
|
248
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
249
|
+
you can use `@pypi_base` to set packages required by all
|
250
|
+
steps and use `@pypi` to specify step-specific overrides.
|
231
251
|
|
232
252
|
|
233
253
|
Parameters
|
234
254
|
----------
|
235
|
-
|
236
|
-
|
255
|
+
packages : Dict[str, str], default: {}
|
256
|
+
Packages to use for this step. The key is the name of the package
|
257
|
+
and the value is the version to use.
|
258
|
+
python : str, optional, default: None
|
259
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
260
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
237
261
|
"""
|
238
262
|
...
|
239
263
|
|
240
|
-
|
264
|
+
@typing.overload
|
265
|
+
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]]]:
|
241
266
|
"""
|
242
|
-
|
267
|
+
Specifies the resources needed when executing this step.
|
268
|
+
|
269
|
+
Use `@resources` to specify the resource requirements
|
270
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
271
|
+
|
272
|
+
You can choose the compute layer on the command line by executing e.g.
|
273
|
+
```
|
274
|
+
python myflow.py run --with batch
|
275
|
+
```
|
276
|
+
or
|
277
|
+
```
|
278
|
+
python myflow.py run --with kubernetes
|
279
|
+
```
|
280
|
+
which executes the flow on the desired system using the
|
281
|
+
requirements specified in `@resources`.
|
243
282
|
|
244
283
|
|
245
284
|
Parameters
|
246
285
|
----------
|
247
|
-
|
248
|
-
|
286
|
+
cpu : int, default 1
|
287
|
+
Number of CPUs required for this step.
|
288
|
+
gpu : int, optional, default None
|
289
|
+
Number of GPUs required for this step.
|
290
|
+
disk : int, optional, default None
|
291
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
292
|
+
memory : int, default 4096
|
293
|
+
Memory size (in MB) required for this step.
|
294
|
+
shared_memory : int, optional, default None
|
295
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
296
|
+
This parameter maps to the `--shm-size` option in Docker.
|
297
|
+
"""
|
298
|
+
...
|
299
|
+
|
300
|
+
@typing.overload
|
301
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
302
|
+
...
|
303
|
+
|
304
|
+
@typing.overload
|
305
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
306
|
+
...
|
307
|
+
|
308
|
+
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):
|
309
|
+
"""
|
310
|
+
Specifies the resources needed when executing this step.
|
249
311
|
|
250
|
-
|
251
|
-
|
312
|
+
Use `@resources` to specify the resource requirements
|
313
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
252
314
|
|
253
|
-
|
315
|
+
You can choose the compute layer on the command line by executing e.g.
|
316
|
+
```
|
317
|
+
python myflow.py run --with batch
|
318
|
+
```
|
319
|
+
or
|
320
|
+
```
|
321
|
+
python myflow.py run --with kubernetes
|
322
|
+
```
|
323
|
+
which executes the flow on the desired system using the
|
324
|
+
requirements specified in `@resources`.
|
254
325
|
|
255
|
-
- If repo (model/dataset) is not found in the datastore:
|
256
|
-
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
257
|
-
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
258
|
-
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
259
326
|
|
260
|
-
|
261
|
-
|
327
|
+
Parameters
|
328
|
+
----------
|
329
|
+
cpu : int, default 1
|
330
|
+
Number of CPUs required for this step.
|
331
|
+
gpu : int, optional, default None
|
332
|
+
Number of GPUs required for this step.
|
333
|
+
disk : int, optional, default None
|
334
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
335
|
+
memory : int, default 4096
|
336
|
+
Memory size (in MB) required for this step.
|
337
|
+
shared_memory : int, optional, default None
|
338
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
339
|
+
This parameter maps to the `--shm-size` option in Docker.
|
340
|
+
"""
|
341
|
+
...
|
342
|
+
|
343
|
+
@typing.overload
|
344
|
+
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]]]:
|
345
|
+
"""
|
346
|
+
Specifies a timeout for your step.
|
347
|
+
|
348
|
+
This decorator is useful if this step may hang indefinitely.
|
349
|
+
|
350
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
351
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
352
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
353
|
+
|
354
|
+
Note that all the values specified in parameters are added together so if you specify
|
355
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
356
|
+
|
357
|
+
|
358
|
+
Parameters
|
359
|
+
----------
|
360
|
+
seconds : int, default 0
|
361
|
+
Number of seconds to wait prior to timing out.
|
362
|
+
minutes : int, default 0
|
363
|
+
Number of minutes to wait prior to timing out.
|
364
|
+
hours : int, default 0
|
365
|
+
Number of hours to wait prior to timing out.
|
366
|
+
"""
|
367
|
+
...
|
368
|
+
|
369
|
+
@typing.overload
|
370
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
371
|
+
...
|
372
|
+
|
373
|
+
@typing.overload
|
374
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
375
|
+
...
|
376
|
+
|
377
|
+
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):
|
378
|
+
"""
|
379
|
+
Specifies a timeout for your step.
|
380
|
+
|
381
|
+
This decorator is useful if this step may hang indefinitely.
|
382
|
+
|
383
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
384
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
385
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
386
|
+
|
387
|
+
Note that all the values specified in parameters are added together so if you specify
|
388
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
389
|
+
|
390
|
+
|
391
|
+
Parameters
|
392
|
+
----------
|
393
|
+
seconds : int, default 0
|
394
|
+
Number of seconds to wait prior to timing out.
|
395
|
+
minutes : int, default 0
|
396
|
+
Number of minutes to wait prior to timing out.
|
397
|
+
hours : int, default 0
|
398
|
+
Number of hours to wait prior to timing out.
|
262
399
|
"""
|
263
400
|
...
|
264
401
|
|
@@ -334,377 +471,254 @@ def app_deploy(*, app_port: int, app_name: str) -> typing.Callable[[typing.Union
|
|
334
471
|
"""
|
335
472
|
...
|
336
473
|
|
337
|
-
|
474
|
+
@typing.overload
|
475
|
+
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]]]:
|
338
476
|
"""
|
339
|
-
|
340
|
-
|
341
|
-
User code call
|
342
|
-
-----------
|
343
|
-
@nim(
|
344
|
-
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
345
|
-
backend='managed'
|
346
|
-
)
|
347
|
-
|
348
|
-
Valid backend options
|
349
|
-
---------------------
|
350
|
-
- 'managed': Outerbounds selects a compute provider based on the model.
|
351
|
-
|
352
|
-
Valid model options
|
353
|
-
----------------
|
354
|
-
- 'meta/llama3-8b-instruct': 8B parameter model
|
355
|
-
- 'meta/llama3-70b-instruct': 70B parameter model
|
356
|
-
- any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
|
477
|
+
Specifies environment variables to be set prior to the execution of a step.
|
357
478
|
|
358
479
|
|
359
480
|
Parameters
|
360
481
|
----------
|
361
|
-
|
362
|
-
|
363
|
-
backend: str
|
364
|
-
Compute provider to run the NIM container.
|
365
|
-
queue_timeout : int
|
366
|
-
Time to keep the job in NVCF's queue.
|
482
|
+
vars : Dict[str, str], default {}
|
483
|
+
Dictionary of environment variables to set.
|
367
484
|
"""
|
368
485
|
...
|
369
486
|
|
370
|
-
|
371
|
-
|
372
|
-
Specifies that this step should execute on Kubernetes.
|
373
|
-
|
374
|
-
|
375
|
-
Parameters
|
376
|
-
----------
|
377
|
-
cpu : int, default 1
|
378
|
-
Number of CPUs required for this step. If `@resources` is
|
379
|
-
also present, the maximum value from all decorators is used.
|
380
|
-
memory : int, default 4096
|
381
|
-
Memory size (in MB) required for this step. If
|
382
|
-
`@resources` is also present, the maximum value from all decorators is
|
383
|
-
used.
|
384
|
-
disk : int, default 10240
|
385
|
-
Disk size (in MB) required for this step. If
|
386
|
-
`@resources` is also present, the maximum value from all decorators is
|
387
|
-
used.
|
388
|
-
image : str, optional, default None
|
389
|
-
Docker image to use when launching on Kubernetes. If not specified, and
|
390
|
-
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
391
|
-
not, a default Docker image mapping to the current version of Python is used.
|
392
|
-
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
393
|
-
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
394
|
-
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
395
|
-
Kubernetes service account to use when launching pod in Kubernetes.
|
396
|
-
secrets : List[str], optional, default None
|
397
|
-
Kubernetes secrets to use when launching pod in Kubernetes. These
|
398
|
-
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
399
|
-
in Metaflow configuration.
|
400
|
-
node_selector: Union[Dict[str,str], str], optional, default None
|
401
|
-
Kubernetes node selector(s) to apply to the pod running the task.
|
402
|
-
Can be passed in as a comma separated string of values e.g.
|
403
|
-
'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
|
404
|
-
{'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
|
405
|
-
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
406
|
-
Kubernetes namespace to use when launching pod in Kubernetes.
|
407
|
-
gpu : int, optional, default None
|
408
|
-
Number of GPUs required for this step. A value of zero implies that
|
409
|
-
the scheduled node should not have GPUs.
|
410
|
-
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
411
|
-
The vendor of the GPUs to be used for this step.
|
412
|
-
tolerations : List[str], default []
|
413
|
-
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
414
|
-
Kubernetes tolerations to use when launching pod in Kubernetes.
|
415
|
-
labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
|
416
|
-
Kubernetes labels to use when launching pod in Kubernetes.
|
417
|
-
annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
|
418
|
-
Kubernetes annotations to use when launching pod in Kubernetes.
|
419
|
-
use_tmpfs : bool, default False
|
420
|
-
This enables an explicit tmpfs mount for this step.
|
421
|
-
tmpfs_tempdir : bool, default True
|
422
|
-
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
423
|
-
tmpfs_size : int, optional, default: None
|
424
|
-
The value for the size (in MiB) of the tmpfs mount for this step.
|
425
|
-
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
426
|
-
memory allocated for this step.
|
427
|
-
tmpfs_path : str, optional, default /metaflow_temp
|
428
|
-
Path to tmpfs mount for this step.
|
429
|
-
persistent_volume_claims : Dict[str, str], optional, default None
|
430
|
-
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
431
|
-
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
432
|
-
shared_memory: int, optional
|
433
|
-
Shared memory size (in MiB) required for this step
|
434
|
-
port: int, optional
|
435
|
-
Port number to specify in the Kubernetes job object
|
436
|
-
compute_pool : str, optional, default None
|
437
|
-
Compute pool to be used for for this step.
|
438
|
-
If not specified, any accessible compute pool within the perimeter is used.
|
439
|
-
hostname_resolution_timeout: int, default 10 * 60
|
440
|
-
Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
|
441
|
-
Only applicable when @parallel is used.
|
442
|
-
qos: str, default: Burstable
|
443
|
-
Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
|
444
|
-
|
445
|
-
security_context: Dict[str, Any], optional, default None
|
446
|
-
Container security context. Applies to the task container. Allows the following keys:
|
447
|
-
- privileged: bool, optional, default None
|
448
|
-
- allow_privilege_escalation: bool, optional, default None
|
449
|
-
- run_as_user: int, optional, default None
|
450
|
-
- run_as_group: int, optional, default None
|
451
|
-
- run_as_non_root: bool, optional, default None
|
452
|
-
"""
|
487
|
+
@typing.overload
|
488
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
453
489
|
...
|
454
490
|
|
455
|
-
|
491
|
+
@typing.overload
|
492
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
493
|
+
...
|
494
|
+
|
495
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
456
496
|
"""
|
457
|
-
|
458
|
-
|
459
|
-
User code call
|
460
|
-
-----------
|
461
|
-
@ollama(
|
462
|
-
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
463
|
-
backend='local'
|
464
|
-
)
|
465
|
-
|
466
|
-
Valid backend options
|
467
|
-
---------------------
|
468
|
-
- 'local': Run as a separate process on the local task machine.
|
469
|
-
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
470
|
-
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
471
|
-
|
472
|
-
Valid model options
|
473
|
-
----------------
|
474
|
-
- 'llama3.2'
|
475
|
-
- 'llama3.3'
|
476
|
-
- any model here https://ollama.com/search
|
497
|
+
Specifies environment variables to be set prior to the execution of a step.
|
477
498
|
|
478
499
|
|
479
500
|
Parameters
|
480
501
|
----------
|
481
|
-
|
482
|
-
|
483
|
-
backend: str
|
484
|
-
Determines where and how to run the Ollama process.
|
502
|
+
vars : Dict[str, str], default {}
|
503
|
+
Dictionary of environment variables to set.
|
485
504
|
"""
|
486
505
|
...
|
487
506
|
|
488
507
|
@typing.overload
|
489
|
-
def
|
508
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
490
509
|
"""
|
491
|
-
|
510
|
+
Decorator prototype for all step decorators. This function gets specialized
|
511
|
+
and imported for all decorators types by _import_plugin_decorators().
|
492
512
|
"""
|
493
513
|
...
|
494
514
|
|
495
515
|
@typing.overload
|
496
|
-
def
|
516
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
497
517
|
...
|
498
518
|
|
499
|
-
def
|
519
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
500
520
|
"""
|
501
|
-
|
521
|
+
Decorator prototype for all step decorators. This function gets specialized
|
522
|
+
and imported for all decorators types by _import_plugin_decorators().
|
502
523
|
"""
|
503
524
|
...
|
504
525
|
|
505
526
|
@typing.overload
|
506
|
-
def
|
527
|
+
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]]]:
|
507
528
|
"""
|
508
|
-
Specifies the
|
529
|
+
Specifies the Conda environment for the step.
|
509
530
|
|
510
531
|
Information in this decorator will augment any
|
511
|
-
attributes set in the `@
|
512
|
-
you can use `@
|
513
|
-
steps and use `@
|
532
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
533
|
+
you can use `@conda_base` to set packages required by all
|
534
|
+
steps and use `@conda` to specify step-specific overrides.
|
514
535
|
|
515
536
|
|
516
537
|
Parameters
|
517
538
|
----------
|
518
|
-
packages : Dict[str, str], default
|
539
|
+
packages : Dict[str, str], default {}
|
519
540
|
Packages to use for this step. The key is the name of the package
|
520
541
|
and the value is the version to use.
|
521
|
-
|
542
|
+
libraries : Dict[str, str], default {}
|
543
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
544
|
+
python : str, optional, default None
|
522
545
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
523
546
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
547
|
+
disabled : bool, default False
|
548
|
+
If set to True, disables @conda.
|
524
549
|
"""
|
525
550
|
...
|
526
551
|
|
527
552
|
@typing.overload
|
528
|
-
def
|
553
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
529
554
|
...
|
530
555
|
|
531
556
|
@typing.overload
|
532
|
-
def
|
557
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
533
558
|
...
|
534
559
|
|
535
|
-
def
|
560
|
+
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):
|
536
561
|
"""
|
537
|
-
Specifies the
|
562
|
+
Specifies the Conda environment for the step.
|
538
563
|
|
539
564
|
Information in this decorator will augment any
|
540
|
-
attributes set in the `@
|
541
|
-
you can use `@
|
542
|
-
steps and use `@
|
565
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
566
|
+
you can use `@conda_base` to set packages required by all
|
567
|
+
steps and use `@conda` to specify step-specific overrides.
|
543
568
|
|
544
569
|
|
545
570
|
Parameters
|
546
571
|
----------
|
547
|
-
packages : Dict[str, str], default
|
572
|
+
packages : Dict[str, str], default {}
|
548
573
|
Packages to use for this step. The key is the name of the package
|
549
574
|
and the value is the version to use.
|
550
|
-
|
575
|
+
libraries : Dict[str, str], default {}
|
576
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
577
|
+
python : str, optional, default None
|
551
578
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
552
579
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
580
|
+
disabled : bool, default False
|
581
|
+
If set to True, disables @conda.
|
553
582
|
"""
|
554
583
|
...
|
555
584
|
|
556
585
|
@typing.overload
|
557
|
-
def
|
586
|
+
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]]]:
|
558
587
|
"""
|
559
|
-
Specifies
|
560
|
-
|
561
|
-
Use `@resources` to specify the resource requirements
|
562
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
563
|
-
|
564
|
-
You can choose the compute layer on the command line by executing e.g.
|
565
|
-
```
|
566
|
-
python myflow.py run --with batch
|
567
|
-
```
|
568
|
-
or
|
569
|
-
```
|
570
|
-
python myflow.py run --with kubernetes
|
571
|
-
```
|
572
|
-
which executes the flow on the desired system using the
|
573
|
-
requirements specified in `@resources`.
|
588
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
589
|
+
the execution of a step.
|
574
590
|
|
575
591
|
|
576
592
|
Parameters
|
577
593
|
----------
|
578
|
-
|
579
|
-
|
580
|
-
gpu : int, optional, default None
|
581
|
-
Number of GPUs required for this step.
|
582
|
-
disk : int, optional, default None
|
583
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
584
|
-
memory : int, default 4096
|
585
|
-
Memory size (in MB) required for this step.
|
586
|
-
shared_memory : int, optional, default None
|
587
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
588
|
-
This parameter maps to the `--shm-size` option in Docker.
|
594
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
595
|
+
List of secret specs, defining how the secrets are to be retrieved
|
589
596
|
"""
|
590
597
|
...
|
591
598
|
|
592
599
|
@typing.overload
|
593
|
-
def
|
600
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
594
601
|
...
|
595
602
|
|
596
603
|
@typing.overload
|
597
|
-
def
|
604
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
598
605
|
...
|
599
606
|
|
600
|
-
def
|
607
|
+
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]]] = []):
|
601
608
|
"""
|
602
|
-
Specifies
|
603
|
-
|
604
|
-
Use `@resources` to specify the resource requirements
|
605
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
606
|
-
|
607
|
-
You can choose the compute layer on the command line by executing e.g.
|
608
|
-
```
|
609
|
-
python myflow.py run --with batch
|
610
|
-
```
|
611
|
-
or
|
612
|
-
```
|
613
|
-
python myflow.py run --with kubernetes
|
614
|
-
```
|
615
|
-
which executes the flow on the desired system using the
|
616
|
-
requirements specified in `@resources`.
|
609
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
610
|
+
the execution of a step.
|
617
611
|
|
618
612
|
|
619
613
|
Parameters
|
620
614
|
----------
|
621
|
-
|
622
|
-
|
623
|
-
gpu : int, optional, default None
|
624
|
-
Number of GPUs required for this step.
|
625
|
-
disk : int, optional, default None
|
626
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
627
|
-
memory : int, default 4096
|
628
|
-
Memory size (in MB) required for this step.
|
629
|
-
shared_memory : int, optional, default None
|
630
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
631
|
-
This parameter maps to the `--shm-size` option in Docker.
|
615
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
616
|
+
List of secret specs, defining how the secrets are to be retrieved
|
632
617
|
"""
|
633
618
|
...
|
634
619
|
|
635
|
-
|
636
|
-
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]]]:
|
620
|
+
def ollama(*, models: "list[Ollama]", backend: 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]]]:
|
637
621
|
"""
|
638
|
-
|
622
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
623
|
+
|
624
|
+
User code call
|
625
|
+
-----------
|
626
|
+
@ollama(
|
627
|
+
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
628
|
+
backend='local'
|
629
|
+
)
|
630
|
+
|
631
|
+
Valid backend options
|
632
|
+
---------------------
|
633
|
+
- 'local': Run as a separate process on the local task machine.
|
634
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
635
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
639
636
|
|
637
|
+
Valid model options
|
638
|
+
----------------
|
639
|
+
- 'llama3.2'
|
640
|
+
- 'llama3.3'
|
641
|
+
- any model here https://ollama.com/search
|
640
642
|
|
641
643
|
|
642
644
|
Parameters
|
643
645
|
----------
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
will be loaded at the start of the task.
|
649
|
-
- "none": Do not load any checkpoint
|
650
|
-
- "fresh": Loads the lastest checkpoint created within the running Task.
|
651
|
-
This mode helps loading checkpoints across various retry attempts of the same task.
|
652
|
-
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
653
|
-
created within the task will be loaded when the task is retries execution on failure.
|
654
|
-
|
655
|
-
temp_dir_root : str, default: None
|
656
|
-
The root directory under which `current.checkpoint.directory` will be created.
|
646
|
+
models: list[Ollama]
|
647
|
+
List of Ollama containers running models in sidecars.
|
648
|
+
backend: str
|
649
|
+
Determines where and how to run the Ollama process.
|
657
650
|
"""
|
658
651
|
...
|
659
652
|
|
660
|
-
|
661
|
-
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
662
|
-
...
|
663
|
-
|
664
|
-
@typing.overload
|
665
|
-
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
666
|
-
...
|
667
|
-
|
668
|
-
def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load_policy: str = 'fresh', temp_dir_root: str = None):
|
653
|
+
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]]]:
|
669
654
|
"""
|
670
|
-
|
671
|
-
|
655
|
+
Specifies that this step should execute on DGX cloud.
|
672
656
|
|
673
657
|
|
674
658
|
Parameters
|
675
659
|
----------
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
will be loaded at the start of the task.
|
681
|
-
- "none": Do not load any checkpoint
|
682
|
-
- "fresh": Loads the lastest checkpoint created within the running Task.
|
683
|
-
This mode helps loading checkpoints across various retry attempts of the same task.
|
684
|
-
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
685
|
-
created within the task will be loaded when the task is retries execution on failure.
|
686
|
-
|
687
|
-
temp_dir_root : str, default: None
|
688
|
-
The root directory under which `current.checkpoint.directory` will be created.
|
660
|
+
gpu : int
|
661
|
+
Number of GPUs to use.
|
662
|
+
gpu_type : str
|
663
|
+
Type of Nvidia GPU to use.
|
689
664
|
"""
|
690
665
|
...
|
691
666
|
|
692
667
|
@typing.overload
|
693
|
-
def
|
668
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
694
669
|
"""
|
695
|
-
|
696
|
-
and imported for all decorators types by _import_plugin_decorators().
|
670
|
+
Internal decorator to support Fast bakery
|
697
671
|
"""
|
698
672
|
...
|
699
673
|
|
700
674
|
@typing.overload
|
701
|
-
def
|
675
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
702
676
|
...
|
703
677
|
|
704
|
-
def
|
678
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
705
679
|
"""
|
706
|
-
|
707
|
-
|
680
|
+
Internal decorator to support Fast bakery
|
681
|
+
"""
|
682
|
+
...
|
683
|
+
|
684
|
+
def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> 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]]]:
|
685
|
+
"""
|
686
|
+
Specifies that this step should execute on DGX cloud.
|
687
|
+
|
688
|
+
|
689
|
+
Parameters
|
690
|
+
----------
|
691
|
+
gpu : int
|
692
|
+
Number of GPUs to use.
|
693
|
+
gpu_type : str
|
694
|
+
Type of Nvidia GPU to use.
|
695
|
+
queue_timeout : int
|
696
|
+
Time to keep the job in NVCF's queue.
|
697
|
+
"""
|
698
|
+
...
|
699
|
+
|
700
|
+
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]]]:
|
701
|
+
"""
|
702
|
+
Decorator that helps cache, version and store models/datasets from huggingface hub.
|
703
|
+
|
704
|
+
|
705
|
+
Parameters
|
706
|
+
----------
|
707
|
+
temp_dir_root : str, optional
|
708
|
+
The root directory that will hold the temporary directory where objects will be downloaded.
|
709
|
+
|
710
|
+
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
711
|
+
The list of repos (models/datasets) to load.
|
712
|
+
|
713
|
+
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
714
|
+
|
715
|
+
- If repo (model/dataset) is not found in the datastore:
|
716
|
+
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
717
|
+
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
718
|
+
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
719
|
+
|
720
|
+
- If repo is found in the datastore:
|
721
|
+
- Loads it directly from datastore to local path (can be temporary directory or specified path)
|
708
722
|
"""
|
709
723
|
...
|
710
724
|
|
@@ -746,89 +760,98 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
|
|
746
760
|
|
747
761
|
Parameters
|
748
762
|
----------
|
749
|
-
type : str, default 'default'
|
750
|
-
Card type.
|
751
|
-
id : str, optional, default None
|
752
|
-
If multiple cards are present, use this id to identify this card.
|
753
|
-
options : Dict[str, Any], default {}
|
754
|
-
Options passed to the card. The contents depend on the card type.
|
755
|
-
timeout : int, default 45
|
756
|
-
Interrupt reporting if it takes more than this many seconds.
|
763
|
+
type : str, default 'default'
|
764
|
+
Card type.
|
765
|
+
id : str, optional, default None
|
766
|
+
If multiple cards are present, use this id to identify this card.
|
767
|
+
options : Dict[str, Any], default {}
|
768
|
+
Options passed to the card. The contents depend on the card type.
|
769
|
+
timeout : int, default 45
|
770
|
+
Interrupt reporting if it takes more than this many seconds.
|
771
|
+
"""
|
772
|
+
...
|
773
|
+
|
774
|
+
def nim(*, models: "list[NIM]", backend: str, queue_timeout: int) -> 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]]]:
|
775
|
+
"""
|
776
|
+
This decorator is used to run NIM containers in Metaflow tasks as sidecars.
|
777
|
+
|
778
|
+
User code call
|
779
|
+
-----------
|
780
|
+
@nim(
|
781
|
+
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
782
|
+
backend='managed'
|
783
|
+
)
|
784
|
+
|
785
|
+
Valid backend options
|
786
|
+
---------------------
|
787
|
+
- 'managed': Outerbounds selects a compute provider based on the model.
|
788
|
+
|
789
|
+
Valid model options
|
790
|
+
----------------
|
791
|
+
- 'meta/llama3-8b-instruct': 8B parameter model
|
792
|
+
- 'meta/llama3-70b-instruct': 70B parameter model
|
793
|
+
- any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
|
794
|
+
|
795
|
+
|
796
|
+
Parameters
|
797
|
+
----------
|
798
|
+
models: list[NIM]
|
799
|
+
List of NIM containers running models in sidecars.
|
800
|
+
backend: str
|
801
|
+
Compute provider to run the NIM container.
|
802
|
+
queue_timeout : int
|
803
|
+
Time to keep the job in NVCF's queue.
|
757
804
|
"""
|
758
805
|
...
|
759
806
|
|
760
807
|
@typing.overload
|
761
|
-
def
|
808
|
+
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]]]:
|
762
809
|
"""
|
763
|
-
Specifies the
|
810
|
+
Specifies that the step will success under all circumstances.
|
764
811
|
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
812
|
+
The decorator will create an optional artifact, specified by `var`, which
|
813
|
+
contains the exception raised. You can use it to detect the presence
|
814
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
815
|
+
are missing.
|
769
816
|
|
770
817
|
|
771
818
|
Parameters
|
772
819
|
----------
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
780
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
781
|
-
disabled : bool, default False
|
782
|
-
If set to True, disables @conda.
|
820
|
+
var : str, optional, default None
|
821
|
+
Name of the artifact in which to store the caught exception.
|
822
|
+
If not specified, the exception is not stored.
|
823
|
+
print_exception : bool, default True
|
824
|
+
Determines whether or not the exception is printed to
|
825
|
+
stdout when caught.
|
783
826
|
"""
|
784
827
|
...
|
785
828
|
|
786
829
|
@typing.overload
|
787
|
-
def
|
830
|
+
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
788
831
|
...
|
789
832
|
|
790
833
|
@typing.overload
|
791
|
-
def
|
834
|
+
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
792
835
|
...
|
793
836
|
|
794
|
-
def
|
837
|
+
def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, var: typing.Optional[str] = None, print_exception: bool = True):
|
795
838
|
"""
|
796
|
-
Specifies the
|
797
|
-
|
798
|
-
Information in this decorator will augment any
|
799
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
800
|
-
you can use `@conda_base` to set packages required by all
|
801
|
-
steps and use `@conda` to specify step-specific overrides.
|
802
|
-
|
839
|
+
Specifies that the step will success under all circumstances.
|
803
840
|
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
and the value is the version to use.
|
809
|
-
libraries : Dict[str, str], default {}
|
810
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
811
|
-
python : str, optional, default None
|
812
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
813
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
814
|
-
disabled : bool, default False
|
815
|
-
If set to True, disables @conda.
|
816
|
-
"""
|
817
|
-
...
|
818
|
-
|
819
|
-
def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> 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]]]:
|
820
|
-
"""
|
821
|
-
Specifies that this step should execute on DGX cloud.
|
841
|
+
The decorator will create an optional artifact, specified by `var`, which
|
842
|
+
contains the exception raised. You can use it to detect the presence
|
843
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
844
|
+
are missing.
|
822
845
|
|
823
846
|
|
824
847
|
Parameters
|
825
848
|
----------
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
849
|
+
var : str, optional, default None
|
850
|
+
Name of the artifact in which to store the caught exception.
|
851
|
+
If not specified, the exception is not stored.
|
852
|
+
print_exception : bool, default True
|
853
|
+
Determines whether or not the exception is printed to
|
854
|
+
stdout when caught.
|
832
855
|
"""
|
833
856
|
...
|
834
857
|
|
@@ -887,140 +910,139 @@ def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
887
910
|
"""
|
888
911
|
...
|
889
912
|
|
890
|
-
|
891
|
-
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]]]:
|
892
|
-
"""
|
893
|
-
Specifies a timeout for your step.
|
894
|
-
|
895
|
-
This decorator is useful if this step may hang indefinitely.
|
896
|
-
|
897
|
-
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
898
|
-
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
899
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
900
|
-
|
901
|
-
Note that all the values specified in parameters are added together so if you specify
|
902
|
-
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
903
|
-
|
904
|
-
|
905
|
-
Parameters
|
906
|
-
----------
|
907
|
-
seconds : int, default 0
|
908
|
-
Number of seconds to wait prior to timing out.
|
909
|
-
minutes : int, default 0
|
910
|
-
Number of minutes to wait prior to timing out.
|
911
|
-
hours : int, default 0
|
912
|
-
Number of hours to wait prior to timing out.
|
913
|
-
"""
|
914
|
-
...
|
915
|
-
|
916
|
-
@typing.overload
|
917
|
-
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
918
|
-
...
|
919
|
-
|
920
|
-
@typing.overload
|
921
|
-
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
922
|
-
...
|
923
|
-
|
924
|
-
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):
|
913
|
+
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', 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]]]:
|
925
914
|
"""
|
926
|
-
Specifies
|
927
|
-
|
928
|
-
This decorator is useful if this step may hang indefinitely.
|
929
|
-
|
930
|
-
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
931
|
-
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
932
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
933
|
-
|
934
|
-
Note that all the values specified in parameters are added together so if you specify
|
935
|
-
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
915
|
+
Specifies that this step should execute on Kubernetes.
|
936
916
|
|
937
917
|
|
938
918
|
Parameters
|
939
919
|
----------
|
940
|
-
|
941
|
-
Number of
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
920
|
+
cpu : int, default 1
|
921
|
+
Number of CPUs required for this step. If `@resources` is
|
922
|
+
also present, the maximum value from all decorators is used.
|
923
|
+
memory : int, default 4096
|
924
|
+
Memory size (in MB) required for this step. If
|
925
|
+
`@resources` is also present, the maximum value from all decorators is
|
926
|
+
used.
|
927
|
+
disk : int, default 10240
|
928
|
+
Disk size (in MB) required for this step. If
|
929
|
+
`@resources` is also present, the maximum value from all decorators is
|
930
|
+
used.
|
931
|
+
image : str, optional, default None
|
932
|
+
Docker image to use when launching on Kubernetes. If not specified, and
|
933
|
+
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
934
|
+
not, a default Docker image mapping to the current version of Python is used.
|
935
|
+
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
936
|
+
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
937
|
+
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
938
|
+
Kubernetes service account to use when launching pod in Kubernetes.
|
939
|
+
secrets : List[str], optional, default None
|
940
|
+
Kubernetes secrets to use when launching pod in Kubernetes. These
|
941
|
+
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
942
|
+
in Metaflow configuration.
|
943
|
+
node_selector: Union[Dict[str,str], str], optional, default None
|
944
|
+
Kubernetes node selector(s) to apply to the pod running the task.
|
945
|
+
Can be passed in as a comma separated string of values e.g.
|
946
|
+
'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
|
947
|
+
{'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
|
948
|
+
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
949
|
+
Kubernetes namespace to use when launching pod in Kubernetes.
|
950
|
+
gpu : int, optional, default None
|
951
|
+
Number of GPUs required for this step. A value of zero implies that
|
952
|
+
the scheduled node should not have GPUs.
|
953
|
+
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
954
|
+
The vendor of the GPUs to be used for this step.
|
955
|
+
tolerations : List[str], default []
|
956
|
+
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
957
|
+
Kubernetes tolerations to use when launching pod in Kubernetes.
|
958
|
+
labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
|
959
|
+
Kubernetes labels to use when launching pod in Kubernetes.
|
960
|
+
annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
|
961
|
+
Kubernetes annotations to use when launching pod in Kubernetes.
|
962
|
+
use_tmpfs : bool, default False
|
963
|
+
This enables an explicit tmpfs mount for this step.
|
964
|
+
tmpfs_tempdir : bool, default True
|
965
|
+
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
966
|
+
tmpfs_size : int, optional, default: None
|
967
|
+
The value for the size (in MiB) of the tmpfs mount for this step.
|
968
|
+
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
969
|
+
memory allocated for this step.
|
970
|
+
tmpfs_path : str, optional, default /metaflow_temp
|
971
|
+
Path to tmpfs mount for this step.
|
972
|
+
persistent_volume_claims : Dict[str, str], optional, default None
|
973
|
+
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
974
|
+
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
975
|
+
shared_memory: int, optional
|
976
|
+
Shared memory size (in MiB) required for this step
|
977
|
+
port: int, optional
|
978
|
+
Port number to specify in the Kubernetes job object
|
979
|
+
compute_pool : str, optional, default None
|
980
|
+
Compute pool to be used for for this step.
|
981
|
+
If not specified, any accessible compute pool within the perimeter is used.
|
982
|
+
hostname_resolution_timeout: int, default 10 * 60
|
983
|
+
Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
|
984
|
+
Only applicable when @parallel is used.
|
985
|
+
qos: str, default: Burstable
|
986
|
+
Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
|
955
987
|
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
988
|
+
security_context: Dict[str, Any], optional, default None
|
989
|
+
Container security context. Applies to the task container. Allows the following keys:
|
990
|
+
- privileged: bool, optional, default None
|
991
|
+
- allow_privilege_escalation: bool, optional, default None
|
992
|
+
- run_as_user: int, optional, default None
|
993
|
+
- run_as_group: int, optional, default None
|
994
|
+
- run_as_non_root: bool, optional, default None
|
960
995
|
"""
|
961
996
|
...
|
962
997
|
|
963
998
|
@typing.overload
|
964
|
-
def
|
965
|
-
...
|
966
|
-
|
967
|
-
@typing.overload
|
968
|
-
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
969
|
-
...
|
970
|
-
|
971
|
-
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]]] = []):
|
999
|
+
def schedule(*, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
972
1000
|
"""
|
973
|
-
Specifies
|
974
|
-
|
1001
|
+
Specifies the times when the flow should be run when running on a
|
1002
|
+
production scheduler.
|
975
1003
|
|
976
1004
|
|
977
1005
|
Parameters
|
978
1006
|
----------
|
979
|
-
|
980
|
-
|
1007
|
+
hourly : bool, default False
|
1008
|
+
Run the workflow hourly.
|
1009
|
+
daily : bool, default True
|
1010
|
+
Run the workflow daily.
|
1011
|
+
weekly : bool, default False
|
1012
|
+
Run the workflow weekly.
|
1013
|
+
cron : str, optional, default None
|
1014
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1015
|
+
specified by this expression.
|
1016
|
+
timezone : str, optional, default None
|
1017
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1018
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
981
1019
|
"""
|
982
1020
|
...
|
983
1021
|
|
984
|
-
|
1022
|
+
@typing.overload
|
1023
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1024
|
+
...
|
1025
|
+
|
1026
|
+
def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
|
985
1027
|
"""
|
986
|
-
|
987
|
-
|
988
|
-
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
989
|
-
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
990
|
-
starts only after all sensors finish.
|
1028
|
+
Specifies the times when the flow should be run when running on a
|
1029
|
+
production scheduler.
|
991
1030
|
|
992
1031
|
|
993
1032
|
Parameters
|
994
1033
|
----------
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1008
|
-
name : str
|
1009
|
-
Name of the sensor on Airflow
|
1010
|
-
description : str
|
1011
|
-
Description of sensor in the Airflow UI
|
1012
|
-
bucket_key : Union[str, List[str]]
|
1013
|
-
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1014
|
-
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1015
|
-
bucket_name : str
|
1016
|
-
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1017
|
-
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1018
|
-
wildcard_match : bool
|
1019
|
-
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1020
|
-
aws_conn_id : str
|
1021
|
-
a reference to the s3 connection on Airflow. (Default: None)
|
1022
|
-
verify : bool
|
1023
|
-
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1034
|
+
hourly : bool, default False
|
1035
|
+
Run the workflow hourly.
|
1036
|
+
daily : bool, default True
|
1037
|
+
Run the workflow daily.
|
1038
|
+
weekly : bool, default False
|
1039
|
+
Run the workflow weekly.
|
1040
|
+
cron : str, optional, default None
|
1041
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1042
|
+
specified by this expression.
|
1043
|
+
timezone : str, optional, default None
|
1044
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1045
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1024
1046
|
"""
|
1025
1047
|
...
|
1026
1048
|
|
@@ -1075,99 +1097,6 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
|
|
1075
1097
|
"""
|
1076
1098
|
...
|
1077
1099
|
|
1078
|
-
@typing.overload
|
1079
|
-
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]]:
|
1080
|
-
"""
|
1081
|
-
Specifies the event(s) that this flow depends on.
|
1082
|
-
|
1083
|
-
```
|
1084
|
-
@trigger(event='foo')
|
1085
|
-
```
|
1086
|
-
or
|
1087
|
-
```
|
1088
|
-
@trigger(events=['foo', 'bar'])
|
1089
|
-
```
|
1090
|
-
|
1091
|
-
Additionally, you can specify the parameter mappings
|
1092
|
-
to map event payload to Metaflow parameters for the flow.
|
1093
|
-
```
|
1094
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1095
|
-
```
|
1096
|
-
or
|
1097
|
-
```
|
1098
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1099
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1100
|
-
```
|
1101
|
-
|
1102
|
-
'parameters' can also be a list of strings and tuples like so:
|
1103
|
-
```
|
1104
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1105
|
-
```
|
1106
|
-
This is equivalent to:
|
1107
|
-
```
|
1108
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1109
|
-
```
|
1110
|
-
|
1111
|
-
|
1112
|
-
Parameters
|
1113
|
-
----------
|
1114
|
-
event : Union[str, Dict[str, Any]], optional, default None
|
1115
|
-
Event dependency for this flow.
|
1116
|
-
events : List[Union[str, Dict[str, Any]]], default []
|
1117
|
-
Events dependency for this flow.
|
1118
|
-
options : Dict[str, Any], default {}
|
1119
|
-
Backend-specific configuration for tuning eventing behavior.
|
1120
|
-
"""
|
1121
|
-
...
|
1122
|
-
|
1123
|
-
@typing.overload
|
1124
|
-
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1125
|
-
...
|
1126
|
-
|
1127
|
-
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] = {}):
|
1128
|
-
"""
|
1129
|
-
Specifies the event(s) that this flow depends on.
|
1130
|
-
|
1131
|
-
```
|
1132
|
-
@trigger(event='foo')
|
1133
|
-
```
|
1134
|
-
or
|
1135
|
-
```
|
1136
|
-
@trigger(events=['foo', 'bar'])
|
1137
|
-
```
|
1138
|
-
|
1139
|
-
Additionally, you can specify the parameter mappings
|
1140
|
-
to map event payload to Metaflow parameters for the flow.
|
1141
|
-
```
|
1142
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1143
|
-
```
|
1144
|
-
or
|
1145
|
-
```
|
1146
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1147
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1148
|
-
```
|
1149
|
-
|
1150
|
-
'parameters' can also be a list of strings and tuples like so:
|
1151
|
-
```
|
1152
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1153
|
-
```
|
1154
|
-
This is equivalent to:
|
1155
|
-
```
|
1156
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1157
|
-
```
|
1158
|
-
|
1159
|
-
|
1160
|
-
Parameters
|
1161
|
-
----------
|
1162
|
-
event : Union[str, Dict[str, Any]], optional, default None
|
1163
|
-
Event dependency for this flow.
|
1164
|
-
events : List[Union[str, Dict[str, Any]]], default []
|
1165
|
-
Events dependency for this flow.
|
1166
|
-
options : Dict[str, Any], default {}
|
1167
|
-
Backend-specific configuration for tuning eventing behavior.
|
1168
|
-
"""
|
1169
|
-
...
|
1170
|
-
|
1171
1100
|
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]]:
|
1172
1101
|
"""
|
1173
1102
|
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.
|
@@ -1211,6 +1140,120 @@ def airflow_external_task_sensor(*, timeout: int, poke_interval: int, mode: str,
|
|
1211
1140
|
"""
|
1212
1141
|
...
|
1213
1142
|
|
1143
|
+
def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
|
1144
|
+
"""
|
1145
|
+
Allows setting external datastores to save data for the
|
1146
|
+
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
1147
|
+
|
1148
|
+
This decorator is useful when users wish to save data to a different datastore
|
1149
|
+
than what is configured in Metaflow. This can be for variety of reasons:
|
1150
|
+
|
1151
|
+
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
1152
|
+
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
1153
|
+
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
1154
|
+
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
1155
|
+
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
1156
|
+
|
1157
|
+
Usage:
|
1158
|
+
----------
|
1159
|
+
|
1160
|
+
- Using a custom IAM role to access the datastore.
|
1161
|
+
|
1162
|
+
```python
|
1163
|
+
@with_artifact_store(
|
1164
|
+
type="s3",
|
1165
|
+
config=lambda: {
|
1166
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
1167
|
+
"role_arn": ROLE,
|
1168
|
+
},
|
1169
|
+
)
|
1170
|
+
class MyFlow(FlowSpec):
|
1171
|
+
|
1172
|
+
@checkpoint
|
1173
|
+
@step
|
1174
|
+
def start(self):
|
1175
|
+
with open("my_file.txt", "w") as f:
|
1176
|
+
f.write("Hello, World!")
|
1177
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1178
|
+
self.next(self.end)
|
1179
|
+
|
1180
|
+
```
|
1181
|
+
|
1182
|
+
- Using credentials to access the s3-compatible datastore.
|
1183
|
+
|
1184
|
+
```python
|
1185
|
+
@with_artifact_store(
|
1186
|
+
type="s3",
|
1187
|
+
config=lambda: {
|
1188
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
1189
|
+
"client_params": {
|
1190
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1191
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1192
|
+
},
|
1193
|
+
},
|
1194
|
+
)
|
1195
|
+
class MyFlow(FlowSpec):
|
1196
|
+
|
1197
|
+
@checkpoint
|
1198
|
+
@step
|
1199
|
+
def start(self):
|
1200
|
+
with open("my_file.txt", "w") as f:
|
1201
|
+
f.write("Hello, World!")
|
1202
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1203
|
+
self.next(self.end)
|
1204
|
+
|
1205
|
+
```
|
1206
|
+
|
1207
|
+
- Accessing objects stored in external datastores after task execution.
|
1208
|
+
|
1209
|
+
```python
|
1210
|
+
run = Run("CheckpointsTestsFlow/8992")
|
1211
|
+
with artifact_store_from(run=run, config={
|
1212
|
+
"client_params": {
|
1213
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1214
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1215
|
+
},
|
1216
|
+
}):
|
1217
|
+
with Checkpoint() as cp:
|
1218
|
+
latest = cp.list(
|
1219
|
+
task=run["start"].task
|
1220
|
+
)[0]
|
1221
|
+
print(latest)
|
1222
|
+
cp.load(
|
1223
|
+
latest,
|
1224
|
+
"test-checkpoints"
|
1225
|
+
)
|
1226
|
+
|
1227
|
+
task = Task("TorchTuneFlow/8484/train/53673")
|
1228
|
+
with artifact_store_from(run=run, config={
|
1229
|
+
"client_params": {
|
1230
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1231
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1232
|
+
},
|
1233
|
+
}):
|
1234
|
+
load_model(
|
1235
|
+
task.data.model_ref,
|
1236
|
+
"test-models"
|
1237
|
+
)
|
1238
|
+
```
|
1239
|
+
Parameters:
|
1240
|
+
----------
|
1241
|
+
|
1242
|
+
type: str
|
1243
|
+
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
1244
|
+
|
1245
|
+
config: dict or Callable
|
1246
|
+
Dictionary of configuration options for the datastore. The following keys are required:
|
1247
|
+
- root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
|
1248
|
+
- example: 's3://bucket-name/path/to/root'
|
1249
|
+
- example: 'gs://bucket-name/path/to/root'
|
1250
|
+
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
1251
|
+
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
1252
|
+
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
1253
|
+
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
1254
|
+
"""
|
1255
|
+
...
|
1256
|
+
|
1214
1257
|
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1215
1258
|
"""
|
1216
1259
|
Specifies what flows belong to the same project.
|
@@ -1348,167 +1391,138 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
|
|
1348
1391
|
...
|
1349
1392
|
|
1350
1393
|
@typing.overload
|
1351
|
-
def
|
1394
|
+
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]]:
|
1352
1395
|
"""
|
1353
|
-
Specifies the
|
1354
|
-
|
1396
|
+
Specifies the event(s) that this flow depends on.
|
1397
|
+
|
1398
|
+
```
|
1399
|
+
@trigger(event='foo')
|
1400
|
+
```
|
1401
|
+
or
|
1402
|
+
```
|
1403
|
+
@trigger(events=['foo', 'bar'])
|
1404
|
+
```
|
1405
|
+
|
1406
|
+
Additionally, you can specify the parameter mappings
|
1407
|
+
to map event payload to Metaflow parameters for the flow.
|
1408
|
+
```
|
1409
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1410
|
+
```
|
1411
|
+
or
|
1412
|
+
```
|
1413
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1414
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1415
|
+
```
|
1416
|
+
|
1417
|
+
'parameters' can also be a list of strings and tuples like so:
|
1418
|
+
```
|
1419
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1420
|
+
```
|
1421
|
+
This is equivalent to:
|
1422
|
+
```
|
1423
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1424
|
+
```
|
1355
1425
|
|
1356
1426
|
|
1357
1427
|
Parameters
|
1358
1428
|
----------
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
cron : str, optional, default None
|
1366
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1367
|
-
specified by this expression.
|
1368
|
-
timezone : str, optional, default None
|
1369
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1370
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1429
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
1430
|
+
Event dependency for this flow.
|
1431
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
1432
|
+
Events dependency for this flow.
|
1433
|
+
options : Dict[str, Any], default {}
|
1434
|
+
Backend-specific configuration for tuning eventing behavior.
|
1371
1435
|
"""
|
1372
1436
|
...
|
1373
1437
|
|
1374
1438
|
@typing.overload
|
1375
|
-
def
|
1439
|
+
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1376
1440
|
...
|
1377
1441
|
|
1378
|
-
def
|
1442
|
+
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] = {}):
|
1379
1443
|
"""
|
1380
|
-
Specifies the
|
1381
|
-
|
1444
|
+
Specifies the event(s) that this flow depends on.
|
1445
|
+
|
1446
|
+
```
|
1447
|
+
@trigger(event='foo')
|
1448
|
+
```
|
1449
|
+
or
|
1450
|
+
```
|
1451
|
+
@trigger(events=['foo', 'bar'])
|
1452
|
+
```
|
1453
|
+
|
1454
|
+
Additionally, you can specify the parameter mappings
|
1455
|
+
to map event payload to Metaflow parameters for the flow.
|
1456
|
+
```
|
1457
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1458
|
+
```
|
1459
|
+
or
|
1460
|
+
```
|
1461
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1462
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1463
|
+
```
|
1464
|
+
|
1465
|
+
'parameters' can also be a list of strings and tuples like so:
|
1466
|
+
```
|
1467
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1468
|
+
```
|
1469
|
+
This is equivalent to:
|
1470
|
+
```
|
1471
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1472
|
+
```
|
1382
1473
|
|
1383
1474
|
|
1384
1475
|
Parameters
|
1385
1476
|
----------
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
cron : str, optional, default None
|
1393
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1394
|
-
specified by this expression.
|
1395
|
-
timezone : str, optional, default None
|
1396
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1397
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1477
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
1478
|
+
Event dependency for this flow.
|
1479
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
1480
|
+
Events dependency for this flow.
|
1481
|
+
options : Dict[str, Any], default {}
|
1482
|
+
Backend-specific configuration for tuning eventing behavior.
|
1398
1483
|
"""
|
1399
1484
|
...
|
1400
1485
|
|
1401
|
-
def
|
1486
|
+
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]]:
|
1402
1487
|
"""
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
1410
|
-
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
1411
|
-
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
1412
|
-
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
1413
|
-
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
1414
|
-
|
1415
|
-
Usage:
|
1416
|
-
----------
|
1417
|
-
|
1418
|
-
- Using a custom IAM role to access the datastore.
|
1419
|
-
|
1420
|
-
```python
|
1421
|
-
@with_artifact_store(
|
1422
|
-
type="s3",
|
1423
|
-
config=lambda: {
|
1424
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
1425
|
-
"role_arn": ROLE,
|
1426
|
-
},
|
1427
|
-
)
|
1428
|
-
class MyFlow(FlowSpec):
|
1429
|
-
|
1430
|
-
@checkpoint
|
1431
|
-
@step
|
1432
|
-
def start(self):
|
1433
|
-
with open("my_file.txt", "w") as f:
|
1434
|
-
f.write("Hello, World!")
|
1435
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1436
|
-
self.next(self.end)
|
1437
|
-
|
1438
|
-
```
|
1439
|
-
|
1440
|
-
- Using credentials to access the s3-compatible datastore.
|
1441
|
-
|
1442
|
-
```python
|
1443
|
-
@with_artifact_store(
|
1444
|
-
type="s3",
|
1445
|
-
config=lambda: {
|
1446
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
1447
|
-
"client_params": {
|
1448
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1449
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1450
|
-
},
|
1451
|
-
},
|
1452
|
-
)
|
1453
|
-
class MyFlow(FlowSpec):
|
1454
|
-
|
1455
|
-
@checkpoint
|
1456
|
-
@step
|
1457
|
-
def start(self):
|
1458
|
-
with open("my_file.txt", "w") as f:
|
1459
|
-
f.write("Hello, World!")
|
1460
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1461
|
-
self.next(self.end)
|
1462
|
-
|
1463
|
-
```
|
1464
|
-
|
1465
|
-
- Accessing objects stored in external datastores after task execution.
|
1488
|
+
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)
|
1489
|
+
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1490
|
+
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1491
|
+
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1492
|
+
starts only after all sensors finish.
|
1466
1493
|
|
1467
|
-
```python
|
1468
|
-
run = Run("CheckpointsTestsFlow/8992")
|
1469
|
-
with artifact_store_from(run=run, config={
|
1470
|
-
"client_params": {
|
1471
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1472
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1473
|
-
},
|
1474
|
-
}):
|
1475
|
-
with Checkpoint() as cp:
|
1476
|
-
latest = cp.list(
|
1477
|
-
task=run["start"].task
|
1478
|
-
)[0]
|
1479
|
-
print(latest)
|
1480
|
-
cp.load(
|
1481
|
-
latest,
|
1482
|
-
"test-checkpoints"
|
1483
|
-
)
|
1484
1494
|
|
1485
|
-
|
1486
|
-
with artifact_store_from(run=run, config={
|
1487
|
-
"client_params": {
|
1488
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1489
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1490
|
-
},
|
1491
|
-
}):
|
1492
|
-
load_model(
|
1493
|
-
task.data.model_ref,
|
1494
|
-
"test-models"
|
1495
|
-
)
|
1496
|
-
```
|
1497
|
-
Parameters:
|
1495
|
+
Parameters
|
1498
1496
|
----------
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1497
|
+
timeout : int
|
1498
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1499
|
+
poke_interval : int
|
1500
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1501
|
+
mode : str
|
1502
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1503
|
+
exponential_backoff : bool
|
1504
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1505
|
+
pool : str
|
1506
|
+
the slot pool this task should run in,
|
1507
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1508
|
+
soft_fail : bool
|
1509
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1510
|
+
name : str
|
1511
|
+
Name of the sensor on Airflow
|
1512
|
+
description : str
|
1513
|
+
Description of sensor in the Airflow UI
|
1514
|
+
bucket_key : Union[str, List[str]]
|
1515
|
+
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1516
|
+
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1517
|
+
bucket_name : str
|
1518
|
+
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1519
|
+
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1520
|
+
wildcard_match : bool
|
1521
|
+
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1522
|
+
aws_conn_id : str
|
1523
|
+
a reference to the s3 connection on Airflow. (Default: None)
|
1524
|
+
verify : bool
|
1525
|
+
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1512
1526
|
"""
|
1513
1527
|
...
|
1514
1528
|
|