ob-metaflow-stubs 6.0.3.169__py2.py3-none-any.whl → 6.0.3.171__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 +676 -672
- metaflow-stubs/cards.pyi +1 -1
- metaflow-stubs/cli.pyi +1 -1
- metaflow-stubs/cli_components/__init__.pyi +1 -1
- metaflow-stubs/cli_components/utils.pyi +1 -1
- metaflow-stubs/client/__init__.pyi +1 -1
- metaflow-stubs/client/core.pyi +5 -5
- metaflow-stubs/client/filecache.pyi +2 -2
- metaflow-stubs/events.pyi +1 -1
- metaflow-stubs/exception.pyi +1 -1
- metaflow-stubs/flowspec.pyi +3 -3
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +2 -2
- metaflow-stubs/info_file.pyi +1 -1
- metaflow-stubs/metadata_provider/__init__.pyi +1 -1
- metaflow-stubs/metadata_provider/heartbeat.pyi +1 -1
- metaflow-stubs/metadata_provider/metadata.pyi +1 -1
- metaflow-stubs/metadata_provider/util.pyi +1 -1
- metaflow-stubs/metaflow_config.pyi +1 -1
- metaflow-stubs/metaflow_current.pyi +127 -127
- metaflow-stubs/metaflow_git.pyi +1 -1
- metaflow-stubs/mf_extensions/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +12 -0
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +30 -0
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +15 -7
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
- metaflow-stubs/multicore_utils.pyi +1 -1
- metaflow-stubs/parameters.pyi +2 -2
- metaflow-stubs/plugins/__init__.pyi +11 -11
- metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
- metaflow-stubs/plugins/airflow/exception.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
- metaflow-stubs/plugins/argo/__init__.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +1 -1
- metaflow-stubs/plugins/aws/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
- metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
- metaflow-stubs/plugins/azure/__init__.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
- metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/cards/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_client.pyi +2 -2
- metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
- metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/components.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
- metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
- metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
- metaflow-stubs/plugins/cards/exception.pyi +1 -1
- metaflow-stubs/plugins/catch_decorator.pyi +1 -1
- metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/local.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
- metaflow-stubs/plugins/debug_logger.pyi +1 -1
- metaflow-stubs/plugins/debug_monitor.pyi +1 -1
- metaflow-stubs/plugins/environment_decorator.pyi +1 -1
- metaflow-stubs/plugins/events_decorator.pyi +1 -1
- metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
- metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
- metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
- metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
- metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
- metaflow-stubs/plugins/ollama/__init__.pyi +17 -9
- metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
- metaflow-stubs/plugins/perimeters.pyi +1 -1
- metaflow-stubs/plugins/project_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_environment.pyi +1 -1
- metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
- metaflow-stubs/plugins/pypi/utils.pyi +1 -1
- metaflow-stubs/plugins/resources_decorator.pyi +1 -1
- metaflow-stubs/plugins/retry_decorator.pyi +1 -1
- metaflow-stubs/plugins/secrets/__init__.pyi +1 -1
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +1 -1
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
- metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/plugins/storage_executor.pyi +1 -1
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
- metaflow-stubs/plugins/timeout_decorator.pyi +1 -1
- metaflow-stubs/plugins/uv/__init__.pyi +1 -1
- metaflow-stubs/plugins/uv/uv_environment.pyi +1 -1
- metaflow-stubs/profilers/__init__.pyi +1 -1
- metaflow-stubs/pylint_wrapper.pyi +1 -1
- metaflow-stubs/runner/__init__.pyi +1 -1
- metaflow-stubs/runner/deployer.pyi +29 -29
- metaflow-stubs/runner/deployer_impl.pyi +1 -1
- metaflow-stubs/runner/metaflow_runner.pyi +1 -1
- metaflow-stubs/runner/nbdeploy.pyi +1 -1
- metaflow-stubs/runner/nbrun.pyi +1 -1
- metaflow-stubs/runner/subprocess_manager.pyi +1 -1
- metaflow-stubs/runner/utils.pyi +2 -2
- metaflow-stubs/system/__init__.pyi +1 -1
- metaflow-stubs/system/system_logger.pyi +1 -1
- metaflow-stubs/system/system_monitor.pyi +1 -1
- metaflow-stubs/tagging_util.pyi +1 -1
- metaflow-stubs/tuple_util.pyi +1 -1
- metaflow-stubs/user_configs/__init__.pyi +1 -1
- metaflow-stubs/user_configs/config_decorators.pyi +4 -4
- metaflow-stubs/user_configs/config_options.pyi +2 -2
- metaflow-stubs/user_configs/config_parameters.pyi +4 -4
- {ob_metaflow_stubs-6.0.3.169.dist-info → ob_metaflow_stubs-6.0.3.171.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.3.171.dist-info/RECORD +208 -0
- ob_metaflow_stubs-6.0.3.169.dist-info/RECORD +0 -206
- {ob_metaflow_stubs-6.0.3.169.dist-info → ob_metaflow_stubs-6.0.3.171.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.3.169.dist-info → ob_metaflow_stubs-6.0.3.171.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
######################################################################################################
|
2
2
|
# Auto-generated Metaflow stub file #
|
3
3
|
# MF version: 2.15.14.1+obcheckpoint(0.2.1);ob(v1) #
|
4
|
-
# Generated on 2025-05-
|
4
|
+
# Generated on 2025-05-27T00:40:42.234892 #
|
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
|
|
@@ -37,16 +37,16 @@ from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDec
|
|
37
37
|
from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
|
38
38
|
from . import tuple_util as tuple_util
|
39
39
|
from . import cards as cards
|
40
|
-
from . import metaflow_git as metaflow_git
|
41
40
|
from . import events as events
|
41
|
+
from . import metaflow_git as metaflow_git
|
42
42
|
from . import runner as runner
|
43
43
|
from . import plugins as plugins
|
44
44
|
from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
|
45
45
|
from . import includefile as includefile
|
46
46
|
from .includefile import IncludeFile as IncludeFile
|
47
|
-
from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
|
48
|
-
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
|
49
47
|
from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
|
48
|
+
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
|
49
|
+
from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
|
50
50
|
from . import client as client
|
51
51
|
from .client.core import namespace as namespace
|
52
52
|
from .client.core import get_namespace as get_namespace
|
@@ -154,195 +154,171 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
154
154
|
...
|
155
155
|
|
156
156
|
@typing.overload
|
157
|
-
def
|
157
|
+
def retry(*, times: int = 3, minutes_between_retries: int = 2) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
158
158
|
"""
|
159
|
-
Specifies
|
159
|
+
Specifies the number of times the task corresponding
|
160
|
+
to a step needs to be retried.
|
160
161
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
163
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
164
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
165
|
+
|
166
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
167
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
168
|
+
ensuring that the flow execution can continue.
|
165
169
|
|
166
170
|
|
167
171
|
Parameters
|
168
172
|
----------
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
Determines whether or not the exception is printed to
|
174
|
-
stdout when caught.
|
173
|
+
times : int, default 3
|
174
|
+
Number of times to retry this task.
|
175
|
+
minutes_between_retries : int, default 2
|
176
|
+
Number of minutes between retries.
|
175
177
|
"""
|
176
178
|
...
|
177
179
|
|
178
180
|
@typing.overload
|
179
|
-
def
|
181
|
+
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
180
182
|
...
|
181
183
|
|
182
184
|
@typing.overload
|
183
|
-
def
|
185
|
+
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
184
186
|
...
|
185
187
|
|
186
|
-
def
|
188
|
+
def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, times: int = 3, minutes_between_retries: int = 2):
|
187
189
|
"""
|
188
|
-
Specifies
|
190
|
+
Specifies the number of times the task corresponding
|
191
|
+
to a step needs to be retried.
|
189
192
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
193
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
194
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
195
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
196
|
+
|
197
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
198
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
199
|
+
ensuring that the flow execution can continue.
|
194
200
|
|
195
201
|
|
196
202
|
Parameters
|
197
203
|
----------
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
Determines whether or not the exception is printed to
|
203
|
-
stdout when caught.
|
204
|
+
times : int, default 3
|
205
|
+
Number of times to retry this task.
|
206
|
+
minutes_between_retries : int, default 2
|
207
|
+
Number of minutes between retries.
|
204
208
|
"""
|
205
209
|
...
|
206
210
|
|
207
211
|
@typing.overload
|
208
|
-
def
|
212
|
+
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]]]:
|
209
213
|
"""
|
210
|
-
|
211
|
-
|
214
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
215
|
+
the execution of a step.
|
212
216
|
|
213
217
|
|
214
218
|
Parameters
|
215
219
|
----------
|
216
|
-
|
217
|
-
|
218
|
-
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
219
|
-
- `current.checkpoint`
|
220
|
-
- `current.model`
|
221
|
-
- `current.huggingface_hub`
|
222
|
-
|
223
|
-
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
|
224
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
225
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
226
|
-
|
227
|
-
temp_dir_root : str, default: None
|
228
|
-
The root directory under which `current.model.loaded` will store loaded models
|
220
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
221
|
+
List of secret specs, defining how the secrets are to be retrieved
|
229
222
|
"""
|
230
223
|
...
|
231
224
|
|
232
225
|
@typing.overload
|
233
|
-
def
|
226
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
234
227
|
...
|
235
228
|
|
236
229
|
@typing.overload
|
237
|
-
def
|
230
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
238
231
|
...
|
239
232
|
|
240
|
-
def
|
233
|
+
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]]] = []):
|
241
234
|
"""
|
242
|
-
|
243
|
-
|
235
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
236
|
+
the execution of a step.
|
244
237
|
|
245
238
|
|
246
239
|
Parameters
|
247
240
|
----------
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
241
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
242
|
+
List of secret specs, defining how the secrets are to be retrieved
|
243
|
+
"""
|
244
|
+
...
|
245
|
+
|
246
|
+
@typing.overload
|
247
|
+
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]]]:
|
248
|
+
"""
|
249
|
+
Specifies the resources needed when executing this step.
|
254
250
|
|
255
|
-
|
256
|
-
|
257
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
251
|
+
Use `@resources` to specify the resource requirements
|
252
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
258
253
|
|
259
|
-
|
260
|
-
|
254
|
+
You can choose the compute layer on the command line by executing e.g.
|
255
|
+
```
|
256
|
+
python myflow.py run --with batch
|
257
|
+
```
|
258
|
+
or
|
259
|
+
```
|
260
|
+
python myflow.py run --with kubernetes
|
261
|
+
```
|
262
|
+
which executes the flow on the desired system using the
|
263
|
+
requirements specified in `@resources`.
|
264
|
+
|
265
|
+
|
266
|
+
Parameters
|
267
|
+
----------
|
268
|
+
cpu : int, default 1
|
269
|
+
Number of CPUs required for this step.
|
270
|
+
gpu : int, optional, default None
|
271
|
+
Number of GPUs required for this step.
|
272
|
+
disk : int, optional, default None
|
273
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
274
|
+
memory : int, default 4096
|
275
|
+
Memory size (in MB) required for this step.
|
276
|
+
shared_memory : int, optional, default None
|
277
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
278
|
+
This parameter maps to the `--shm-size` option in Docker.
|
261
279
|
"""
|
262
280
|
...
|
263
281
|
|
264
|
-
|
282
|
+
@typing.overload
|
283
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
284
|
+
...
|
285
|
+
|
286
|
+
@typing.overload
|
287
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
288
|
+
...
|
289
|
+
|
290
|
+
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):
|
265
291
|
"""
|
266
|
-
Specifies
|
292
|
+
Specifies the resources needed when executing this step.
|
293
|
+
|
294
|
+
Use `@resources` to specify the resource requirements
|
295
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
296
|
+
|
297
|
+
You can choose the compute layer on the command line by executing e.g.
|
298
|
+
```
|
299
|
+
python myflow.py run --with batch
|
300
|
+
```
|
301
|
+
or
|
302
|
+
```
|
303
|
+
python myflow.py run --with kubernetes
|
304
|
+
```
|
305
|
+
which executes the flow on the desired system using the
|
306
|
+
requirements specified in `@resources`.
|
267
307
|
|
268
308
|
|
269
309
|
Parameters
|
270
310
|
----------
|
271
311
|
cpu : int, default 1
|
272
|
-
Number of CPUs required for this step.
|
273
|
-
also present, the maximum value from all decorators is used.
|
274
|
-
memory : int, default 4096
|
275
|
-
Memory size (in MB) required for this step. If
|
276
|
-
`@resources` is also present, the maximum value from all decorators is
|
277
|
-
used.
|
278
|
-
disk : int, default 10240
|
279
|
-
Disk size (in MB) required for this step. If
|
280
|
-
`@resources` is also present, the maximum value from all decorators is
|
281
|
-
used.
|
282
|
-
image : str, optional, default None
|
283
|
-
Docker image to use when launching on Kubernetes. If not specified, and
|
284
|
-
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
285
|
-
not, a default Docker image mapping to the current version of Python is used.
|
286
|
-
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
287
|
-
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
288
|
-
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
289
|
-
Kubernetes service account to use when launching pod in Kubernetes.
|
290
|
-
secrets : List[str], optional, default None
|
291
|
-
Kubernetes secrets to use when launching pod in Kubernetes. These
|
292
|
-
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
293
|
-
in Metaflow configuration.
|
294
|
-
node_selector: Union[Dict[str,str], str], optional, default None
|
295
|
-
Kubernetes node selector(s) to apply to the pod running the task.
|
296
|
-
Can be passed in as a comma separated string of values e.g.
|
297
|
-
'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
|
298
|
-
{'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
|
299
|
-
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
300
|
-
Kubernetes namespace to use when launching pod in Kubernetes.
|
312
|
+
Number of CPUs required for this step.
|
301
313
|
gpu : int, optional, default None
|
302
|
-
Number of GPUs required for this step.
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
Kubernetes labels to use when launching pod in Kubernetes.
|
311
|
-
annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
|
312
|
-
Kubernetes annotations to use when launching pod in Kubernetes.
|
313
|
-
use_tmpfs : bool, default False
|
314
|
-
This enables an explicit tmpfs mount for this step.
|
315
|
-
tmpfs_tempdir : bool, default True
|
316
|
-
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
317
|
-
tmpfs_size : int, optional, default: None
|
318
|
-
The value for the size (in MiB) of the tmpfs mount for this step.
|
319
|
-
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
320
|
-
memory allocated for this step.
|
321
|
-
tmpfs_path : str, optional, default /metaflow_temp
|
322
|
-
Path to tmpfs mount for this step.
|
323
|
-
persistent_volume_claims : Dict[str, str], optional, default None
|
324
|
-
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
325
|
-
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
326
|
-
shared_memory: int, optional
|
327
|
-
Shared memory size (in MiB) required for this step
|
328
|
-
port: int, optional
|
329
|
-
Port number to specify in the Kubernetes job object
|
330
|
-
compute_pool : str, optional, default None
|
331
|
-
Compute pool to be used for for this step.
|
332
|
-
If not specified, any accessible compute pool within the perimeter is used.
|
333
|
-
hostname_resolution_timeout: int, default 10 * 60
|
334
|
-
Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
|
335
|
-
Only applicable when @parallel is used.
|
336
|
-
qos: str, default: Burstable
|
337
|
-
Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
|
338
|
-
|
339
|
-
security_context: Dict[str, Any], optional, default None
|
340
|
-
Container security context. Applies to the task container. Allows the following keys:
|
341
|
-
- privileged: bool, optional, default None
|
342
|
-
- allow_privilege_escalation: bool, optional, default None
|
343
|
-
- run_as_user: int, optional, default None
|
344
|
-
- run_as_group: int, optional, default None
|
345
|
-
- run_as_non_root: bool, optional, default None
|
314
|
+
Number of GPUs required for this step.
|
315
|
+
disk : int, optional, default None
|
316
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
317
|
+
memory : int, default 4096
|
318
|
+
Memory size (in MB) required for this step.
|
319
|
+
shared_memory : int, optional, default None
|
320
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
321
|
+
This parameter maps to the `--shm-size` option in Docker.
|
346
322
|
"""
|
347
323
|
...
|
348
324
|
|
@@ -430,195 +406,329 @@ def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.
|
|
430
406
|
"""
|
431
407
|
...
|
432
408
|
|
433
|
-
def
|
409
|
+
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]]]:
|
434
410
|
"""
|
435
|
-
Specifies that this step
|
411
|
+
Specifies that this step is used to deploy an instance of the app.
|
412
|
+
Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
|
436
413
|
|
437
414
|
|
438
415
|
Parameters
|
439
416
|
----------
|
440
|
-
|
417
|
+
app_port : int
|
441
418
|
Number of GPUs to use.
|
442
|
-
|
443
|
-
|
419
|
+
app_name : str
|
420
|
+
Name of the app to deploy.
|
421
|
+
"""
|
422
|
+
...
|
423
|
+
|
424
|
+
def ollama(*, models: list, backend: str, force_pull: bool, skip_push_check: bool, debug: bool) -> 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]]]:
|
425
|
+
"""
|
426
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
427
|
+
|
428
|
+
User code call
|
429
|
+
--------------
|
430
|
+
@ollama(
|
431
|
+
models=[...],
|
432
|
+
...
|
433
|
+
)
|
434
|
+
|
435
|
+
Valid backend options
|
436
|
+
---------------------
|
437
|
+
- 'local': Run as a separate process on the local task machine.
|
438
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
439
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
440
|
+
|
441
|
+
Valid model options
|
442
|
+
-------------------
|
443
|
+
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
444
|
+
|
445
|
+
|
446
|
+
Parameters
|
447
|
+
----------
|
448
|
+
models: list[str]
|
449
|
+
List of Ollama containers running models in sidecars.
|
450
|
+
backend: str
|
451
|
+
Determines where and how to run the Ollama process.
|
452
|
+
force_pull: bool
|
453
|
+
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
454
|
+
skip_push_check: bool
|
455
|
+
Whether to skip the check that populates/overwrites remote cache on terminating an ollama model.
|
456
|
+
debug: bool
|
457
|
+
Whether to turn on verbose debugging logs.
|
444
458
|
"""
|
445
459
|
...
|
446
460
|
|
447
461
|
@typing.overload
|
448
|
-
def
|
462
|
+
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]]]:
|
449
463
|
"""
|
450
|
-
|
464
|
+
Specifies environment variables to be set prior to the execution of a step.
|
465
|
+
|
466
|
+
|
467
|
+
Parameters
|
468
|
+
----------
|
469
|
+
vars : Dict[str, str], default {}
|
470
|
+
Dictionary of environment variables to set.
|
451
471
|
"""
|
452
472
|
...
|
453
473
|
|
454
474
|
@typing.overload
|
455
|
-
def
|
475
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
456
476
|
...
|
457
477
|
|
458
|
-
|
478
|
+
@typing.overload
|
479
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
480
|
+
...
|
481
|
+
|
482
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
459
483
|
"""
|
460
|
-
|
484
|
+
Specifies environment variables to be set prior to the execution of a step.
|
485
|
+
|
486
|
+
|
487
|
+
Parameters
|
488
|
+
----------
|
489
|
+
vars : Dict[str, str], default {}
|
490
|
+
Dictionary of environment variables to set.
|
461
491
|
"""
|
462
492
|
...
|
463
493
|
|
464
494
|
@typing.overload
|
465
|
-
def
|
495
|
+
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]]]:
|
466
496
|
"""
|
467
|
-
Specifies the
|
468
|
-
|
469
|
-
Use `@resources` to specify the resource requirements
|
470
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
497
|
+
Specifies the PyPI packages for the step.
|
471
498
|
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
or
|
477
|
-
```
|
478
|
-
python myflow.py run --with kubernetes
|
479
|
-
```
|
480
|
-
which executes the flow on the desired system using the
|
481
|
-
requirements specified in `@resources`.
|
499
|
+
Information in this decorator will augment any
|
500
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
501
|
+
you can use `@pypi_base` to set packages required by all
|
502
|
+
steps and use `@pypi` to specify step-specific overrides.
|
482
503
|
|
483
504
|
|
484
505
|
Parameters
|
485
506
|
----------
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
memory : int, default 4096
|
493
|
-
Memory size (in MB) required for this step.
|
494
|
-
shared_memory : int, optional, default None
|
495
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
496
|
-
This parameter maps to the `--shm-size` option in Docker.
|
507
|
+
packages : Dict[str, str], default: {}
|
508
|
+
Packages to use for this step. The key is the name of the package
|
509
|
+
and the value is the version to use.
|
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.
|
497
513
|
"""
|
498
514
|
...
|
499
515
|
|
500
516
|
@typing.overload
|
501
|
-
def
|
517
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
502
518
|
...
|
503
519
|
|
504
520
|
@typing.overload
|
505
|
-
def
|
521
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
506
522
|
...
|
507
523
|
|
508
|
-
def
|
524
|
+
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):
|
509
525
|
"""
|
510
|
-
Specifies the
|
526
|
+
Specifies the PyPI packages for the step.
|
511
527
|
|
512
|
-
|
513
|
-
|
528
|
+
Information in this decorator will augment any
|
529
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
530
|
+
you can use `@pypi_base` to set packages required by all
|
531
|
+
steps and use `@pypi` to specify step-specific overrides.
|
514
532
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
python
|
522
|
-
|
523
|
-
|
524
|
-
|
533
|
+
|
534
|
+
Parameters
|
535
|
+
----------
|
536
|
+
packages : Dict[str, str], default: {}
|
537
|
+
Packages to use for this step. The key is the name of the package
|
538
|
+
and the value is the version to use.
|
539
|
+
python : str, optional, default: None
|
540
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
541
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
542
|
+
"""
|
543
|
+
...
|
544
|
+
|
545
|
+
@typing.overload
|
546
|
+
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]]]:
|
547
|
+
"""
|
548
|
+
Specifies that the step will success under all circumstances.
|
549
|
+
|
550
|
+
The decorator will create an optional artifact, specified by `var`, which
|
551
|
+
contains the exception raised. You can use it to detect the presence
|
552
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
553
|
+
are missing.
|
525
554
|
|
526
555
|
|
527
556
|
Parameters
|
528
557
|
----------
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
memory : int, default 4096
|
536
|
-
Memory size (in MB) required for this step.
|
537
|
-
shared_memory : int, optional, default None
|
538
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
539
|
-
This parameter maps to the `--shm-size` option in Docker.
|
558
|
+
var : str, optional, default None
|
559
|
+
Name of the artifact in which to store the caught exception.
|
560
|
+
If not specified, the exception is not stored.
|
561
|
+
print_exception : bool, default True
|
562
|
+
Determines whether or not the exception is printed to
|
563
|
+
stdout when caught.
|
540
564
|
"""
|
541
565
|
...
|
542
566
|
|
543
|
-
|
567
|
+
@typing.overload
|
568
|
+
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
569
|
+
...
|
570
|
+
|
571
|
+
@typing.overload
|
572
|
+
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
573
|
+
...
|
574
|
+
|
575
|
+
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):
|
544
576
|
"""
|
545
|
-
Specifies that
|
577
|
+
Specifies that the step will success under all circumstances.
|
578
|
+
|
579
|
+
The decorator will create an optional artifact, specified by `var`, which
|
580
|
+
contains the exception raised. You can use it to detect the presence
|
581
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
582
|
+
are missing.
|
546
583
|
|
547
584
|
|
548
585
|
Parameters
|
549
586
|
----------
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
587
|
+
var : str, optional, default None
|
588
|
+
Name of the artifact in which to store the caught exception.
|
589
|
+
If not specified, the exception is not stored.
|
590
|
+
print_exception : bool, default True
|
591
|
+
Determines whether or not the exception is printed to
|
592
|
+
stdout when caught.
|
556
593
|
"""
|
557
594
|
...
|
558
595
|
|
559
596
|
@typing.overload
|
560
|
-
def
|
597
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
561
598
|
"""
|
562
|
-
|
599
|
+
Decorator prototype for all step decorators. This function gets specialized
|
600
|
+
and imported for all decorators types by _import_plugin_decorators().
|
601
|
+
"""
|
602
|
+
...
|
603
|
+
|
604
|
+
@typing.overload
|
605
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
606
|
+
...
|
607
|
+
|
608
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
609
|
+
"""
|
610
|
+
Decorator prototype for all step decorators. This function gets specialized
|
611
|
+
and imported for all decorators types by _import_plugin_decorators().
|
612
|
+
"""
|
613
|
+
...
|
614
|
+
|
615
|
+
@typing.overload
|
616
|
+
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]]]:
|
617
|
+
"""
|
618
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
619
|
+
|
620
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
563
621
|
|
564
622
|
|
565
623
|
Parameters
|
566
624
|
----------
|
567
|
-
|
568
|
-
|
625
|
+
type : str, default 'default'
|
626
|
+
Card type.
|
627
|
+
id : str, optional, default None
|
628
|
+
If multiple cards are present, use this id to identify this card.
|
629
|
+
options : Dict[str, Any], default {}
|
630
|
+
Options passed to the card. The contents depend on the card type.
|
631
|
+
timeout : int, default 45
|
632
|
+
Interrupt reporting if it takes more than this many seconds.
|
569
633
|
"""
|
570
634
|
...
|
571
635
|
|
572
636
|
@typing.overload
|
573
|
-
def
|
637
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
574
638
|
...
|
575
639
|
|
576
640
|
@typing.overload
|
577
|
-
def
|
641
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
578
642
|
...
|
579
643
|
|
580
|
-
def
|
644
|
+
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):
|
581
645
|
"""
|
582
|
-
|
646
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
647
|
+
|
648
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
583
649
|
|
584
650
|
|
585
651
|
Parameters
|
586
652
|
----------
|
587
|
-
|
588
|
-
|
653
|
+
type : str, default 'default'
|
654
|
+
Card type.
|
655
|
+
id : str, optional, default None
|
656
|
+
If multiple cards are present, use this id to identify this card.
|
657
|
+
options : Dict[str, Any], default {}
|
658
|
+
Options passed to the card. The contents depend on the card type.
|
659
|
+
timeout : int, default 45
|
660
|
+
Interrupt reporting if it takes more than this many seconds.
|
589
661
|
"""
|
590
662
|
...
|
591
663
|
|
592
|
-
|
664
|
+
@typing.overload
|
665
|
+
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]]]:
|
593
666
|
"""
|
594
|
-
|
667
|
+
Enables loading / saving of models within a step.
|
595
668
|
|
596
|
-
User code call
|
597
|
-
-----------
|
598
|
-
@ollama(
|
599
|
-
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
600
|
-
backend='local'
|
601
|
-
)
|
602
669
|
|
603
|
-
Valid backend options
|
604
|
-
---------------------
|
605
|
-
- 'local': Run as a separate process on the local task machine.
|
606
|
-
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
607
|
-
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
608
670
|
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
671
|
+
Parameters
|
672
|
+
----------
|
673
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
674
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
675
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
676
|
+
- `current.checkpoint`
|
677
|
+
- `current.model`
|
678
|
+
- `current.huggingface_hub`
|
679
|
+
|
680
|
+
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
|
681
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
682
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
683
|
+
|
684
|
+
temp_dir_root : str, default: None
|
685
|
+
The root directory under which `current.model.loaded` will store loaded models
|
686
|
+
"""
|
687
|
+
...
|
688
|
+
|
689
|
+
@typing.overload
|
690
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
691
|
+
...
|
692
|
+
|
693
|
+
@typing.overload
|
694
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
695
|
+
...
|
696
|
+
|
697
|
+
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):
|
698
|
+
"""
|
699
|
+
Enables loading / saving of models within a step.
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
Parameters
|
704
|
+
----------
|
705
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
706
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
707
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
708
|
+
- `current.checkpoint`
|
709
|
+
- `current.model`
|
710
|
+
- `current.huggingface_hub`
|
711
|
+
|
712
|
+
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
|
713
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
714
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
715
|
+
|
716
|
+
temp_dir_root : str, default: None
|
717
|
+
The root directory under which `current.model.loaded` will store loaded models
|
718
|
+
"""
|
719
|
+
...
|
720
|
+
|
721
|
+
def nvct(*, gpu: int, gpu_type: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
722
|
+
"""
|
723
|
+
Specifies that this step should execute on DGX cloud.
|
614
724
|
|
615
725
|
|
616
726
|
Parameters
|
617
727
|
----------
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
728
|
+
gpu : int
|
729
|
+
Number of GPUs to use.
|
730
|
+
gpu_type : str
|
731
|
+
Type of Nvidia GPU to use.
|
622
732
|
"""
|
623
733
|
...
|
624
734
|
|
@@ -681,38 +791,105 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
681
791
|
"""
|
682
792
|
...
|
683
793
|
|
684
|
-
|
685
|
-
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]]]:
|
794
|
+
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
686
795
|
"""
|
687
|
-
Specifies
|
688
|
-
the execution of a step.
|
796
|
+
Specifies that this step should execute on Kubernetes.
|
689
797
|
|
690
798
|
|
691
799
|
Parameters
|
692
800
|
----------
|
693
|
-
|
694
|
-
|
801
|
+
cpu : int, default 1
|
802
|
+
Number of CPUs required for this step. If `@resources` is
|
803
|
+
also present, the maximum value from all decorators is used.
|
804
|
+
memory : int, default 4096
|
805
|
+
Memory size (in MB) required for this step. If
|
806
|
+
`@resources` is also present, the maximum value from all decorators is
|
807
|
+
used.
|
808
|
+
disk : int, default 10240
|
809
|
+
Disk size (in MB) required for this step. If
|
810
|
+
`@resources` is also present, the maximum value from all decorators is
|
811
|
+
used.
|
812
|
+
image : str, optional, default None
|
813
|
+
Docker image to use when launching on Kubernetes. If not specified, and
|
814
|
+
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
815
|
+
not, a default Docker image mapping to the current version of Python is used.
|
816
|
+
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
817
|
+
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
818
|
+
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
819
|
+
Kubernetes service account to use when launching pod in Kubernetes.
|
820
|
+
secrets : List[str], optional, default None
|
821
|
+
Kubernetes secrets to use when launching pod in Kubernetes. These
|
822
|
+
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
823
|
+
in Metaflow configuration.
|
824
|
+
node_selector: Union[Dict[str,str], str], optional, default None
|
825
|
+
Kubernetes node selector(s) to apply to the pod running the task.
|
826
|
+
Can be passed in as a comma separated string of values e.g.
|
827
|
+
'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
|
828
|
+
{'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
|
829
|
+
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
830
|
+
Kubernetes namespace to use when launching pod in Kubernetes.
|
831
|
+
gpu : int, optional, default None
|
832
|
+
Number of GPUs required for this step. A value of zero implies that
|
833
|
+
the scheduled node should not have GPUs.
|
834
|
+
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
835
|
+
The vendor of the GPUs to be used for this step.
|
836
|
+
tolerations : List[str], default []
|
837
|
+
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
838
|
+
Kubernetes tolerations to use when launching pod in Kubernetes.
|
839
|
+
labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
|
840
|
+
Kubernetes labels to use when launching pod in Kubernetes.
|
841
|
+
annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
|
842
|
+
Kubernetes annotations to use when launching pod in Kubernetes.
|
843
|
+
use_tmpfs : bool, default False
|
844
|
+
This enables an explicit tmpfs mount for this step.
|
845
|
+
tmpfs_tempdir : bool, default True
|
846
|
+
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
847
|
+
tmpfs_size : int, optional, default: None
|
848
|
+
The value for the size (in MiB) of the tmpfs mount for this step.
|
849
|
+
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
850
|
+
memory allocated for this step.
|
851
|
+
tmpfs_path : str, optional, default /metaflow_temp
|
852
|
+
Path to tmpfs mount for this step.
|
853
|
+
persistent_volume_claims : Dict[str, str], optional, default None
|
854
|
+
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
855
|
+
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
856
|
+
shared_memory: int, optional
|
857
|
+
Shared memory size (in MiB) required for this step
|
858
|
+
port: int, optional
|
859
|
+
Port number to specify in the Kubernetes job object
|
860
|
+
compute_pool : str, optional, default None
|
861
|
+
Compute pool to be used for for this step.
|
862
|
+
If not specified, any accessible compute pool within the perimeter is used.
|
863
|
+
hostname_resolution_timeout: int, default 10 * 60
|
864
|
+
Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
|
865
|
+
Only applicable when @parallel is used.
|
866
|
+
qos: str, default: Burstable
|
867
|
+
Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
|
868
|
+
|
869
|
+
security_context: Dict[str, Any], optional, default None
|
870
|
+
Container security context. Applies to the task container. Allows the following keys:
|
871
|
+
- privileged: bool, optional, default None
|
872
|
+
- allow_privilege_escalation: bool, optional, default None
|
873
|
+
- run_as_user: int, optional, default None
|
874
|
+
- run_as_group: int, optional, default None
|
875
|
+
- run_as_non_root: bool, optional, default None
|
695
876
|
"""
|
696
877
|
...
|
697
878
|
|
698
879
|
@typing.overload
|
699
|
-
def
|
880
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
881
|
+
"""
|
882
|
+
Internal decorator to support Fast bakery
|
883
|
+
"""
|
700
884
|
...
|
701
885
|
|
702
886
|
@typing.overload
|
703
|
-
def
|
887
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
704
888
|
...
|
705
889
|
|
706
|
-
def
|
890
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
707
891
|
"""
|
708
|
-
|
709
|
-
the execution of a step.
|
710
|
-
|
711
|
-
|
712
|
-
Parameters
|
713
|
-
----------
|
714
|
-
sources : List[Union[str, Dict[str, Any]]], default: []
|
715
|
-
List of secret specs, defining how the secrets are to be retrieved
|
892
|
+
Internal decorator to support Fast bakery
|
716
893
|
"""
|
717
894
|
...
|
718
895
|
|
@@ -772,193 +949,141 @@ def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None
|
|
772
949
|
The root directory under which `current.checkpoint.directory` will be created.
|
773
950
|
"""
|
774
951
|
...
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
Creates a human-readable report, a Metaflow Card, after this step completes.
|
780
|
-
|
781
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
782
|
-
|
783
|
-
|
784
|
-
Parameters
|
785
|
-
----------
|
786
|
-
type : str, default 'default'
|
787
|
-
Card type.
|
788
|
-
id : str, optional, default None
|
789
|
-
If multiple cards are present, use this id to identify this card.
|
790
|
-
options : Dict[str, Any], default {}
|
791
|
-
Options passed to the card. The contents depend on the card type.
|
792
|
-
timeout : int, default 45
|
793
|
-
Interrupt reporting if it takes more than this many seconds.
|
794
|
-
"""
|
795
|
-
...
|
796
|
-
|
797
|
-
@typing.overload
|
798
|
-
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
799
|
-
...
|
800
|
-
|
801
|
-
@typing.overload
|
802
|
-
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
803
|
-
...
|
804
|
-
|
805
|
-
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):
|
806
|
-
"""
|
807
|
-
Creates a human-readable report, a Metaflow Card, after this step completes.
|
808
|
-
|
809
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
810
|
-
|
811
|
-
|
812
|
-
Parameters
|
813
|
-
----------
|
814
|
-
type : str, default 'default'
|
815
|
-
Card type.
|
816
|
-
id : str, optional, default None
|
817
|
-
If multiple cards are present, use this id to identify this card.
|
818
|
-
options : Dict[str, Any], default {}
|
819
|
-
Options passed to the card. The contents depend on the card type.
|
820
|
-
timeout : int, default 45
|
821
|
-
Interrupt reporting if it takes more than this many seconds.
|
822
|
-
"""
|
823
|
-
...
|
824
|
-
|
825
|
-
@typing.overload
|
826
|
-
def retry(*, times: int = 3, minutes_between_retries: int = 2) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
827
|
-
"""
|
828
|
-
Specifies the number of times the task corresponding
|
829
|
-
to a step needs to be retried.
|
830
|
-
|
831
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
832
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
833
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
834
|
-
|
835
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
836
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
837
|
-
ensuring that the flow execution can continue.
|
838
|
-
|
839
|
-
|
840
|
-
Parameters
|
841
|
-
----------
|
842
|
-
times : int, default 3
|
843
|
-
Number of times to retry this task.
|
844
|
-
minutes_between_retries : int, default 2
|
845
|
-
Number of minutes between retries.
|
846
|
-
"""
|
847
|
-
...
|
848
|
-
|
849
|
-
@typing.overload
|
850
|
-
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
851
|
-
...
|
852
|
-
|
853
|
-
@typing.overload
|
854
|
-
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
855
|
-
...
|
856
|
-
|
857
|
-
def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, times: int = 3, minutes_between_retries: int = 2):
|
858
|
-
"""
|
859
|
-
Specifies the number of times the task corresponding
|
860
|
-
to a step needs to be retried.
|
861
|
-
|
862
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
863
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
864
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
865
|
-
|
866
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
867
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
868
|
-
ensuring that the flow execution can continue.
|
869
|
-
|
870
|
-
|
871
|
-
Parameters
|
872
|
-
----------
|
873
|
-
times : int, default 3
|
874
|
-
Number of times to retry this task.
|
875
|
-
minutes_between_retries : int, default 2
|
876
|
-
Number of minutes between retries.
|
877
|
-
"""
|
878
|
-
...
|
879
|
-
|
880
|
-
@typing.overload
|
881
|
-
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]]]:
|
882
|
-
"""
|
883
|
-
Specifies the PyPI packages for the step.
|
884
|
-
|
885
|
-
Information in this decorator will augment any
|
886
|
-
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
887
|
-
you can use `@pypi_base` to set packages required by all
|
888
|
-
steps and use `@pypi` to specify step-specific overrides.
|
889
|
-
|
890
|
-
|
891
|
-
Parameters
|
892
|
-
----------
|
893
|
-
packages : Dict[str, str], default: {}
|
894
|
-
Packages to use for this step. The key is the name of the package
|
895
|
-
and the value is the version to use.
|
896
|
-
python : str, optional, default: None
|
897
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
898
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
899
|
-
"""
|
900
|
-
...
|
901
|
-
|
902
|
-
@typing.overload
|
903
|
-
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
904
|
-
...
|
905
|
-
|
906
|
-
@typing.overload
|
907
|
-
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
908
|
-
...
|
909
|
-
|
910
|
-
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):
|
911
|
-
"""
|
912
|
-
Specifies the PyPI packages for the step.
|
913
|
-
|
914
|
-
Information in this decorator will augment any
|
915
|
-
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
916
|
-
you can use `@pypi_base` to set packages required by all
|
917
|
-
steps and use `@pypi` to specify step-specific overrides.
|
952
|
+
|
953
|
+
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]]]:
|
954
|
+
"""
|
955
|
+
Specifies that this step should execute on DGX cloud.
|
918
956
|
|
919
957
|
|
920
958
|
Parameters
|
921
959
|
----------
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
960
|
+
gpu : int
|
961
|
+
Number of GPUs to use.
|
962
|
+
gpu_type : str
|
963
|
+
Type of Nvidia GPU to use.
|
964
|
+
queue_timeout : int
|
965
|
+
Time to keep the job in NVCF's queue.
|
928
966
|
"""
|
929
967
|
...
|
930
968
|
|
931
|
-
|
932
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
969
|
+
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]]:
|
933
970
|
"""
|
934
|
-
|
935
|
-
and
|
971
|
+
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.
|
972
|
+
This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
|
973
|
+
|
974
|
+
|
975
|
+
Parameters
|
976
|
+
----------
|
977
|
+
timeout : int
|
978
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
979
|
+
poke_interval : int
|
980
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
981
|
+
mode : str
|
982
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
983
|
+
exponential_backoff : bool
|
984
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
985
|
+
pool : str
|
986
|
+
the slot pool this task should run in,
|
987
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
988
|
+
soft_fail : bool
|
989
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
990
|
+
name : str
|
991
|
+
Name of the sensor on Airflow
|
992
|
+
description : str
|
993
|
+
Description of sensor in the Airflow UI
|
994
|
+
external_dag_id : str
|
995
|
+
The dag_id that contains the task you want to wait for.
|
996
|
+
external_task_ids : List[str]
|
997
|
+
The list of task_ids that you want to wait for.
|
998
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
999
|
+
allowed_states : List[str]
|
1000
|
+
Iterable of allowed states, (Default: ['success'])
|
1001
|
+
failed_states : List[str]
|
1002
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
1003
|
+
execution_delta : datetime.timedelta
|
1004
|
+
time difference with the previous execution to look at,
|
1005
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
1006
|
+
check_existence: bool
|
1007
|
+
Set to True to check if the external task exists or check if
|
1008
|
+
the DAG to wait for exists. (Default: True)
|
936
1009
|
"""
|
937
1010
|
...
|
938
1011
|
|
939
|
-
|
940
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
941
|
-
...
|
942
|
-
|
943
|
-
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
1012
|
+
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
944
1013
|
"""
|
945
|
-
|
946
|
-
|
1014
|
+
Specifies what flows belong to the same project.
|
1015
|
+
|
1016
|
+
A project-specific namespace is created for all flows that
|
1017
|
+
use the same `@project(name)`.
|
1018
|
+
|
1019
|
+
|
1020
|
+
Parameters
|
1021
|
+
----------
|
1022
|
+
name : str
|
1023
|
+
Project name. Make sure that the name is unique amongst all
|
1024
|
+
projects that use the same production scheduler. The name may
|
1025
|
+
contain only lowercase alphanumeric characters and underscores.
|
1026
|
+
|
1027
|
+
branch : Optional[str], default None
|
1028
|
+
The branch to use. If not specified, the branch is set to
|
1029
|
+
`user.<username>` unless `production` is set to `True`. This can
|
1030
|
+
also be set on the command line using `--branch` as a top-level option.
|
1031
|
+
It is an error to specify `branch` in the decorator and on the command line.
|
1032
|
+
|
1033
|
+
production : bool, default False
|
1034
|
+
Whether or not the branch is the production branch. This can also be set on the
|
1035
|
+
command line using `--production` as a top-level option. It is an error to specify
|
1036
|
+
`production` in the decorator and on the command line.
|
1037
|
+
The project branch name will be:
|
1038
|
+
- if `branch` is specified:
|
1039
|
+
- if `production` is True: `prod.<branch>`
|
1040
|
+
- if `production` is False: `test.<branch>`
|
1041
|
+
- if `branch` is not specified:
|
1042
|
+
- if `production` is True: `prod`
|
1043
|
+
- if `production` is False: `user.<username>`
|
947
1044
|
"""
|
948
1045
|
...
|
949
1046
|
|
950
|
-
def
|
1047
|
+
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]]:
|
951
1048
|
"""
|
952
|
-
|
953
|
-
|
1049
|
+
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)
|
1050
|
+
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1051
|
+
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1052
|
+
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1053
|
+
starts only after all sensors finish.
|
954
1054
|
|
955
1055
|
|
956
1056
|
Parameters
|
957
1057
|
----------
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
1058
|
+
timeout : int
|
1059
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1060
|
+
poke_interval : int
|
1061
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1062
|
+
mode : str
|
1063
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1064
|
+
exponential_backoff : bool
|
1065
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1066
|
+
pool : str
|
1067
|
+
the slot pool this task should run in,
|
1068
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1069
|
+
soft_fail : bool
|
1070
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1071
|
+
name : str
|
1072
|
+
Name of the sensor on Airflow
|
1073
|
+
description : str
|
1074
|
+
Description of sensor in the Airflow UI
|
1075
|
+
bucket_key : Union[str, List[str]]
|
1076
|
+
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1077
|
+
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1078
|
+
bucket_name : str
|
1079
|
+
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1080
|
+
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1081
|
+
wildcard_match : bool
|
1082
|
+
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1083
|
+
aws_conn_id : str
|
1084
|
+
a reference to the s3 connection on Airflow. (Default: None)
|
1085
|
+
verify : bool
|
1086
|
+
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
962
1087
|
"""
|
963
1088
|
...
|
964
1089
|
|
@@ -1091,18 +1216,132 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
|
|
1091
1216
|
steps and use `@conda` to specify step-specific additions.
|
1092
1217
|
|
1093
1218
|
|
1094
|
-
Parameters
|
1095
|
-
----------
|
1096
|
-
packages : Dict[str, str], default {}
|
1097
|
-
Packages to use for this flow. The key is the name of the package
|
1098
|
-
and the value is the version to use.
|
1099
|
-
libraries : Dict[str, str], default {}
|
1100
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1101
|
-
python : str, optional, default None
|
1102
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1103
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1104
|
-
disabled : bool, default False
|
1105
|
-
If set to True, disables Conda.
|
1219
|
+
Parameters
|
1220
|
+
----------
|
1221
|
+
packages : Dict[str, str], default {}
|
1222
|
+
Packages to use for this flow. The key is the name of the package
|
1223
|
+
and the value is the version to use.
|
1224
|
+
libraries : Dict[str, str], default {}
|
1225
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1226
|
+
python : str, optional, default None
|
1227
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1228
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1229
|
+
disabled : bool, default False
|
1230
|
+
If set to True, disables Conda.
|
1231
|
+
"""
|
1232
|
+
...
|
1233
|
+
|
1234
|
+
def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
|
1235
|
+
"""
|
1236
|
+
Allows setting external datastores to save data for the
|
1237
|
+
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
1238
|
+
|
1239
|
+
This decorator is useful when users wish to save data to a different datastore
|
1240
|
+
than what is configured in Metaflow. This can be for variety of reasons:
|
1241
|
+
|
1242
|
+
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
1243
|
+
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
1244
|
+
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
1245
|
+
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
1246
|
+
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
1247
|
+
|
1248
|
+
Usage:
|
1249
|
+
----------
|
1250
|
+
|
1251
|
+
- Using a custom IAM role to access the datastore.
|
1252
|
+
|
1253
|
+
```python
|
1254
|
+
@with_artifact_store(
|
1255
|
+
type="s3",
|
1256
|
+
config=lambda: {
|
1257
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
1258
|
+
"role_arn": ROLE,
|
1259
|
+
},
|
1260
|
+
)
|
1261
|
+
class MyFlow(FlowSpec):
|
1262
|
+
|
1263
|
+
@checkpoint
|
1264
|
+
@step
|
1265
|
+
def start(self):
|
1266
|
+
with open("my_file.txt", "w") as f:
|
1267
|
+
f.write("Hello, World!")
|
1268
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1269
|
+
self.next(self.end)
|
1270
|
+
|
1271
|
+
```
|
1272
|
+
|
1273
|
+
- Using credentials to access the s3-compatible datastore.
|
1274
|
+
|
1275
|
+
```python
|
1276
|
+
@with_artifact_store(
|
1277
|
+
type="s3",
|
1278
|
+
config=lambda: {
|
1279
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
1280
|
+
"client_params": {
|
1281
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1282
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1283
|
+
},
|
1284
|
+
},
|
1285
|
+
)
|
1286
|
+
class MyFlow(FlowSpec):
|
1287
|
+
|
1288
|
+
@checkpoint
|
1289
|
+
@step
|
1290
|
+
def start(self):
|
1291
|
+
with open("my_file.txt", "w") as f:
|
1292
|
+
f.write("Hello, World!")
|
1293
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1294
|
+
self.next(self.end)
|
1295
|
+
|
1296
|
+
```
|
1297
|
+
|
1298
|
+
- Accessing objects stored in external datastores after task execution.
|
1299
|
+
|
1300
|
+
```python
|
1301
|
+
run = Run("CheckpointsTestsFlow/8992")
|
1302
|
+
with artifact_store_from(run=run, config={
|
1303
|
+
"client_params": {
|
1304
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1305
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1306
|
+
},
|
1307
|
+
}):
|
1308
|
+
with Checkpoint() as cp:
|
1309
|
+
latest = cp.list(
|
1310
|
+
task=run["start"].task
|
1311
|
+
)[0]
|
1312
|
+
print(latest)
|
1313
|
+
cp.load(
|
1314
|
+
latest,
|
1315
|
+
"test-checkpoints"
|
1316
|
+
)
|
1317
|
+
|
1318
|
+
task = Task("TorchTuneFlow/8484/train/53673")
|
1319
|
+
with artifact_store_from(run=run, config={
|
1320
|
+
"client_params": {
|
1321
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1322
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1323
|
+
},
|
1324
|
+
}):
|
1325
|
+
load_model(
|
1326
|
+
task.data.model_ref,
|
1327
|
+
"test-models"
|
1328
|
+
)
|
1329
|
+
```
|
1330
|
+
Parameters:
|
1331
|
+
----------
|
1332
|
+
|
1333
|
+
type: str
|
1334
|
+
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
1335
|
+
|
1336
|
+
config: dict or Callable
|
1337
|
+
Dictionary of configuration options for the datastore. The following keys are required:
|
1338
|
+
- root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
|
1339
|
+
- example: 's3://bucket-name/path/to/root'
|
1340
|
+
- example: 'gs://bucket-name/path/to/root'
|
1341
|
+
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
1342
|
+
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
1343
|
+
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
1344
|
+
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
1106
1345
|
"""
|
1107
1346
|
...
|
1108
1347
|
|
@@ -1147,127 +1386,6 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
|
|
1147
1386
|
"""
|
1148
1387
|
...
|
1149
1388
|
|
1150
|
-
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1151
|
-
"""
|
1152
|
-
Specifies what flows belong to the same project.
|
1153
|
-
|
1154
|
-
A project-specific namespace is created for all flows that
|
1155
|
-
use the same `@project(name)`.
|
1156
|
-
|
1157
|
-
|
1158
|
-
Parameters
|
1159
|
-
----------
|
1160
|
-
name : str
|
1161
|
-
Project name. Make sure that the name is unique amongst all
|
1162
|
-
projects that use the same production scheduler. The name may
|
1163
|
-
contain only lowercase alphanumeric characters and underscores.
|
1164
|
-
|
1165
|
-
branch : Optional[str], default None
|
1166
|
-
The branch to use. If not specified, the branch is set to
|
1167
|
-
`user.<username>` unless `production` is set to `True`. This can
|
1168
|
-
also be set on the command line using `--branch` as a top-level option.
|
1169
|
-
It is an error to specify `branch` in the decorator and on the command line.
|
1170
|
-
|
1171
|
-
production : bool, default False
|
1172
|
-
Whether or not the branch is the production branch. This can also be set on the
|
1173
|
-
command line using `--production` as a top-level option. It is an error to specify
|
1174
|
-
`production` in the decorator and on the command line.
|
1175
|
-
The project branch name will be:
|
1176
|
-
- if `branch` is specified:
|
1177
|
-
- if `production` is True: `prod.<branch>`
|
1178
|
-
- if `production` is False: `test.<branch>`
|
1179
|
-
- if `branch` is not specified:
|
1180
|
-
- if `production` is True: `prod`
|
1181
|
-
- if `production` is False: `user.<username>`
|
1182
|
-
"""
|
1183
|
-
...
|
1184
|
-
|
1185
|
-
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]]:
|
1186
|
-
"""
|
1187
|
-
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)
|
1188
|
-
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1189
|
-
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1190
|
-
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1191
|
-
starts only after all sensors finish.
|
1192
|
-
|
1193
|
-
|
1194
|
-
Parameters
|
1195
|
-
----------
|
1196
|
-
timeout : int
|
1197
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
1198
|
-
poke_interval : int
|
1199
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
1200
|
-
mode : str
|
1201
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1202
|
-
exponential_backoff : bool
|
1203
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1204
|
-
pool : str
|
1205
|
-
the slot pool this task should run in,
|
1206
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1207
|
-
soft_fail : bool
|
1208
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1209
|
-
name : str
|
1210
|
-
Name of the sensor on Airflow
|
1211
|
-
description : str
|
1212
|
-
Description of sensor in the Airflow UI
|
1213
|
-
bucket_key : Union[str, List[str]]
|
1214
|
-
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1215
|
-
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1216
|
-
bucket_name : str
|
1217
|
-
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1218
|
-
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1219
|
-
wildcard_match : bool
|
1220
|
-
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1221
|
-
aws_conn_id : str
|
1222
|
-
a reference to the s3 connection on Airflow. (Default: None)
|
1223
|
-
verify : bool
|
1224
|
-
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1225
|
-
"""
|
1226
|
-
...
|
1227
|
-
|
1228
|
-
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]]:
|
1229
|
-
"""
|
1230
|
-
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.
|
1231
|
-
This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
|
1232
|
-
|
1233
|
-
|
1234
|
-
Parameters
|
1235
|
-
----------
|
1236
|
-
timeout : int
|
1237
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
1238
|
-
poke_interval : int
|
1239
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
1240
|
-
mode : str
|
1241
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1242
|
-
exponential_backoff : bool
|
1243
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1244
|
-
pool : str
|
1245
|
-
the slot pool this task should run in,
|
1246
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1247
|
-
soft_fail : bool
|
1248
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1249
|
-
name : str
|
1250
|
-
Name of the sensor on Airflow
|
1251
|
-
description : str
|
1252
|
-
Description of sensor in the Airflow UI
|
1253
|
-
external_dag_id : str
|
1254
|
-
The dag_id that contains the task you want to wait for.
|
1255
|
-
external_task_ids : List[str]
|
1256
|
-
The list of task_ids that you want to wait for.
|
1257
|
-
If None (default value) the sensor waits for the DAG. (Default: None)
|
1258
|
-
allowed_states : List[str]
|
1259
|
-
Iterable of allowed states, (Default: ['success'])
|
1260
|
-
failed_states : List[str]
|
1261
|
-
Iterable of failed or dis-allowed states. (Default: None)
|
1262
|
-
execution_delta : datetime.timedelta
|
1263
|
-
time difference with the previous execution to look at,
|
1264
|
-
the default is the same logical date as the current task or DAG. (Default: None)
|
1265
|
-
check_existence: bool
|
1266
|
-
Set to True to check if the external task exists or check if
|
1267
|
-
the DAG to wait for exists. (Default: True)
|
1268
|
-
"""
|
1269
|
-
...
|
1270
|
-
|
1271
1389
|
@typing.overload
|
1272
1390
|
def trigger_on_finish(*, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1273
1391
|
"""
|
@@ -1420,119 +1538,5 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
|
|
1420
1538
|
"""
|
1421
1539
|
...
|
1422
1540
|
|
1423
|
-
def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
|
1424
|
-
"""
|
1425
|
-
Allows setting external datastores to save data for the
|
1426
|
-
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
1427
|
-
|
1428
|
-
This decorator is useful when users wish to save data to a different datastore
|
1429
|
-
than what is configured in Metaflow. This can be for variety of reasons:
|
1430
|
-
|
1431
|
-
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
1432
|
-
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
1433
|
-
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
1434
|
-
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
1435
|
-
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
1436
|
-
|
1437
|
-
Usage:
|
1438
|
-
----------
|
1439
|
-
|
1440
|
-
- Using a custom IAM role to access the datastore.
|
1441
|
-
|
1442
|
-
```python
|
1443
|
-
@with_artifact_store(
|
1444
|
-
type="s3",
|
1445
|
-
config=lambda: {
|
1446
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
1447
|
-
"role_arn": ROLE,
|
1448
|
-
},
|
1449
|
-
)
|
1450
|
-
class MyFlow(FlowSpec):
|
1451
|
-
|
1452
|
-
@checkpoint
|
1453
|
-
@step
|
1454
|
-
def start(self):
|
1455
|
-
with open("my_file.txt", "w") as f:
|
1456
|
-
f.write("Hello, World!")
|
1457
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1458
|
-
self.next(self.end)
|
1459
|
-
|
1460
|
-
```
|
1461
|
-
|
1462
|
-
- Using credentials to access the s3-compatible datastore.
|
1463
|
-
|
1464
|
-
```python
|
1465
|
-
@with_artifact_store(
|
1466
|
-
type="s3",
|
1467
|
-
config=lambda: {
|
1468
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
1469
|
-
"client_params": {
|
1470
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1471
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1472
|
-
},
|
1473
|
-
},
|
1474
|
-
)
|
1475
|
-
class MyFlow(FlowSpec):
|
1476
|
-
|
1477
|
-
@checkpoint
|
1478
|
-
@step
|
1479
|
-
def start(self):
|
1480
|
-
with open("my_file.txt", "w") as f:
|
1481
|
-
f.write("Hello, World!")
|
1482
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
1483
|
-
self.next(self.end)
|
1484
|
-
|
1485
|
-
```
|
1486
|
-
|
1487
|
-
- Accessing objects stored in external datastores after task execution.
|
1488
|
-
|
1489
|
-
```python
|
1490
|
-
run = Run("CheckpointsTestsFlow/8992")
|
1491
|
-
with artifact_store_from(run=run, config={
|
1492
|
-
"client_params": {
|
1493
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1494
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1495
|
-
},
|
1496
|
-
}):
|
1497
|
-
with Checkpoint() as cp:
|
1498
|
-
latest = cp.list(
|
1499
|
-
task=run["start"].task
|
1500
|
-
)[0]
|
1501
|
-
print(latest)
|
1502
|
-
cp.load(
|
1503
|
-
latest,
|
1504
|
-
"test-checkpoints"
|
1505
|
-
)
|
1506
|
-
|
1507
|
-
task = Task("TorchTuneFlow/8484/train/53673")
|
1508
|
-
with artifact_store_from(run=run, config={
|
1509
|
-
"client_params": {
|
1510
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
1511
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
1512
|
-
},
|
1513
|
-
}):
|
1514
|
-
load_model(
|
1515
|
-
task.data.model_ref,
|
1516
|
-
"test-models"
|
1517
|
-
)
|
1518
|
-
```
|
1519
|
-
Parameters:
|
1520
|
-
----------
|
1521
|
-
|
1522
|
-
type: str
|
1523
|
-
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
1524
|
-
|
1525
|
-
config: dict or Callable
|
1526
|
-
Dictionary of configuration options for the datastore. The following keys are required:
|
1527
|
-
- root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
|
1528
|
-
- example: 's3://bucket-name/path/to/root'
|
1529
|
-
- example: 'gs://bucket-name/path/to/root'
|
1530
|
-
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
1531
|
-
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
1532
|
-
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
1533
|
-
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
1534
|
-
"""
|
1535
|
-
...
|
1536
|
-
|
1537
1541
|
pkg_name: str
|
1538
1542
|
|