ob-metaflow-stubs 6.0.4.8__py2.py3-none-any.whl → 6.0.4.9__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 +948 -948
- 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 +3 -3
- metaflow-stubs/client/filecache.pyi +2 -2
- metaflow-stubs/events.pyi +2 -2
- metaflow-stubs/exception.pyi +1 -1
- metaflow-stubs/flowspec.pyi +4 -4
- 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 +51 -51
- 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 +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +1 -1
- 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 +3 -3
- 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 +2 -2
- 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 +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +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/apps/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_state_machine.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/spinners.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_cli.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_config.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/capsule.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/click_importer.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/code_packager.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/cli_generator.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/config_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/schema_export.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/typed_configs.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/unified_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/dependencies.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/deployer.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/experimental/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/perimeters.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/utils.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/assume_role_decorator.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.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/fast_bakery/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
- metaflow-stubs/multicore_utils.pyi +1 -1
- metaflow-stubs/ob_internal.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 +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +2 -2
- metaflow-stubs/plugins/argo/exit_hooks.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 +4 -4
- 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 +4 -4
- metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
- metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/cards/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_client.pyi +1 -1
- metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
- metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +1 -1
- 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 +2 -2
- metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/local.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3.pyi +1 -1
- 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/exit_hook/__init__.pyi +1 -1
- metaflow-stubs/plugins/exit_hook/exit_hook_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 +4 -4
- 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 +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
- metaflow-stubs/plugins/perimeters.pyi +1 -1
- metaflow-stubs/plugins/project_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
- 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 +2 -2
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
- metaflow-stubs/plugins/secrets/secrets_func.pyi +1 -1
- metaflow-stubs/plugins/secrets/secrets_spec.pyi +1 -1
- metaflow-stubs/plugins/secrets/utils.pyi +1 -1
- metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/plugins/storage_executor.pyi +1 -1
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
- metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
- metaflow-stubs/plugins/torchtune/__init__.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 +4 -4
- metaflow-stubs/runner/deployer_impl.pyi +2 -2
- metaflow-stubs/runner/metaflow_runner.pyi +3 -3
- metaflow-stubs/runner/nbdeploy.pyi +1 -1
- metaflow-stubs/runner/nbrun.pyi +1 -1
- metaflow-stubs/runner/subprocess_manager.pyi +1 -1
- metaflow-stubs/runner/utils.pyi +2 -2
- metaflow-stubs/system/__init__.pyi +1 -1
- metaflow-stubs/system/system_logger.pyi +2 -2
- metaflow-stubs/system/system_monitor.pyi +1 -1
- metaflow-stubs/tagging_util.pyi +1 -1
- metaflow-stubs/tuple_util.pyi +1 -1
- metaflow-stubs/user_configs/__init__.pyi +1 -1
- metaflow-stubs/user_configs/config_decorators.pyi +5 -5
- metaflow-stubs/user_configs/config_options.pyi +2 -2
- metaflow-stubs/user_configs/config_parameters.pyi +6 -6
- {ob_metaflow_stubs-6.0.4.8.dist-info → ob_metaflow_stubs-6.0.4.9.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.4.9.dist-info/RECORD +249 -0
- ob_metaflow_stubs-6.0.4.8.dist-info/RECORD +0 -249
- {ob_metaflow_stubs-6.0.4.8.dist-info → ob_metaflow_stubs-6.0.4.9.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.4.8.dist-info → ob_metaflow_stubs-6.0.4.9.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
######################################################################################################
|
|
2
2
|
# Auto-generated Metaflow stub file #
|
|
3
3
|
# MF version: 2.15.21.5+obcheckpoint(0.2.4);ob(v1) #
|
|
4
|
-
# Generated on 2025-07-
|
|
4
|
+
# Generated on 2025-07-30T20:52:28.447575 #
|
|
5
5
|
######################################################################################################
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
@@ -35,8 +35,8 @@ from .user_configs.config_parameters import ConfigValue as ConfigValue
|
|
|
35
35
|
from .user_configs.config_parameters import config_expr as config_expr
|
|
36
36
|
from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
|
|
37
37
|
from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
|
|
38
|
-
from . import tuple_util as tuple_util
|
|
39
38
|
from . import cards as cards
|
|
39
|
+
from . import tuple_util as tuple_util
|
|
40
40
|
from . import metaflow_git as metaflow_git
|
|
41
41
|
from . import events as events
|
|
42
42
|
from . import runner as runner
|
|
@@ -157,484 +157,382 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
|
157
157
|
...
|
|
158
158
|
|
|
159
159
|
@typing.overload
|
|
160
|
-
def
|
|
160
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
161
161
|
"""
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
Use `@resources` to specify the resource requirements
|
|
165
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
166
|
-
|
|
167
|
-
You can choose the compute layer on the command line by executing e.g.
|
|
168
|
-
```
|
|
169
|
-
python myflow.py run --with batch
|
|
170
|
-
```
|
|
171
|
-
or
|
|
172
|
-
```
|
|
173
|
-
python myflow.py run --with kubernetes
|
|
174
|
-
```
|
|
175
|
-
which executes the flow on the desired system using the
|
|
176
|
-
requirements specified in `@resources`.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
Parameters
|
|
180
|
-
----------
|
|
181
|
-
cpu : int, default 1
|
|
182
|
-
Number of CPUs required for this step.
|
|
183
|
-
gpu : int, optional, default None
|
|
184
|
-
Number of GPUs required for this step.
|
|
185
|
-
disk : int, optional, default None
|
|
186
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
187
|
-
memory : int, default 4096
|
|
188
|
-
Memory size (in MB) required for this step.
|
|
189
|
-
shared_memory : int, optional, default None
|
|
190
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
191
|
-
This parameter maps to the `--shm-size` option in Docker.
|
|
162
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
163
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
192
164
|
"""
|
|
193
165
|
...
|
|
194
166
|
|
|
195
167
|
@typing.overload
|
|
196
|
-
def
|
|
168
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
197
169
|
...
|
|
198
170
|
|
|
199
|
-
|
|
200
|
-
|
|
171
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
172
|
+
"""
|
|
173
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
174
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
175
|
+
"""
|
|
201
176
|
...
|
|
202
177
|
|
|
203
|
-
def
|
|
178
|
+
def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
204
179
|
"""
|
|
205
|
-
|
|
180
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
|
206
181
|
|
|
207
|
-
|
|
208
|
-
|
|
182
|
+
User code call
|
|
183
|
+
--------------
|
|
184
|
+
@ollama(
|
|
185
|
+
models=[...],
|
|
186
|
+
...
|
|
187
|
+
)
|
|
209
188
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
requirements specified in `@resources`.
|
|
189
|
+
Valid backend options
|
|
190
|
+
---------------------
|
|
191
|
+
- 'local': Run as a separate process on the local task machine.
|
|
192
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
|
193
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
|
194
|
+
|
|
195
|
+
Valid model options
|
|
196
|
+
-------------------
|
|
197
|
+
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
|
220
198
|
|
|
221
199
|
|
|
222
200
|
Parameters
|
|
223
201
|
----------
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
"""
|
|
241
|
-
Internal decorator to support Fast bakery
|
|
202
|
+
models: list[str]
|
|
203
|
+
List of Ollama containers running models in sidecars.
|
|
204
|
+
backend: str
|
|
205
|
+
Determines where and how to run the Ollama process.
|
|
206
|
+
force_pull: bool
|
|
207
|
+
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
|
208
|
+
cache_update_policy: str
|
|
209
|
+
Cache update policy: "auto", "force", or "never".
|
|
210
|
+
force_cache_update: bool
|
|
211
|
+
Simple override for "force" cache update policy.
|
|
212
|
+
debug: bool
|
|
213
|
+
Whether to turn on verbose debugging logs.
|
|
214
|
+
circuit_breaker_config: dict
|
|
215
|
+
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
|
216
|
+
timeout_config: dict
|
|
217
|
+
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
|
242
218
|
"""
|
|
243
219
|
...
|
|
244
220
|
|
|
245
|
-
|
|
246
|
-
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
247
|
-
...
|
|
248
|
-
|
|
249
|
-
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
221
|
+
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', image_pull_secrets: typing.List[str] = [], service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
250
222
|
"""
|
|
251
|
-
|
|
223
|
+
Specifies that this step should execute on Kubernetes.
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
Parameters
|
|
227
|
+
----------
|
|
228
|
+
cpu : int, default 1
|
|
229
|
+
Number of CPUs required for this step. If `@resources` is
|
|
230
|
+
also present, the maximum value from all decorators is used.
|
|
231
|
+
memory : int, default 4096
|
|
232
|
+
Memory size (in MB) required for this step. If
|
|
233
|
+
`@resources` is also present, the maximum value from all decorators is
|
|
234
|
+
used.
|
|
235
|
+
disk : int, default 10240
|
|
236
|
+
Disk size (in MB) required for this step. If
|
|
237
|
+
`@resources` is also present, the maximum value from all decorators is
|
|
238
|
+
used.
|
|
239
|
+
image : str, optional, default None
|
|
240
|
+
Docker image to use when launching on Kubernetes. If not specified, and
|
|
241
|
+
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
|
242
|
+
not, a default Docker image mapping to the current version of Python is used.
|
|
243
|
+
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
|
244
|
+
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
|
245
|
+
image_pull_secrets: List[str], default []
|
|
246
|
+
The default is extracted from METAFLOW_KUBERNETES_IMAGE_PULL_SECRETS.
|
|
247
|
+
Kubernetes image pull secrets to use when pulling container images
|
|
248
|
+
in Kubernetes.
|
|
249
|
+
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
|
250
|
+
Kubernetes service account to use when launching pod in Kubernetes.
|
|
251
|
+
secrets : List[str], optional, default None
|
|
252
|
+
Kubernetes secrets to use when launching pod in Kubernetes. These
|
|
253
|
+
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
|
254
|
+
in Metaflow configuration.
|
|
255
|
+
node_selector: Union[Dict[str,str], str], optional, default None
|
|
256
|
+
Kubernetes node selector(s) to apply to the pod running the task.
|
|
257
|
+
Can be passed in as a comma separated string of values e.g.
|
|
258
|
+
'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
|
|
259
|
+
{'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
|
|
260
|
+
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
|
261
|
+
Kubernetes namespace to use when launching pod in Kubernetes.
|
|
262
|
+
gpu : int, optional, default None
|
|
263
|
+
Number of GPUs required for this step. A value of zero implies that
|
|
264
|
+
the scheduled node should not have GPUs.
|
|
265
|
+
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
|
266
|
+
The vendor of the GPUs to be used for this step.
|
|
267
|
+
tolerations : List[str], default []
|
|
268
|
+
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
|
269
|
+
Kubernetes tolerations to use when launching pod in Kubernetes.
|
|
270
|
+
labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
|
|
271
|
+
Kubernetes labels to use when launching pod in Kubernetes.
|
|
272
|
+
annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
|
|
273
|
+
Kubernetes annotations to use when launching pod in Kubernetes.
|
|
274
|
+
use_tmpfs : bool, default False
|
|
275
|
+
This enables an explicit tmpfs mount for this step.
|
|
276
|
+
tmpfs_tempdir : bool, default True
|
|
277
|
+
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
|
278
|
+
tmpfs_size : int, optional, default: None
|
|
279
|
+
The value for the size (in MiB) of the tmpfs mount for this step.
|
|
280
|
+
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
|
281
|
+
memory allocated for this step.
|
|
282
|
+
tmpfs_path : str, optional, default /metaflow_temp
|
|
283
|
+
Path to tmpfs mount for this step.
|
|
284
|
+
persistent_volume_claims : Dict[str, str], optional, default None
|
|
285
|
+
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
|
286
|
+
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
|
287
|
+
shared_memory: int, optional
|
|
288
|
+
Shared memory size (in MiB) required for this step
|
|
289
|
+
port: int, optional
|
|
290
|
+
Port number to specify in the Kubernetes job object
|
|
291
|
+
compute_pool : str, optional, default None
|
|
292
|
+
Compute pool to be used for for this step.
|
|
293
|
+
If not specified, any accessible compute pool within the perimeter is used.
|
|
294
|
+
hostname_resolution_timeout: int, default 10 * 60
|
|
295
|
+
Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
|
|
296
|
+
Only applicable when @parallel is used.
|
|
297
|
+
qos: str, default: Burstable
|
|
298
|
+
Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
|
|
299
|
+
|
|
300
|
+
security_context: Dict[str, Any], optional, default None
|
|
301
|
+
Container security context. Applies to the task container. Allows the following keys:
|
|
302
|
+
- privileged: bool, optional, default None
|
|
303
|
+
- allow_privilege_escalation: bool, optional, default None
|
|
304
|
+
- run_as_user: int, optional, default None
|
|
305
|
+
- run_as_group: int, optional, default None
|
|
306
|
+
- run_as_non_root: bool, optional, default None
|
|
252
307
|
"""
|
|
253
308
|
...
|
|
254
309
|
|
|
255
310
|
@typing.overload
|
|
256
|
-
def
|
|
311
|
+
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]]]:
|
|
257
312
|
"""
|
|
258
|
-
Specifies
|
|
259
|
-
|
|
313
|
+
Specifies that the step will success under all circumstances.
|
|
314
|
+
|
|
315
|
+
The decorator will create an optional artifact, specified by `var`, which
|
|
316
|
+
contains the exception raised. You can use it to detect the presence
|
|
317
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
|
318
|
+
are missing.
|
|
260
319
|
|
|
261
320
|
|
|
262
321
|
Parameters
|
|
263
322
|
----------
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
323
|
+
var : str, optional, default None
|
|
324
|
+
Name of the artifact in which to store the caught exception.
|
|
325
|
+
If not specified, the exception is not stored.
|
|
326
|
+
print_exception : bool, default True
|
|
327
|
+
Determines whether or not the exception is printed to
|
|
328
|
+
stdout when caught.
|
|
268
329
|
"""
|
|
269
330
|
...
|
|
270
331
|
|
|
271
332
|
@typing.overload
|
|
272
|
-
def
|
|
333
|
+
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
273
334
|
...
|
|
274
335
|
|
|
275
336
|
@typing.overload
|
|
276
|
-
def
|
|
337
|
+
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
277
338
|
...
|
|
278
339
|
|
|
279
|
-
def
|
|
340
|
+
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):
|
|
280
341
|
"""
|
|
281
|
-
Specifies
|
|
282
|
-
|
|
342
|
+
Specifies that the step will success under all circumstances.
|
|
343
|
+
|
|
344
|
+
The decorator will create an optional artifact, specified by `var`, which
|
|
345
|
+
contains the exception raised. You can use it to detect the presence
|
|
346
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
|
347
|
+
are missing.
|
|
283
348
|
|
|
284
349
|
|
|
285
350
|
Parameters
|
|
286
351
|
----------
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
352
|
+
var : str, optional, default None
|
|
353
|
+
Name of the artifact in which to store the caught exception.
|
|
354
|
+
If not specified, the exception is not stored.
|
|
355
|
+
print_exception : bool, default True
|
|
356
|
+
Determines whether or not the exception is printed to
|
|
357
|
+
stdout when caught.
|
|
291
358
|
"""
|
|
292
359
|
...
|
|
293
360
|
|
|
294
361
|
@typing.overload
|
|
295
|
-
def
|
|
362
|
+
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]]]:
|
|
296
363
|
"""
|
|
297
|
-
Enables
|
|
364
|
+
Enables loading / saving of models within a step.
|
|
298
365
|
|
|
299
366
|
> Examples
|
|
300
|
-
|
|
301
|
-
- Saving Checkpoints
|
|
302
|
-
|
|
367
|
+
- Saving Models
|
|
303
368
|
```python
|
|
304
|
-
@
|
|
369
|
+
@model
|
|
305
370
|
@step
|
|
306
371
|
def train(self):
|
|
307
|
-
model
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
name="epoch_checkpoint",
|
|
319
|
-
metadata={
|
|
320
|
-
"epoch": i,
|
|
321
|
-
"loss": loss,
|
|
322
|
-
}
|
|
323
|
-
)
|
|
324
|
-
```
|
|
372
|
+
# current.model.save returns a dictionary reference to the model saved
|
|
373
|
+
self.my_model = current.model.save(
|
|
374
|
+
path_to_my_model,
|
|
375
|
+
label="my_model",
|
|
376
|
+
metadata={
|
|
377
|
+
"epochs": 10,
|
|
378
|
+
"batch-size": 32,
|
|
379
|
+
"learning-rate": 0.001,
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
self.next(self.test)
|
|
325
383
|
|
|
326
|
-
|
|
384
|
+
@model(load="my_model")
|
|
385
|
+
@step
|
|
386
|
+
def test(self):
|
|
387
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
|
388
|
+
# where the key is the name of the artifact and the value is the path to the model
|
|
389
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
|
390
|
+
self.next(self.end)
|
|
391
|
+
```
|
|
327
392
|
|
|
393
|
+
- Loading models
|
|
328
394
|
```python
|
|
329
|
-
@retry(times=3)
|
|
330
|
-
@checkpoint
|
|
331
395
|
@step
|
|
332
396
|
def train(self):
|
|
333
|
-
#
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
for i in range(self.epochs):
|
|
342
|
-
...
|
|
397
|
+
# current.model.load returns the path to the model loaded
|
|
398
|
+
checkpoint_path = current.model.load(
|
|
399
|
+
self.checkpoint_key,
|
|
400
|
+
)
|
|
401
|
+
model_path = current.model.load(
|
|
402
|
+
self.model,
|
|
403
|
+
)
|
|
404
|
+
self.next(self.test)
|
|
343
405
|
```
|
|
344
406
|
|
|
345
407
|
|
|
346
408
|
Parameters
|
|
347
409
|
----------
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
355
|
-
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
356
|
-
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
357
|
-
created within the task will be loaded when the task is retries execution on failure.
|
|
410
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
411
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
412
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by `current.checkpoint` / `current.model` / `current.huggingface_hub`.
|
|
413
|
+
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
|
|
414
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
415
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
358
416
|
|
|
359
417
|
temp_dir_root : str, default: None
|
|
360
|
-
The root directory under which `current.
|
|
418
|
+
The root directory under which `current.model.loaded` will store loaded models
|
|
361
419
|
"""
|
|
362
420
|
...
|
|
363
421
|
|
|
364
422
|
@typing.overload
|
|
365
|
-
def
|
|
423
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
366
424
|
...
|
|
367
425
|
|
|
368
426
|
@typing.overload
|
|
369
|
-
def
|
|
427
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
370
428
|
...
|
|
371
429
|
|
|
372
|
-
def
|
|
430
|
+
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):
|
|
373
431
|
"""
|
|
374
|
-
Enables
|
|
432
|
+
Enables loading / saving of models within a step.
|
|
375
433
|
|
|
376
434
|
> Examples
|
|
377
|
-
|
|
378
|
-
- Saving Checkpoints
|
|
379
|
-
|
|
435
|
+
- Saving Models
|
|
380
436
|
```python
|
|
381
|
-
@
|
|
437
|
+
@model
|
|
382
438
|
@step
|
|
383
439
|
def train(self):
|
|
384
|
-
model
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
name="epoch_checkpoint",
|
|
396
|
-
metadata={
|
|
397
|
-
"epoch": i,
|
|
398
|
-
"loss": loss,
|
|
399
|
-
}
|
|
400
|
-
)
|
|
401
|
-
```
|
|
440
|
+
# current.model.save returns a dictionary reference to the model saved
|
|
441
|
+
self.my_model = current.model.save(
|
|
442
|
+
path_to_my_model,
|
|
443
|
+
label="my_model",
|
|
444
|
+
metadata={
|
|
445
|
+
"epochs": 10,
|
|
446
|
+
"batch-size": 32,
|
|
447
|
+
"learning-rate": 0.001,
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
self.next(self.test)
|
|
402
451
|
|
|
403
|
-
|
|
452
|
+
@model(load="my_model")
|
|
453
|
+
@step
|
|
454
|
+
def test(self):
|
|
455
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
|
456
|
+
# where the key is the name of the artifact and the value is the path to the model
|
|
457
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
|
458
|
+
self.next(self.end)
|
|
459
|
+
```
|
|
404
460
|
|
|
461
|
+
- Loading models
|
|
405
462
|
```python
|
|
406
|
-
@retry(times=3)
|
|
407
|
-
@checkpoint
|
|
408
463
|
@step
|
|
409
464
|
def train(self):
|
|
410
|
-
#
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
for i in range(self.epochs):
|
|
419
|
-
...
|
|
465
|
+
# current.model.load returns the path to the model loaded
|
|
466
|
+
checkpoint_path = current.model.load(
|
|
467
|
+
self.checkpoint_key,
|
|
468
|
+
)
|
|
469
|
+
model_path = current.model.load(
|
|
470
|
+
self.model,
|
|
471
|
+
)
|
|
472
|
+
self.next(self.test)
|
|
420
473
|
```
|
|
421
474
|
|
|
422
475
|
|
|
423
476
|
Parameters
|
|
424
477
|
----------
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
432
|
-
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
433
|
-
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
434
|
-
created within the task will be loaded when the task is retries execution on failure.
|
|
478
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
479
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
480
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by `current.checkpoint` / `current.model` / `current.huggingface_hub`.
|
|
481
|
+
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
|
|
482
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
483
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
435
484
|
|
|
436
485
|
temp_dir_root : str, default: None
|
|
437
|
-
The root directory under which `current.
|
|
438
|
-
"""
|
|
439
|
-
...
|
|
440
|
-
|
|
441
|
-
@typing.overload
|
|
442
|
-
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]]]:
|
|
443
|
-
"""
|
|
444
|
-
Specifies environment variables to be set prior to the execution of a step.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
Parameters
|
|
448
|
-
----------
|
|
449
|
-
vars : Dict[str, str], default {}
|
|
450
|
-
Dictionary of environment variables to set.
|
|
451
|
-
"""
|
|
452
|
-
...
|
|
453
|
-
|
|
454
|
-
@typing.overload
|
|
455
|
-
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
456
|
-
...
|
|
457
|
-
|
|
458
|
-
@typing.overload
|
|
459
|
-
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
460
|
-
...
|
|
461
|
-
|
|
462
|
-
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
|
463
|
-
"""
|
|
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.
|
|
486
|
+
The root directory under which `current.model.loaded` will store loaded models
|
|
471
487
|
"""
|
|
472
488
|
...
|
|
473
489
|
|
|
474
490
|
@typing.overload
|
|
475
|
-
def
|
|
491
|
+
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]]]:
|
|
476
492
|
"""
|
|
477
|
-
|
|
493
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
|
478
494
|
|
|
479
|
-
|
|
480
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
481
|
-
you can use `@conda_base` to set packages required by all
|
|
482
|
-
steps and use `@conda` to specify step-specific overrides.
|
|
495
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
|
483
496
|
|
|
484
497
|
|
|
485
498
|
Parameters
|
|
486
499
|
----------
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
disabled : bool, default False
|
|
496
|
-
If set to True, disables @conda.
|
|
500
|
+
type : str, default 'default'
|
|
501
|
+
Card type.
|
|
502
|
+
id : str, optional, default None
|
|
503
|
+
If multiple cards are present, use this id to identify this card.
|
|
504
|
+
options : Dict[str, Any], default {}
|
|
505
|
+
Options passed to the card. The contents depend on the card type.
|
|
506
|
+
timeout : int, default 45
|
|
507
|
+
Interrupt reporting if it takes more than this many seconds.
|
|
497
508
|
"""
|
|
498
509
|
...
|
|
499
510
|
|
|
500
511
|
@typing.overload
|
|
501
|
-
def
|
|
512
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
502
513
|
...
|
|
503
514
|
|
|
504
515
|
@typing.overload
|
|
505
|
-
def
|
|
516
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
506
517
|
...
|
|
507
518
|
|
|
508
|
-
def
|
|
519
|
+
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):
|
|
509
520
|
"""
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
Information in this decorator will augment any
|
|
513
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
514
|
-
you can use `@conda_base` to set packages required by all
|
|
515
|
-
steps and use `@conda` to specify step-specific overrides.
|
|
516
|
-
|
|
521
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
|
517
522
|
|
|
518
|
-
|
|
519
|
-
----------
|
|
520
|
-
packages : Dict[str, str], default {}
|
|
521
|
-
Packages to use for this step. The key is the name of the package
|
|
522
|
-
and the value is the version to use.
|
|
523
|
-
libraries : Dict[str, str], default {}
|
|
524
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
525
|
-
python : str, optional, default None
|
|
526
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
527
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
528
|
-
disabled : bool, default False
|
|
529
|
-
If set to True, disables @conda.
|
|
530
|
-
"""
|
|
531
|
-
...
|
|
532
|
-
|
|
533
|
-
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', image_pull_secrets: typing.List[str] = [], service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
534
|
-
"""
|
|
535
|
-
Specifies that this step should execute on Kubernetes.
|
|
523
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
|
536
524
|
|
|
537
525
|
|
|
538
526
|
Parameters
|
|
539
527
|
----------
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
Disk size (in MB) required for this step. If
|
|
549
|
-
`@resources` is also present, the maximum value from all decorators is
|
|
550
|
-
used.
|
|
551
|
-
image : str, optional, default None
|
|
552
|
-
Docker image to use when launching on Kubernetes. If not specified, and
|
|
553
|
-
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
|
554
|
-
not, a default Docker image mapping to the current version of Python is used.
|
|
555
|
-
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
|
556
|
-
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
|
557
|
-
image_pull_secrets: List[str], default []
|
|
558
|
-
The default is extracted from METAFLOW_KUBERNETES_IMAGE_PULL_SECRETS.
|
|
559
|
-
Kubernetes image pull secrets to use when pulling container images
|
|
560
|
-
in Kubernetes.
|
|
561
|
-
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
|
562
|
-
Kubernetes service account to use when launching pod in Kubernetes.
|
|
563
|
-
secrets : List[str], optional, default None
|
|
564
|
-
Kubernetes secrets to use when launching pod in Kubernetes. These
|
|
565
|
-
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
|
566
|
-
in Metaflow configuration.
|
|
567
|
-
node_selector: Union[Dict[str,str], str], optional, default None
|
|
568
|
-
Kubernetes node selector(s) to apply to the pod running the task.
|
|
569
|
-
Can be passed in as a comma separated string of values e.g.
|
|
570
|
-
'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
|
|
571
|
-
{'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
|
|
572
|
-
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
|
573
|
-
Kubernetes namespace to use when launching pod in Kubernetes.
|
|
574
|
-
gpu : int, optional, default None
|
|
575
|
-
Number of GPUs required for this step. A value of zero implies that
|
|
576
|
-
the scheduled node should not have GPUs.
|
|
577
|
-
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
|
578
|
-
The vendor of the GPUs to be used for this step.
|
|
579
|
-
tolerations : List[str], default []
|
|
580
|
-
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
|
581
|
-
Kubernetes tolerations to use when launching pod in Kubernetes.
|
|
582
|
-
labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
|
|
583
|
-
Kubernetes labels to use when launching pod in Kubernetes.
|
|
584
|
-
annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
|
|
585
|
-
Kubernetes annotations to use when launching pod in Kubernetes.
|
|
586
|
-
use_tmpfs : bool, default False
|
|
587
|
-
This enables an explicit tmpfs mount for this step.
|
|
588
|
-
tmpfs_tempdir : bool, default True
|
|
589
|
-
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
|
590
|
-
tmpfs_size : int, optional, default: None
|
|
591
|
-
The value for the size (in MiB) of the tmpfs mount for this step.
|
|
592
|
-
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
|
593
|
-
memory allocated for this step.
|
|
594
|
-
tmpfs_path : str, optional, default /metaflow_temp
|
|
595
|
-
Path to tmpfs mount for this step.
|
|
596
|
-
persistent_volume_claims : Dict[str, str], optional, default None
|
|
597
|
-
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
|
598
|
-
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
|
599
|
-
shared_memory: int, optional
|
|
600
|
-
Shared memory size (in MiB) required for this step
|
|
601
|
-
port: int, optional
|
|
602
|
-
Port number to specify in the Kubernetes job object
|
|
603
|
-
compute_pool : str, optional, default None
|
|
604
|
-
Compute pool to be used for for this step.
|
|
605
|
-
If not specified, any accessible compute pool within the perimeter is used.
|
|
606
|
-
hostname_resolution_timeout: int, default 10 * 60
|
|
607
|
-
Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
|
|
608
|
-
Only applicable when @parallel is used.
|
|
609
|
-
qos: str, default: Burstable
|
|
610
|
-
Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
|
|
611
|
-
|
|
612
|
-
security_context: Dict[str, Any], optional, default None
|
|
613
|
-
Container security context. Applies to the task container. Allows the following keys:
|
|
614
|
-
- privileged: bool, optional, default None
|
|
615
|
-
- allow_privilege_escalation: bool, optional, default None
|
|
616
|
-
- run_as_user: int, optional, default None
|
|
617
|
-
- run_as_group: int, optional, default None
|
|
618
|
-
- run_as_non_root: bool, optional, default None
|
|
619
|
-
"""
|
|
620
|
-
...
|
|
621
|
-
|
|
622
|
-
@typing.overload
|
|
623
|
-
def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
624
|
-
"""
|
|
625
|
-
Decorator prototype for all step decorators. This function gets specialized
|
|
626
|
-
and imported for all decorators types by _import_plugin_decorators().
|
|
627
|
-
"""
|
|
628
|
-
...
|
|
629
|
-
|
|
630
|
-
@typing.overload
|
|
631
|
-
def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
632
|
-
...
|
|
633
|
-
|
|
634
|
-
def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
635
|
-
"""
|
|
636
|
-
Decorator prototype for all step decorators. This function gets specialized
|
|
637
|
-
and imported for all decorators types by _import_plugin_decorators().
|
|
528
|
+
type : str, default 'default'
|
|
529
|
+
Card type.
|
|
530
|
+
id : str, optional, default None
|
|
531
|
+
If multiple cards are present, use this id to identify this card.
|
|
532
|
+
options : Dict[str, Any], default {}
|
|
533
|
+
Options passed to the card. The contents depend on the card type.
|
|
534
|
+
timeout : int, default 45
|
|
535
|
+
Interrupt reporting if it takes more than this many seconds.
|
|
638
536
|
"""
|
|
639
537
|
...
|
|
640
538
|
|
|
@@ -689,219 +587,271 @@ def vllm(*, model: str, backend: str, openai_api_server: bool, debug: bool, card
|
|
|
689
587
|
...
|
|
690
588
|
|
|
691
589
|
@typing.overload
|
|
692
|
-
def
|
|
590
|
+
def timeout(*, seconds: int = 0, minutes: int = 0, hours: int = 0) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
693
591
|
"""
|
|
694
|
-
|
|
592
|
+
Specifies a timeout for your step.
|
|
695
593
|
|
|
696
|
-
|
|
697
|
-
- Saving Models
|
|
698
|
-
```python
|
|
699
|
-
@model
|
|
700
|
-
@step
|
|
701
|
-
def train(self):
|
|
702
|
-
# current.model.save returns a dictionary reference to the model saved
|
|
703
|
-
self.my_model = current.model.save(
|
|
704
|
-
path_to_my_model,
|
|
705
|
-
label="my_model",
|
|
706
|
-
metadata={
|
|
707
|
-
"epochs": 10,
|
|
708
|
-
"batch-size": 32,
|
|
709
|
-
"learning-rate": 0.001,
|
|
710
|
-
}
|
|
711
|
-
)
|
|
712
|
-
self.next(self.test)
|
|
594
|
+
This decorator is useful if this step may hang indefinitely.
|
|
713
595
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
# `current.model.loaded` returns a dictionary of the loaded models
|
|
718
|
-
# where the key is the name of the artifact and the value is the path to the model
|
|
719
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
|
720
|
-
self.next(self.end)
|
|
721
|
-
```
|
|
596
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
|
597
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
|
598
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
722
599
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
@step
|
|
726
|
-
def train(self):
|
|
727
|
-
# current.model.load returns the path to the model loaded
|
|
728
|
-
checkpoint_path = current.model.load(
|
|
729
|
-
self.checkpoint_key,
|
|
730
|
-
)
|
|
731
|
-
model_path = current.model.load(
|
|
732
|
-
self.model,
|
|
733
|
-
)
|
|
734
|
-
self.next(self.test)
|
|
735
|
-
```
|
|
600
|
+
Note that all the values specified in parameters are added together so if you specify
|
|
601
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
|
736
602
|
|
|
737
603
|
|
|
738
604
|
Parameters
|
|
739
605
|
----------
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
606
|
+
seconds : int, default 0
|
|
607
|
+
Number of seconds to wait prior to timing out.
|
|
608
|
+
minutes : int, default 0
|
|
609
|
+
Number of minutes to wait prior to timing out.
|
|
610
|
+
hours : int, default 0
|
|
611
|
+
Number of hours to wait prior to timing out.
|
|
612
|
+
"""
|
|
613
|
+
...
|
|
614
|
+
|
|
615
|
+
@typing.overload
|
|
616
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
617
|
+
...
|
|
618
|
+
|
|
619
|
+
@typing.overload
|
|
620
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
621
|
+
...
|
|
622
|
+
|
|
623
|
+
def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, seconds: int = 0, minutes: int = 0, hours: int = 0):
|
|
624
|
+
"""
|
|
625
|
+
Specifies a timeout for your step.
|
|
746
626
|
|
|
747
|
-
|
|
748
|
-
|
|
627
|
+
This decorator is useful if this step may hang indefinitely.
|
|
628
|
+
|
|
629
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
|
630
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
|
631
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
632
|
+
|
|
633
|
+
Note that all the values specified in parameters are added together so if you specify
|
|
634
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
Parameters
|
|
638
|
+
----------
|
|
639
|
+
seconds : int, default 0
|
|
640
|
+
Number of seconds to wait prior to timing out.
|
|
641
|
+
minutes : int, default 0
|
|
642
|
+
Number of minutes to wait prior to timing out.
|
|
643
|
+
hours : int, default 0
|
|
644
|
+
Number of hours to wait prior to timing out.
|
|
749
645
|
"""
|
|
750
646
|
...
|
|
751
647
|
|
|
752
648
|
@typing.overload
|
|
753
|
-
def
|
|
649
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
650
|
+
"""
|
|
651
|
+
Internal decorator to support Fast bakery
|
|
652
|
+
"""
|
|
754
653
|
...
|
|
755
654
|
|
|
756
655
|
@typing.overload
|
|
757
|
-
def
|
|
656
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
758
657
|
...
|
|
759
658
|
|
|
760
|
-
def
|
|
659
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
761
660
|
"""
|
|
762
|
-
|
|
661
|
+
Internal decorator to support Fast bakery
|
|
662
|
+
"""
|
|
663
|
+
...
|
|
664
|
+
|
|
665
|
+
@typing.overload
|
|
666
|
+
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]]]:
|
|
667
|
+
"""
|
|
668
|
+
Specifies the resources needed when executing this step.
|
|
763
669
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
```python
|
|
767
|
-
@model
|
|
768
|
-
@step
|
|
769
|
-
def train(self):
|
|
770
|
-
# current.model.save returns a dictionary reference to the model saved
|
|
771
|
-
self.my_model = current.model.save(
|
|
772
|
-
path_to_my_model,
|
|
773
|
-
label="my_model",
|
|
774
|
-
metadata={
|
|
775
|
-
"epochs": 10,
|
|
776
|
-
"batch-size": 32,
|
|
777
|
-
"learning-rate": 0.001,
|
|
778
|
-
}
|
|
779
|
-
)
|
|
780
|
-
self.next(self.test)
|
|
670
|
+
Use `@resources` to specify the resource requirements
|
|
671
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
781
672
|
|
|
782
|
-
|
|
783
|
-
@step
|
|
784
|
-
def test(self):
|
|
785
|
-
# `current.model.loaded` returns a dictionary of the loaded models
|
|
786
|
-
# where the key is the name of the artifact and the value is the path to the model
|
|
787
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
|
788
|
-
self.next(self.end)
|
|
673
|
+
You can choose the compute layer on the command line by executing e.g.
|
|
789
674
|
```
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
# current.model.load returns the path to the model loaded
|
|
796
|
-
checkpoint_path = current.model.load(
|
|
797
|
-
self.checkpoint_key,
|
|
798
|
-
)
|
|
799
|
-
model_path = current.model.load(
|
|
800
|
-
self.model,
|
|
801
|
-
)
|
|
802
|
-
self.next(self.test)
|
|
675
|
+
python myflow.py run --with batch
|
|
676
|
+
```
|
|
677
|
+
or
|
|
678
|
+
```
|
|
679
|
+
python myflow.py run --with kubernetes
|
|
803
680
|
```
|
|
681
|
+
which executes the flow on the desired system using the
|
|
682
|
+
requirements specified in `@resources`.
|
|
804
683
|
|
|
805
684
|
|
|
806
685
|
Parameters
|
|
807
686
|
----------
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
687
|
+
cpu : int, default 1
|
|
688
|
+
Number of CPUs required for this step.
|
|
689
|
+
gpu : int, optional, default None
|
|
690
|
+
Number of GPUs required for this step.
|
|
691
|
+
disk : int, optional, default None
|
|
692
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
693
|
+
memory : int, default 4096
|
|
694
|
+
Memory size (in MB) required for this step.
|
|
695
|
+
shared_memory : int, optional, default None
|
|
696
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
697
|
+
This parameter maps to the `--shm-size` option in Docker.
|
|
698
|
+
"""
|
|
699
|
+
...
|
|
700
|
+
|
|
701
|
+
@typing.overload
|
|
702
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
703
|
+
...
|
|
704
|
+
|
|
705
|
+
@typing.overload
|
|
706
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
707
|
+
...
|
|
708
|
+
|
|
709
|
+
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):
|
|
710
|
+
"""
|
|
711
|
+
Specifies the resources needed when executing this step.
|
|
814
712
|
|
|
815
|
-
|
|
816
|
-
|
|
713
|
+
Use `@resources` to specify the resource requirements
|
|
714
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
715
|
+
|
|
716
|
+
You can choose the compute layer on the command line by executing e.g.
|
|
717
|
+
```
|
|
718
|
+
python myflow.py run --with batch
|
|
719
|
+
```
|
|
720
|
+
or
|
|
721
|
+
```
|
|
722
|
+
python myflow.py run --with kubernetes
|
|
723
|
+
```
|
|
724
|
+
which executes the flow on the desired system using the
|
|
725
|
+
requirements specified in `@resources`.
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
Parameters
|
|
729
|
+
----------
|
|
730
|
+
cpu : int, default 1
|
|
731
|
+
Number of CPUs required for this step.
|
|
732
|
+
gpu : int, optional, default None
|
|
733
|
+
Number of GPUs required for this step.
|
|
734
|
+
disk : int, optional, default None
|
|
735
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
736
|
+
memory : int, default 4096
|
|
737
|
+
Memory size (in MB) required for this step.
|
|
738
|
+
shared_memory : int, optional, default None
|
|
739
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
740
|
+
This parameter maps to the `--shm-size` option in Docker.
|
|
817
741
|
"""
|
|
818
742
|
...
|
|
819
743
|
|
|
820
|
-
|
|
744
|
+
@typing.overload
|
|
745
|
+
def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
821
746
|
"""
|
|
822
|
-
Specifies
|
|
747
|
+
Specifies the Conda environment for the step.
|
|
748
|
+
|
|
749
|
+
Information in this decorator will augment any
|
|
750
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
751
|
+
you can use `@conda_base` to set packages required by all
|
|
752
|
+
steps and use `@conda` to specify step-specific overrides.
|
|
823
753
|
|
|
824
754
|
|
|
825
755
|
Parameters
|
|
826
756
|
----------
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
757
|
+
packages : Dict[str, str], default {}
|
|
758
|
+
Packages to use for this step. The key is the name of the package
|
|
759
|
+
and the value is the version to use.
|
|
760
|
+
libraries : Dict[str, str], default {}
|
|
761
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
762
|
+
python : str, optional, default None
|
|
763
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
764
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
765
|
+
disabled : bool, default False
|
|
766
|
+
If set to True, disables @conda.
|
|
831
767
|
"""
|
|
832
768
|
...
|
|
833
769
|
|
|
834
770
|
@typing.overload
|
|
835
|
-
def
|
|
771
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
772
|
+
...
|
|
773
|
+
|
|
774
|
+
@typing.overload
|
|
775
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
776
|
+
...
|
|
777
|
+
|
|
778
|
+
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
|
836
779
|
"""
|
|
837
|
-
Specifies
|
|
780
|
+
Specifies the Conda environment for the step.
|
|
838
781
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
782
|
+
Information in this decorator will augment any
|
|
783
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
784
|
+
you can use `@conda_base` to set packages required by all
|
|
785
|
+
steps and use `@conda` to specify step-specific overrides.
|
|
843
786
|
|
|
844
787
|
|
|
845
788
|
Parameters
|
|
846
789
|
----------
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
790
|
+
packages : Dict[str, str], default {}
|
|
791
|
+
Packages to use for this step. The key is the name of the package
|
|
792
|
+
and the value is the version to use.
|
|
793
|
+
libraries : Dict[str, str], default {}
|
|
794
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
795
|
+
python : str, optional, default None
|
|
796
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
797
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
798
|
+
disabled : bool, default False
|
|
799
|
+
If set to True, disables @conda.
|
|
853
800
|
"""
|
|
854
801
|
...
|
|
855
802
|
|
|
856
803
|
@typing.overload
|
|
857
|
-
def
|
|
858
|
-
...
|
|
859
|
-
|
|
860
|
-
@typing.overload
|
|
861
|
-
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
862
|
-
...
|
|
863
|
-
|
|
864
|
-
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):
|
|
804
|
+
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]]]:
|
|
865
805
|
"""
|
|
866
|
-
Specifies
|
|
806
|
+
Specifies the PyPI packages for the step.
|
|
867
807
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
808
|
+
Information in this decorator will augment any
|
|
809
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
810
|
+
you can use `@pypi_base` to set packages required by all
|
|
811
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
872
812
|
|
|
873
813
|
|
|
874
814
|
Parameters
|
|
875
815
|
----------
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
816
|
+
packages : Dict[str, str], default: {}
|
|
817
|
+
Packages to use for this step. The key is the name of the package
|
|
818
|
+
and the value is the version to use.
|
|
819
|
+
python : str, optional, default: None
|
|
820
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
821
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
882
822
|
"""
|
|
883
823
|
...
|
|
884
824
|
|
|
885
825
|
@typing.overload
|
|
886
|
-
def
|
|
887
|
-
"""
|
|
888
|
-
Decorator prototype for all step decorators. This function gets specialized
|
|
889
|
-
and imported for all decorators types by _import_plugin_decorators().
|
|
890
|
-
"""
|
|
826
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
891
827
|
...
|
|
892
828
|
|
|
893
829
|
@typing.overload
|
|
894
|
-
def
|
|
830
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
895
831
|
...
|
|
896
832
|
|
|
897
|
-
def
|
|
833
|
+
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):
|
|
898
834
|
"""
|
|
899
|
-
|
|
900
|
-
|
|
835
|
+
Specifies the PyPI packages for the step.
|
|
836
|
+
|
|
837
|
+
Information in this decorator will augment any
|
|
838
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
839
|
+
you can use `@pypi_base` to set packages required by all
|
|
840
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
Parameters
|
|
844
|
+
----------
|
|
845
|
+
packages : Dict[str, str], default: {}
|
|
846
|
+
Packages to use for this step. The key is the name of the package
|
|
847
|
+
and the value is the version to use.
|
|
848
|
+
python : str, optional, default: None
|
|
849
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
850
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
901
851
|
"""
|
|
902
852
|
...
|
|
903
853
|
|
|
904
|
-
def
|
|
854
|
+
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]]]:
|
|
905
855
|
"""
|
|
906
856
|
Specifies that this step should execute on DGX cloud.
|
|
907
857
|
|
|
@@ -912,100 +862,44 @@ def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[t
|
|
|
912
862
|
Number of GPUs to use.
|
|
913
863
|
gpu_type : str
|
|
914
864
|
Type of Nvidia GPU to use.
|
|
915
|
-
queue_timeout : int
|
|
916
|
-
Time to keep the job in NVCF's queue.
|
|
917
865
|
"""
|
|
918
866
|
...
|
|
919
867
|
|
|
920
|
-
|
|
868
|
+
@typing.overload
|
|
869
|
+
def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
921
870
|
"""
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
User code call
|
|
925
|
-
--------------
|
|
926
|
-
@ollama(
|
|
927
|
-
models=[...],
|
|
928
|
-
...
|
|
929
|
-
)
|
|
930
|
-
|
|
931
|
-
Valid backend options
|
|
932
|
-
---------------------
|
|
933
|
-
- 'local': Run as a separate process on the local task machine.
|
|
934
|
-
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
|
935
|
-
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
|
936
|
-
|
|
937
|
-
Valid model options
|
|
938
|
-
-------------------
|
|
939
|
-
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
Parameters
|
|
943
|
-
----------
|
|
944
|
-
models: list[str]
|
|
945
|
-
List of Ollama containers running models in sidecars.
|
|
946
|
-
backend: str
|
|
947
|
-
Determines where and how to run the Ollama process.
|
|
948
|
-
force_pull: bool
|
|
949
|
-
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
|
950
|
-
cache_update_policy: str
|
|
951
|
-
Cache update policy: "auto", "force", or "never".
|
|
952
|
-
force_cache_update: bool
|
|
953
|
-
Simple override for "force" cache update policy.
|
|
954
|
-
debug: bool
|
|
955
|
-
Whether to turn on verbose debugging logs.
|
|
956
|
-
circuit_breaker_config: dict
|
|
957
|
-
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
|
958
|
-
timeout_config: dict
|
|
959
|
-
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
|
871
|
+
A simple decorator that demonstrates using CardDecoratorInjector
|
|
872
|
+
to inject a card and render simple markdown content.
|
|
960
873
|
"""
|
|
961
874
|
...
|
|
962
875
|
|
|
963
876
|
@typing.overload
|
|
964
|
-
def
|
|
877
|
+
def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
878
|
+
...
|
|
879
|
+
|
|
880
|
+
def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
965
881
|
"""
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
Parameters
|
|
972
|
-
----------
|
|
973
|
-
type : str, default 'default'
|
|
974
|
-
Card type.
|
|
975
|
-
id : str, optional, default None
|
|
976
|
-
If multiple cards are present, use this id to identify this card.
|
|
977
|
-
options : Dict[str, Any], default {}
|
|
978
|
-
Options passed to the card. The contents depend on the card type.
|
|
979
|
-
timeout : int, default 45
|
|
980
|
-
Interrupt reporting if it takes more than this many seconds.
|
|
882
|
+
A simple decorator that demonstrates using CardDecoratorInjector
|
|
883
|
+
to inject a card and render simple markdown content.
|
|
981
884
|
"""
|
|
982
885
|
...
|
|
983
886
|
|
|
984
887
|
@typing.overload
|
|
985
|
-
def
|
|
888
|
+
def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
889
|
+
"""
|
|
890
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
891
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
892
|
+
"""
|
|
986
893
|
...
|
|
987
894
|
|
|
988
895
|
@typing.overload
|
|
989
|
-
def
|
|
896
|
+
def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
990
897
|
...
|
|
991
898
|
|
|
992
|
-
def
|
|
899
|
+
def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
993
900
|
"""
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
Parameters
|
|
1000
|
-
----------
|
|
1001
|
-
type : str, default 'default'
|
|
1002
|
-
Card type.
|
|
1003
|
-
id : str, optional, default None
|
|
1004
|
-
If multiple cards are present, use this id to identify this card.
|
|
1005
|
-
options : Dict[str, Any], default {}
|
|
1006
|
-
Options passed to the card. The contents depend on the card type.
|
|
1007
|
-
timeout : int, default 45
|
|
1008
|
-
Interrupt reporting if it takes more than this many seconds.
|
|
901
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
902
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
1009
903
|
"""
|
|
1010
904
|
...
|
|
1011
905
|
|
|
@@ -1065,131 +959,198 @@ def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
|
1065
959
|
...
|
|
1066
960
|
|
|
1067
961
|
@typing.overload
|
|
1068
|
-
def
|
|
962
|
+
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]]]:
|
|
1069
963
|
"""
|
|
1070
|
-
|
|
1071
|
-
|
|
964
|
+
Specifies environment variables to be set prior to the execution of a step.
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
Parameters
|
|
968
|
+
----------
|
|
969
|
+
vars : Dict[str, str], default {}
|
|
970
|
+
Dictionary of environment variables to set.
|
|
1072
971
|
"""
|
|
1073
972
|
...
|
|
1074
973
|
|
|
1075
974
|
@typing.overload
|
|
1076
|
-
def
|
|
975
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1077
976
|
...
|
|
1078
977
|
|
|
1079
|
-
|
|
978
|
+
@typing.overload
|
|
979
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
980
|
+
...
|
|
981
|
+
|
|
982
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
|
1080
983
|
"""
|
|
1081
|
-
|
|
1082
|
-
|
|
984
|
+
Specifies environment variables to be set prior to the execution of a step.
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
Parameters
|
|
988
|
+
----------
|
|
989
|
+
vars : Dict[str, str], default {}
|
|
990
|
+
Dictionary of environment variables to set.
|
|
1083
991
|
"""
|
|
1084
992
|
...
|
|
1085
993
|
|
|
1086
994
|
@typing.overload
|
|
1087
|
-
def
|
|
995
|
+
def checkpoint(*, load_policy: str = 'fresh', temp_dir_root: str = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
1088
996
|
"""
|
|
1089
|
-
|
|
997
|
+
Enables checkpointing for a step.
|
|
1090
998
|
|
|
1091
|
-
|
|
999
|
+
> Examples
|
|
1092
1000
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1001
|
+
- Saving Checkpoints
|
|
1002
|
+
|
|
1003
|
+
```python
|
|
1004
|
+
@checkpoint
|
|
1005
|
+
@step
|
|
1006
|
+
def train(self):
|
|
1007
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
|
1008
|
+
for i in range(self.epochs):
|
|
1009
|
+
# some training logic
|
|
1010
|
+
loss = model.train(self.dataset)
|
|
1011
|
+
if i % 10 == 0:
|
|
1012
|
+
model.save(
|
|
1013
|
+
current.checkpoint.directory,
|
|
1014
|
+
)
|
|
1015
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
|
1016
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
|
1017
|
+
self.latest_checkpoint = current.checkpoint.save(
|
|
1018
|
+
name="epoch_checkpoint",
|
|
1019
|
+
metadata={
|
|
1020
|
+
"epoch": i,
|
|
1021
|
+
"loss": loss,
|
|
1022
|
+
}
|
|
1023
|
+
)
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
- Using Loaded Checkpoints
|
|
1027
|
+
|
|
1028
|
+
```python
|
|
1029
|
+
@retry(times=3)
|
|
1030
|
+
@checkpoint
|
|
1031
|
+
@step
|
|
1032
|
+
def train(self):
|
|
1033
|
+
# Assume that the task has restarted and the previous attempt of the task
|
|
1034
|
+
# saved a checkpoint
|
|
1035
|
+
checkpoint_path = None
|
|
1036
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
|
1037
|
+
print("Loaded checkpoint from the previous attempt")
|
|
1038
|
+
checkpoint_path = current.checkpoint.directory
|
|
1096
1039
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1040
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
|
1041
|
+
for i in range(self.epochs):
|
|
1042
|
+
...
|
|
1043
|
+
```
|
|
1099
1044
|
|
|
1100
1045
|
|
|
1101
1046
|
Parameters
|
|
1102
1047
|
----------
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1048
|
+
load_policy : str, default: "fresh"
|
|
1049
|
+
The policy for loading the checkpoint. The following policies are supported:
|
|
1050
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
|
1051
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
|
1052
|
+
will be loaded at the start of the task.
|
|
1053
|
+
- "none": Do not load any checkpoint
|
|
1054
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
1055
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
1056
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
1057
|
+
created within the task will be loaded when the task is retries execution on failure.
|
|
1058
|
+
|
|
1059
|
+
temp_dir_root : str, default: None
|
|
1060
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
|
1109
1061
|
"""
|
|
1110
1062
|
...
|
|
1111
1063
|
|
|
1112
1064
|
@typing.overload
|
|
1113
|
-
def
|
|
1065
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1114
1066
|
...
|
|
1115
1067
|
|
|
1116
1068
|
@typing.overload
|
|
1117
|
-
def
|
|
1069
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1118
1070
|
...
|
|
1119
1071
|
|
|
1120
|
-
def
|
|
1072
|
+
def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load_policy: str = 'fresh', temp_dir_root: str = None):
|
|
1121
1073
|
"""
|
|
1122
|
-
|
|
1074
|
+
Enables checkpointing for a step.
|
|
1123
1075
|
|
|
1124
|
-
|
|
1076
|
+
> Examples
|
|
1125
1077
|
|
|
1126
|
-
|
|
1127
|
-
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
|
1128
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
1078
|
+
- Saving Checkpoints
|
|
1129
1079
|
|
|
1130
|
-
|
|
1131
|
-
|
|
1080
|
+
```python
|
|
1081
|
+
@checkpoint
|
|
1082
|
+
@step
|
|
1083
|
+
def train(self):
|
|
1084
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
|
1085
|
+
for i in range(self.epochs):
|
|
1086
|
+
# some training logic
|
|
1087
|
+
loss = model.train(self.dataset)
|
|
1088
|
+
if i % 10 == 0:
|
|
1089
|
+
model.save(
|
|
1090
|
+
current.checkpoint.directory,
|
|
1091
|
+
)
|
|
1092
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
|
1093
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
|
1094
|
+
self.latest_checkpoint = current.checkpoint.save(
|
|
1095
|
+
name="epoch_checkpoint",
|
|
1096
|
+
metadata={
|
|
1097
|
+
"epoch": i,
|
|
1098
|
+
"loss": loss,
|
|
1099
|
+
}
|
|
1100
|
+
)
|
|
1101
|
+
```
|
|
1132
1102
|
|
|
1103
|
+
- Using Loaded Checkpoints
|
|
1133
1104
|
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
@typing.overload
|
|
1146
|
-
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]]]:
|
|
1147
|
-
"""
|
|
1148
|
-
Specifies the PyPI packages for the step.
|
|
1105
|
+
```python
|
|
1106
|
+
@retry(times=3)
|
|
1107
|
+
@checkpoint
|
|
1108
|
+
@step
|
|
1109
|
+
def train(self):
|
|
1110
|
+
# Assume that the task has restarted and the previous attempt of the task
|
|
1111
|
+
# saved a checkpoint
|
|
1112
|
+
checkpoint_path = None
|
|
1113
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
|
1114
|
+
print("Loaded checkpoint from the previous attempt")
|
|
1115
|
+
checkpoint_path = current.checkpoint.directory
|
|
1149
1116
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1117
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
|
1118
|
+
for i in range(self.epochs):
|
|
1119
|
+
...
|
|
1120
|
+
```
|
|
1154
1121
|
|
|
1155
1122
|
|
|
1156
1123
|
Parameters
|
|
1157
1124
|
----------
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1125
|
+
load_policy : str, default: "fresh"
|
|
1126
|
+
The policy for loading the checkpoint. The following policies are supported:
|
|
1127
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
|
1128
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
|
1129
|
+
will be loaded at the start of the task.
|
|
1130
|
+
- "none": Do not load any checkpoint
|
|
1131
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
1132
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
1133
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
1134
|
+
created within the task will be loaded when the task is retries execution on failure.
|
|
1135
|
+
|
|
1136
|
+
temp_dir_root : str, default: None
|
|
1137
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
|
1164
1138
|
"""
|
|
1165
1139
|
...
|
|
1166
1140
|
|
|
1167
|
-
|
|
1168
|
-
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1169
|
-
...
|
|
1170
|
-
|
|
1171
|
-
@typing.overload
|
|
1172
|
-
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1173
|
-
...
|
|
1174
|
-
|
|
1175
|
-
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):
|
|
1141
|
+
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]]]:
|
|
1176
1142
|
"""
|
|
1177
|
-
Specifies
|
|
1178
|
-
|
|
1179
|
-
Information in this decorator will augment any
|
|
1180
|
-
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
1181
|
-
you can use `@pypi_base` to set packages required by all
|
|
1182
|
-
steps and use `@pypi` to specify step-specific overrides.
|
|
1143
|
+
Specifies that this step should execute on DGX cloud.
|
|
1183
1144
|
|
|
1184
1145
|
|
|
1185
1146
|
Parameters
|
|
1186
1147
|
----------
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1148
|
+
gpu : int
|
|
1149
|
+
Number of GPUs to use.
|
|
1150
|
+
gpu_type : str
|
|
1151
|
+
Type of Nvidia GPU to use.
|
|
1152
|
+
queue_timeout : int
|
|
1153
|
+
Time to keep the job in NVCF's queue.
|
|
1193
1154
|
"""
|
|
1194
1155
|
...
|
|
1195
1156
|
|
|
@@ -1273,211 +1234,170 @@ def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.
|
|
|
1273
1234
|
"""
|
|
1274
1235
|
...
|
|
1275
1236
|
|
|
1276
|
-
|
|
1237
|
+
@typing.overload
|
|
1238
|
+
def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: 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]]]:
|
|
1277
1239
|
"""
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
This decorator is useful when users wish to save data to a different datastore
|
|
1282
|
-
than what is configured in Metaflow. This can be for variety of reasons:
|
|
1283
|
-
|
|
1284
|
-
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
|
1285
|
-
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
|
1286
|
-
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
|
1287
|
-
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
|
1288
|
-
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
|
1289
|
-
|
|
1290
|
-
Usage:
|
|
1291
|
-
----------
|
|
1292
|
-
|
|
1293
|
-
- Using a custom IAM role to access the datastore.
|
|
1294
|
-
|
|
1295
|
-
```python
|
|
1296
|
-
@with_artifact_store(
|
|
1297
|
-
type="s3",
|
|
1298
|
-
config=lambda: {
|
|
1299
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
|
1300
|
-
"role_arn": ROLE,
|
|
1301
|
-
},
|
|
1302
|
-
)
|
|
1303
|
-
class MyFlow(FlowSpec):
|
|
1304
|
-
|
|
1305
|
-
@checkpoint
|
|
1306
|
-
@step
|
|
1307
|
-
def start(self):
|
|
1308
|
-
with open("my_file.txt", "w") as f:
|
|
1309
|
-
f.write("Hello, World!")
|
|
1310
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1311
|
-
self.next(self.end)
|
|
1312
|
-
|
|
1313
|
-
```
|
|
1314
|
-
|
|
1315
|
-
- Using credentials to access the s3-compatible datastore.
|
|
1316
|
-
|
|
1317
|
-
```python
|
|
1318
|
-
@with_artifact_store(
|
|
1319
|
-
type="s3",
|
|
1320
|
-
config=lambda: {
|
|
1321
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
|
1322
|
-
"client_params": {
|
|
1323
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1324
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1325
|
-
},
|
|
1326
|
-
},
|
|
1327
|
-
)
|
|
1328
|
-
class MyFlow(FlowSpec):
|
|
1329
|
-
|
|
1330
|
-
@checkpoint
|
|
1331
|
-
@step
|
|
1332
|
-
def start(self):
|
|
1333
|
-
with open("my_file.txt", "w") as f:
|
|
1334
|
-
f.write("Hello, World!")
|
|
1335
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1336
|
-
self.next(self.end)
|
|
1337
|
-
|
|
1338
|
-
```
|
|
1339
|
-
|
|
1340
|
-
- Accessing objects stored in external datastores after task execution.
|
|
1240
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
|
1241
|
+
the execution of a step.
|
|
1341
1242
|
|
|
1342
|
-
```python
|
|
1343
|
-
run = Run("CheckpointsTestsFlow/8992")
|
|
1344
|
-
with artifact_store_from(run=run, config={
|
|
1345
|
-
"client_params": {
|
|
1346
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1347
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1348
|
-
},
|
|
1349
|
-
}):
|
|
1350
|
-
with Checkpoint() as cp:
|
|
1351
|
-
latest = cp.list(
|
|
1352
|
-
task=run["start"].task
|
|
1353
|
-
)[0]
|
|
1354
|
-
print(latest)
|
|
1355
|
-
cp.load(
|
|
1356
|
-
latest,
|
|
1357
|
-
"test-checkpoints"
|
|
1358
|
-
)
|
|
1359
1243
|
|
|
1360
|
-
|
|
1361
|
-
with artifact_store_from(run=run, config={
|
|
1362
|
-
"client_params": {
|
|
1363
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1364
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1365
|
-
},
|
|
1366
|
-
}):
|
|
1367
|
-
load_model(
|
|
1368
|
-
task.data.model_ref,
|
|
1369
|
-
"test-models"
|
|
1370
|
-
)
|
|
1371
|
-
```
|
|
1372
|
-
Parameters:
|
|
1244
|
+
Parameters
|
|
1373
1245
|
----------
|
|
1246
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
|
1247
|
+
List of secret specs, defining how the secrets are to be retrieved
|
|
1248
|
+
role : str, optional, default: None
|
|
1249
|
+
Role to use for fetching secrets
|
|
1250
|
+
"""
|
|
1251
|
+
...
|
|
1252
|
+
|
|
1253
|
+
@typing.overload
|
|
1254
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1255
|
+
...
|
|
1256
|
+
|
|
1257
|
+
@typing.overload
|
|
1258
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1259
|
+
...
|
|
1260
|
+
|
|
1261
|
+
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]]] = [], role: typing.Optional[str] = None):
|
|
1262
|
+
"""
|
|
1263
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
|
1264
|
+
the execution of a step.
|
|
1374
1265
|
|
|
1375
|
-
type: str
|
|
1376
|
-
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
|
1377
1266
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
|
1385
|
-
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
|
1386
|
-
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
|
1267
|
+
Parameters
|
|
1268
|
+
----------
|
|
1269
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
|
1270
|
+
List of secret specs, defining how the secrets are to be retrieved
|
|
1271
|
+
role : str, optional, default: None
|
|
1272
|
+
Role to use for fetching secrets
|
|
1387
1273
|
"""
|
|
1388
1274
|
...
|
|
1389
1275
|
|
|
1390
1276
|
@typing.overload
|
|
1391
|
-
def
|
|
1277
|
+
def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1392
1278
|
"""
|
|
1393
|
-
Specifies the
|
|
1394
|
-
|
|
1279
|
+
Specifies the event(s) that this flow depends on.
|
|
1280
|
+
|
|
1281
|
+
```
|
|
1282
|
+
@trigger(event='foo')
|
|
1283
|
+
```
|
|
1284
|
+
or
|
|
1285
|
+
```
|
|
1286
|
+
@trigger(events=['foo', 'bar'])
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
Additionally, you can specify the parameter mappings
|
|
1290
|
+
to map event payload to Metaflow parameters for the flow.
|
|
1291
|
+
```
|
|
1292
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
1293
|
+
```
|
|
1294
|
+
or
|
|
1295
|
+
```
|
|
1296
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
1297
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
1298
|
+
```
|
|
1299
|
+
|
|
1300
|
+
'parameters' can also be a list of strings and tuples like so:
|
|
1301
|
+
```
|
|
1302
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
1303
|
+
```
|
|
1304
|
+
This is equivalent to:
|
|
1305
|
+
```
|
|
1306
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
1307
|
+
```
|
|
1395
1308
|
|
|
1396
1309
|
|
|
1397
1310
|
Parameters
|
|
1398
1311
|
----------
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
cron : str, optional, default None
|
|
1406
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
1407
|
-
specified by this expression.
|
|
1408
|
-
timezone : str, optional, default None
|
|
1409
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
1410
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
1312
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
|
1313
|
+
Event dependency for this flow.
|
|
1314
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
|
1315
|
+
Events dependency for this flow.
|
|
1316
|
+
options : Dict[str, Any], default {}
|
|
1317
|
+
Backend-specific configuration for tuning eventing behavior.
|
|
1411
1318
|
"""
|
|
1412
1319
|
...
|
|
1413
1320
|
|
|
1414
1321
|
@typing.overload
|
|
1415
|
-
def
|
|
1322
|
+
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1416
1323
|
...
|
|
1417
1324
|
|
|
1418
|
-
def
|
|
1325
|
+
def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
|
|
1419
1326
|
"""
|
|
1420
|
-
Specifies the
|
|
1421
|
-
|
|
1327
|
+
Specifies the event(s) that this flow depends on.
|
|
1328
|
+
|
|
1329
|
+
```
|
|
1330
|
+
@trigger(event='foo')
|
|
1331
|
+
```
|
|
1332
|
+
or
|
|
1333
|
+
```
|
|
1334
|
+
@trigger(events=['foo', 'bar'])
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
Additionally, you can specify the parameter mappings
|
|
1338
|
+
to map event payload to Metaflow parameters for the flow.
|
|
1339
|
+
```
|
|
1340
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
1341
|
+
```
|
|
1342
|
+
or
|
|
1343
|
+
```
|
|
1344
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
1345
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
'parameters' can also be a list of strings and tuples like so:
|
|
1349
|
+
```
|
|
1350
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
1351
|
+
```
|
|
1352
|
+
This is equivalent to:
|
|
1353
|
+
```
|
|
1354
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
1355
|
+
```
|
|
1422
1356
|
|
|
1423
1357
|
|
|
1424
1358
|
Parameters
|
|
1425
1359
|
----------
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
cron : str, optional, default None
|
|
1433
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
1434
|
-
specified by this expression.
|
|
1435
|
-
timezone : str, optional, default None
|
|
1436
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
1437
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
1360
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
|
1361
|
+
Event dependency for this flow.
|
|
1362
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
|
1363
|
+
Events dependency for this flow.
|
|
1364
|
+
options : Dict[str, Any], default {}
|
|
1365
|
+
Backend-specific configuration for tuning eventing behavior.
|
|
1438
1366
|
"""
|
|
1439
1367
|
...
|
|
1440
1368
|
|
|
1441
|
-
def
|
|
1369
|
+
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1442
1370
|
"""
|
|
1443
|
-
|
|
1444
|
-
|
|
1371
|
+
Specifies what flows belong to the same project.
|
|
1372
|
+
|
|
1373
|
+
A project-specific namespace is created for all flows that
|
|
1374
|
+
use the same `@project(name)`.
|
|
1445
1375
|
|
|
1446
1376
|
|
|
1447
1377
|
Parameters
|
|
1448
1378
|
----------
|
|
1449
|
-
timeout : int
|
|
1450
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
|
1451
|
-
poke_interval : int
|
|
1452
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
|
1453
|
-
mode : str
|
|
1454
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
|
1455
|
-
exponential_backoff : bool
|
|
1456
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
|
1457
|
-
pool : str
|
|
1458
|
-
the slot pool this task should run in,
|
|
1459
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
1460
|
-
soft_fail : bool
|
|
1461
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
1462
1379
|
name : str
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1380
|
+
Project name. Make sure that the name is unique amongst all
|
|
1381
|
+
projects that use the same production scheduler. The name may
|
|
1382
|
+
contain only lowercase alphanumeric characters and underscores.
|
|
1383
|
+
|
|
1384
|
+
branch : Optional[str], default None
|
|
1385
|
+
The branch to use. If not specified, the branch is set to
|
|
1386
|
+
`user.<username>` unless `production` is set to `True`. This can
|
|
1387
|
+
also be set on the command line using `--branch` as a top-level option.
|
|
1388
|
+
It is an error to specify `branch` in the decorator and on the command line.
|
|
1389
|
+
|
|
1390
|
+
production : bool, default False
|
|
1391
|
+
Whether or not the branch is the production branch. This can also be set on the
|
|
1392
|
+
command line using `--production` as a top-level option. It is an error to specify
|
|
1393
|
+
`production` in the decorator and on the command line.
|
|
1394
|
+
The project branch name will be:
|
|
1395
|
+
- if `branch` is specified:
|
|
1396
|
+
- if `production` is True: `prod.<branch>`
|
|
1397
|
+
- if `production` is False: `test.<branch>`
|
|
1398
|
+
- if `branch` is not specified:
|
|
1399
|
+
- if `production` is True: `prod`
|
|
1400
|
+
- if `production` is False: `user.<username>`
|
|
1481
1401
|
"""
|
|
1482
1402
|
...
|
|
1483
1403
|
|
|
@@ -1525,43 +1445,96 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
|
|
|
1525
1445
|
...
|
|
1526
1446
|
|
|
1527
1447
|
@typing.overload
|
|
1528
|
-
def
|
|
1448
|
+
def schedule(*, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1529
1449
|
"""
|
|
1530
|
-
Specifies the
|
|
1450
|
+
Specifies the times when the flow should be run when running on a
|
|
1451
|
+
production scheduler.
|
|
1531
1452
|
|
|
1532
|
-
Use `@pypi_base` to set common packages required by all
|
|
1533
|
-
steps and use `@pypi` to specify step-specific overrides.
|
|
1534
1453
|
|
|
1535
1454
|
Parameters
|
|
1536
1455
|
----------
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1456
|
+
hourly : bool, default False
|
|
1457
|
+
Run the workflow hourly.
|
|
1458
|
+
daily : bool, default True
|
|
1459
|
+
Run the workflow daily.
|
|
1460
|
+
weekly : bool, default False
|
|
1461
|
+
Run the workflow weekly.
|
|
1462
|
+
cron : str, optional, default None
|
|
1463
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
1464
|
+
specified by this expression.
|
|
1465
|
+
timezone : str, optional, default None
|
|
1466
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
1467
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
1543
1468
|
"""
|
|
1544
1469
|
...
|
|
1545
1470
|
|
|
1546
1471
|
@typing.overload
|
|
1547
|
-
def
|
|
1472
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1548
1473
|
...
|
|
1549
1474
|
|
|
1550
|
-
def
|
|
1475
|
+
def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
|
|
1551
1476
|
"""
|
|
1552
|
-
Specifies the
|
|
1477
|
+
Specifies the times when the flow should be run when running on a
|
|
1478
|
+
production scheduler.
|
|
1553
1479
|
|
|
1554
|
-
Use `@pypi_base` to set common packages required by all
|
|
1555
|
-
steps and use `@pypi` to specify step-specific overrides.
|
|
1556
1480
|
|
|
1557
1481
|
Parameters
|
|
1558
1482
|
----------
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1483
|
+
hourly : bool, default False
|
|
1484
|
+
Run the workflow hourly.
|
|
1485
|
+
daily : bool, default True
|
|
1486
|
+
Run the workflow daily.
|
|
1487
|
+
weekly : bool, default False
|
|
1488
|
+
Run the workflow weekly.
|
|
1489
|
+
cron : str, optional, default None
|
|
1490
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
1491
|
+
specified by this expression.
|
|
1492
|
+
timezone : str, optional, default None
|
|
1493
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
1494
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
1495
|
+
"""
|
|
1496
|
+
...
|
|
1497
|
+
|
|
1498
|
+
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]]:
|
|
1499
|
+
"""
|
|
1500
|
+
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.
|
|
1501
|
+
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.
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
Parameters
|
|
1505
|
+
----------
|
|
1506
|
+
timeout : int
|
|
1507
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
|
1508
|
+
poke_interval : int
|
|
1509
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
|
1510
|
+
mode : str
|
|
1511
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
|
1512
|
+
exponential_backoff : bool
|
|
1513
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
|
1514
|
+
pool : str
|
|
1515
|
+
the slot pool this task should run in,
|
|
1516
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
1517
|
+
soft_fail : bool
|
|
1518
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
1519
|
+
name : str
|
|
1520
|
+
Name of the sensor on Airflow
|
|
1521
|
+
description : str
|
|
1522
|
+
Description of sensor in the Airflow UI
|
|
1523
|
+
external_dag_id : str
|
|
1524
|
+
The dag_id that contains the task you want to wait for.
|
|
1525
|
+
external_task_ids : List[str]
|
|
1526
|
+
The list of task_ids that you want to wait for.
|
|
1527
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
|
1528
|
+
allowed_states : List[str]
|
|
1529
|
+
Iterable of allowed states, (Default: ['success'])
|
|
1530
|
+
failed_states : List[str]
|
|
1531
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
|
1532
|
+
execution_delta : datetime.timedelta
|
|
1533
|
+
time difference with the previous execution to look at,
|
|
1534
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
|
1535
|
+
check_existence: bool
|
|
1536
|
+
Set to True to check if the external task exists or check if
|
|
1537
|
+
the DAG to wait for exists. (Default: True)
|
|
1565
1538
|
"""
|
|
1566
1539
|
...
|
|
1567
1540
|
|
|
@@ -1717,131 +1690,158 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
|
|
|
1717
1690
|
"""
|
|
1718
1691
|
...
|
|
1719
1692
|
|
|
1720
|
-
def
|
|
1693
|
+
def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
|
|
1721
1694
|
"""
|
|
1722
|
-
|
|
1695
|
+
Allows setting external datastores to save data for the
|
|
1696
|
+
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
|
1723
1697
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1698
|
+
This decorator is useful when users wish to save data to a different datastore
|
|
1699
|
+
than what is configured in Metaflow. This can be for variety of reasons:
|
|
1726
1700
|
|
|
1701
|
+
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
|
1702
|
+
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
|
1703
|
+
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
|
1704
|
+
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
|
1705
|
+
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
|
1727
1706
|
|
|
1728
|
-
|
|
1707
|
+
Usage:
|
|
1729
1708
|
----------
|
|
1730
|
-
name : str
|
|
1731
|
-
Project name. Make sure that the name is unique amongst all
|
|
1732
|
-
projects that use the same production scheduler. The name may
|
|
1733
|
-
contain only lowercase alphanumeric characters and underscores.
|
|
1734
1709
|
|
|
1735
|
-
|
|
1736
|
-
The branch to use. If not specified, the branch is set to
|
|
1737
|
-
`user.<username>` unless `production` is set to `True`. This can
|
|
1738
|
-
also be set on the command line using `--branch` as a top-level option.
|
|
1739
|
-
It is an error to specify `branch` in the decorator and on the command line.
|
|
1710
|
+
- Using a custom IAM role to access the datastore.
|
|
1740
1711
|
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1712
|
+
```python
|
|
1713
|
+
@with_artifact_store(
|
|
1714
|
+
type="s3",
|
|
1715
|
+
config=lambda: {
|
|
1716
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
|
1717
|
+
"role_arn": ROLE,
|
|
1718
|
+
},
|
|
1719
|
+
)
|
|
1720
|
+
class MyFlow(FlowSpec):
|
|
1721
|
+
|
|
1722
|
+
@checkpoint
|
|
1723
|
+
@step
|
|
1724
|
+
def start(self):
|
|
1725
|
+
with open("my_file.txt", "w") as f:
|
|
1726
|
+
f.write("Hello, World!")
|
|
1727
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1728
|
+
self.next(self.end)
|
|
1729
|
+
|
|
1730
|
+
```
|
|
1731
|
+
|
|
1732
|
+
- Using credentials to access the s3-compatible datastore.
|
|
1733
|
+
|
|
1734
|
+
```python
|
|
1735
|
+
@with_artifact_store(
|
|
1736
|
+
type="s3",
|
|
1737
|
+
config=lambda: {
|
|
1738
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
|
1739
|
+
"client_params": {
|
|
1740
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1741
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1742
|
+
},
|
|
1743
|
+
},
|
|
1744
|
+
)
|
|
1745
|
+
class MyFlow(FlowSpec):
|
|
1746
|
+
|
|
1747
|
+
@checkpoint
|
|
1748
|
+
@step
|
|
1749
|
+
def start(self):
|
|
1750
|
+
with open("my_file.txt", "w") as f:
|
|
1751
|
+
f.write("Hello, World!")
|
|
1752
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1753
|
+
self.next(self.end)
|
|
1754
|
+
|
|
1755
|
+
```
|
|
1756
|
+
|
|
1757
|
+
- Accessing objects stored in external datastores after task execution.
|
|
1758
|
+
|
|
1759
|
+
```python
|
|
1760
|
+
run = Run("CheckpointsTestsFlow/8992")
|
|
1761
|
+
with artifact_store_from(run=run, config={
|
|
1762
|
+
"client_params": {
|
|
1763
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1764
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1765
|
+
},
|
|
1766
|
+
}):
|
|
1767
|
+
with Checkpoint() as cp:
|
|
1768
|
+
latest = cp.list(
|
|
1769
|
+
task=run["start"].task
|
|
1770
|
+
)[0]
|
|
1771
|
+
print(latest)
|
|
1772
|
+
cp.load(
|
|
1773
|
+
latest,
|
|
1774
|
+
"test-checkpoints"
|
|
1775
|
+
)
|
|
1776
|
+
|
|
1777
|
+
task = Task("TorchTuneFlow/8484/train/53673")
|
|
1778
|
+
with artifact_store_from(run=run, config={
|
|
1779
|
+
"client_params": {
|
|
1780
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1781
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1782
|
+
},
|
|
1783
|
+
}):
|
|
1784
|
+
load_model(
|
|
1785
|
+
task.data.model_ref,
|
|
1786
|
+
"test-models"
|
|
1787
|
+
)
|
|
1788
|
+
```
|
|
1789
|
+
Parameters:
|
|
1790
|
+
----------
|
|
1791
|
+
|
|
1792
|
+
type: str
|
|
1793
|
+
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
|
1794
|
+
|
|
1795
|
+
config: dict or Callable
|
|
1796
|
+
Dictionary of configuration options for the datastore. The following keys are required:
|
|
1797
|
+
- root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
|
|
1798
|
+
- example: 's3://bucket-name/path/to/root'
|
|
1799
|
+
- example: 'gs://bucket-name/path/to/root'
|
|
1800
|
+
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
|
1801
|
+
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
|
1802
|
+
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
|
1803
|
+
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
|
1752
1804
|
"""
|
|
1753
1805
|
...
|
|
1754
1806
|
|
|
1755
1807
|
@typing.overload
|
|
1756
|
-
def
|
|
1808
|
+
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1757
1809
|
"""
|
|
1758
|
-
Specifies the
|
|
1759
|
-
|
|
1760
|
-
```
|
|
1761
|
-
@trigger(event='foo')
|
|
1762
|
-
```
|
|
1763
|
-
or
|
|
1764
|
-
```
|
|
1765
|
-
@trigger(events=['foo', 'bar'])
|
|
1766
|
-
```
|
|
1767
|
-
|
|
1768
|
-
Additionally, you can specify the parameter mappings
|
|
1769
|
-
to map event payload to Metaflow parameters for the flow.
|
|
1770
|
-
```
|
|
1771
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
1772
|
-
```
|
|
1773
|
-
or
|
|
1774
|
-
```
|
|
1775
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
1776
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
1777
|
-
```
|
|
1778
|
-
|
|
1779
|
-
'parameters' can also be a list of strings and tuples like so:
|
|
1780
|
-
```
|
|
1781
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
1782
|
-
```
|
|
1783
|
-
This is equivalent to:
|
|
1784
|
-
```
|
|
1785
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
1786
|
-
```
|
|
1810
|
+
Specifies the PyPI packages for all steps of the flow.
|
|
1787
1811
|
|
|
1812
|
+
Use `@pypi_base` to set common packages required by all
|
|
1813
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1788
1814
|
|
|
1789
1815
|
Parameters
|
|
1790
1816
|
----------
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1817
|
+
packages : Dict[str, str], default: {}
|
|
1818
|
+
Packages to use for this flow. The key is the name of the package
|
|
1819
|
+
and the value is the version to use.
|
|
1820
|
+
python : str, optional, default: None
|
|
1821
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1822
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1797
1823
|
"""
|
|
1798
1824
|
...
|
|
1799
1825
|
|
|
1800
1826
|
@typing.overload
|
|
1801
|
-
def
|
|
1827
|
+
def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1802
1828
|
...
|
|
1803
1829
|
|
|
1804
|
-
def
|
|
1830
|
+
def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
|
1805
1831
|
"""
|
|
1806
|
-
Specifies the
|
|
1807
|
-
|
|
1808
|
-
```
|
|
1809
|
-
@trigger(event='foo')
|
|
1810
|
-
```
|
|
1811
|
-
or
|
|
1812
|
-
```
|
|
1813
|
-
@trigger(events=['foo', 'bar'])
|
|
1814
|
-
```
|
|
1815
|
-
|
|
1816
|
-
Additionally, you can specify the parameter mappings
|
|
1817
|
-
to map event payload to Metaflow parameters for the flow.
|
|
1818
|
-
```
|
|
1819
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
1820
|
-
```
|
|
1821
|
-
or
|
|
1822
|
-
```
|
|
1823
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
1824
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
1825
|
-
```
|
|
1826
|
-
|
|
1827
|
-
'parameters' can also be a list of strings and tuples like so:
|
|
1828
|
-
```
|
|
1829
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
1830
|
-
```
|
|
1831
|
-
This is equivalent to:
|
|
1832
|
-
```
|
|
1833
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
1834
|
-
```
|
|
1832
|
+
Specifies the PyPI packages for all steps of the flow.
|
|
1835
1833
|
|
|
1834
|
+
Use `@pypi_base` to set common packages required by all
|
|
1835
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1836
1836
|
|
|
1837
1837
|
Parameters
|
|
1838
1838
|
----------
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1839
|
+
packages : Dict[str, str], default: {}
|
|
1840
|
+
Packages to use for this flow. The key is the name of the package
|
|
1841
|
+
and the value is the version to use.
|
|
1842
|
+
python : str, optional, default: None
|
|
1843
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1844
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1845
1845
|
"""
|
|
1846
1846
|
...
|
|
1847
1847
|
|