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