ob-metaflow-stubs 6.0.10.18__py2.py3-none-any.whl → 6.0.10.19__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.
Potentially problematic release.
This version of ob-metaflow-stubs might be problematic. Click here for more details.
- metaflow-stubs/__init__.pyi +1064 -1064
- metaflow-stubs/cards.pyi +2 -2
- metaflow-stubs/cli.pyi +2 -2
- metaflow-stubs/cli_components/__init__.pyi +2 -2
- metaflow-stubs/cli_components/utils.pyi +2 -2
- metaflow-stubs/client/__init__.pyi +2 -2
- metaflow-stubs/client/core.pyi +6 -6
- metaflow-stubs/client/filecache.pyi +3 -3
- metaflow-stubs/events.pyi +3 -3
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +6 -6
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +4 -4
- metaflow-stubs/meta_files.pyi +2 -2
- metaflow-stubs/metadata_provider/__init__.pyi +2 -2
- metaflow-stubs/metadata_provider/heartbeat.pyi +2 -2
- metaflow-stubs/metadata_provider/metadata.pyi +3 -3
- metaflow-stubs/metadata_provider/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +2 -2
- metaflow-stubs/metaflow_current.pyi +66 -66
- metaflow-stubs/metaflow_git.pyi +2 -2
- metaflow-stubs/mf_extensions/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +5 -5
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +5 -5
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +5 -5
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/cards/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/cards/hf_hub_card.pyi +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +5 -5
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_state_machine.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/spinners.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_cli.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/capsule.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/click_importer.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/code_packager.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/cli_generator.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/config_utils.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/schema_export.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/typed_configs.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/unified_config.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/dependencies.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/deployer.pyi +5 -5
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/experimental/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/perimeters.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/utils.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/assume_role_decorator.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/toplevel/s3_proxy.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/ob_internal.pyi +2 -2
- metaflow-stubs/packaging_sys/__init__.pyi +6 -6
- metaflow-stubs/packaging_sys/backend.pyi +4 -4
- metaflow-stubs/packaging_sys/distribution_support.pyi +4 -4
- metaflow-stubs/packaging_sys/tar_backend.pyi +6 -6
- metaflow-stubs/packaging_sys/utils.pyi +2 -2
- metaflow-stubs/packaging_sys/v1.pyi +3 -3
- metaflow-stubs/parameters.pyi +4 -4
- metaflow-stubs/plugins/__init__.pyi +12 -12
- metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
- metaflow-stubs/plugins/airflow/exception.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +4 -4
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +4 -4
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +4 -4
- metaflow-stubs/plugins/argo/exit_hooks.pyi +3 -3
- metaflow-stubs/plugins/aws/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
- metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +5 -5
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +4 -4
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +4 -4
- metaflow-stubs/plugins/azure/__init__.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +5 -5
- metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
- metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/cards/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_client.pyi +3 -3
- metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
- metaflow-stubs/plugins/cards/card_decorator.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/json_viewer.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +2 -2
- metaflow-stubs/plugins/cards/exception.pyi +2 -2
- metaflow-stubs/plugins/catch_decorator.pyi +3 -3
- metaflow-stubs/plugins/datatools/__init__.pyi +2 -2
- metaflow-stubs/plugins/datatools/local.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3.pyi +5 -5
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
- metaflow-stubs/plugins/debug_logger.pyi +2 -2
- metaflow-stubs/plugins/debug_monitor.pyi +2 -2
- metaflow-stubs/plugins/environment_decorator.pyi +2 -2
- metaflow-stubs/plugins/events_decorator.pyi +2 -2
- metaflow-stubs/plugins/exit_hook/__init__.pyi +2 -2
- metaflow-stubs/plugins/exit_hook/exit_hook_decorator.pyi +2 -2
- metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
- metaflow-stubs/plugins/frameworks/pytorch.pyi +2 -2
- metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +5 -5
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
- metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +3 -3
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +2 -2
- metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/plugins/optuna/__init__.pyi +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
- metaflow-stubs/plugins/parsers.pyi +2 -2
- metaflow-stubs/plugins/perimeters.pyi +2 -2
- metaflow-stubs/plugins/project_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_environment.pyi +6 -6
- metaflow-stubs/plugins/pypi/parsers.pyi +2 -2
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
- metaflow-stubs/plugins/pypi/utils.pyi +2 -2
- metaflow-stubs/plugins/resources_decorator.pyi +2 -2
- metaflow-stubs/plugins/retry_decorator.pyi +2 -2
- metaflow-stubs/plugins/secrets/__init__.pyi +3 -3
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +4 -4
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_func.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_spec.pyi +2 -2
- metaflow-stubs/plugins/secrets/utils.pyi +2 -2
- metaflow-stubs/plugins/snowflake/__init__.pyi +2 -2
- metaflow-stubs/plugins/storage_executor.pyi +2 -2
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
- metaflow-stubs/plugins/timeout_decorator.pyi +3 -3
- metaflow-stubs/plugins/torchtune/__init__.pyi +2 -2
- metaflow-stubs/plugins/uv/__init__.pyi +2 -2
- metaflow-stubs/plugins/uv/uv_environment.pyi +3 -3
- metaflow-stubs/profilers/__init__.pyi +2 -2
- metaflow-stubs/pylint_wrapper.pyi +2 -2
- metaflow-stubs/runner/__init__.pyi +2 -2
- metaflow-stubs/runner/deployer.pyi +6 -6
- metaflow-stubs/runner/deployer_impl.pyi +3 -3
- metaflow-stubs/runner/metaflow_runner.pyi +4 -4
- metaflow-stubs/runner/nbdeploy.pyi +2 -2
- metaflow-stubs/runner/nbrun.pyi +2 -2
- metaflow-stubs/runner/subprocess_manager.pyi +2 -2
- metaflow-stubs/runner/utils.pyi +3 -3
- metaflow-stubs/system/__init__.pyi +2 -2
- metaflow-stubs/system/system_logger.pyi +3 -3
- metaflow-stubs/system/system_monitor.pyi +2 -2
- metaflow-stubs/tagging_util.pyi +2 -2
- metaflow-stubs/tuple_util.pyi +2 -2
- metaflow-stubs/user_configs/__init__.pyi +2 -2
- metaflow-stubs/user_configs/config_options.pyi +4 -4
- metaflow-stubs/user_configs/config_parameters.pyi +6 -6
- metaflow-stubs/user_decorators/__init__.pyi +2 -2
- metaflow-stubs/user_decorators/common.pyi +2 -2
- metaflow-stubs/user_decorators/mutable_flow.pyi +5 -5
- metaflow-stubs/user_decorators/mutable_step.pyi +4 -4
- metaflow-stubs/user_decorators/user_flow_decorator.pyi +4 -4
- metaflow-stubs/user_decorators/user_step_decorator.pyi +5 -5
- {ob_metaflow_stubs-6.0.10.18.dist-info → ob_metaflow_stubs-6.0.10.19.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.10.19.dist-info/RECORD +266 -0
- ob_metaflow_stubs-6.0.10.18.dist-info/RECORD +0 -266
- {ob_metaflow_stubs-6.0.10.18.dist-info → ob_metaflow_stubs-6.0.10.19.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.10.18.dist-info → ob_metaflow_stubs-6.0.10.19.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
|
-
# MF version: 2.18.
|
|
4
|
-
# Generated on 2025-10-
|
|
3
|
+
# MF version: 2.18.13.1+obcheckpoint(0.2.8);ob(v1) #
|
|
4
|
+
# Generated on 2025-10-21T09:01:27.410960 #
|
|
5
5
|
######################################################################################################
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
@@ -39,10 +39,10 @@ from .user_decorators.user_step_decorator import UserStepDecorator as UserStepDe
|
|
|
39
39
|
from .user_decorators.user_step_decorator import StepMutator as StepMutator
|
|
40
40
|
from .user_decorators.user_step_decorator import user_step_decorator as user_step_decorator
|
|
41
41
|
from .user_decorators.user_flow_decorator import FlowMutator as FlowMutator
|
|
42
|
-
from . import
|
|
42
|
+
from . import events as events
|
|
43
43
|
from . import metaflow_git as metaflow_git
|
|
44
|
+
from . import cards as cards
|
|
44
45
|
from . import tuple_util as tuple_util
|
|
45
|
-
from . import events as events
|
|
46
46
|
from . import runner as runner
|
|
47
47
|
from . import plugins as plugins
|
|
48
48
|
from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
|
|
@@ -50,8 +50,8 @@ from . import includefile as includefile
|
|
|
50
50
|
from .includefile import IncludeFile as IncludeFile
|
|
51
51
|
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
|
|
52
52
|
from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
|
|
53
|
-
from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
|
|
54
53
|
from .plugins.parsers import yaml_parser as yaml_parser
|
|
54
|
+
from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
|
|
55
55
|
from . import client as client
|
|
56
56
|
from .client.core import namespace as namespace
|
|
57
57
|
from .client.core import get_namespace as get_namespace
|
|
@@ -169,67 +169,134 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
|
169
169
|
"""
|
|
170
170
|
...
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
@typing.overload
|
|
173
|
+
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]]]:
|
|
173
174
|
"""
|
|
174
|
-
|
|
175
|
-
It exists to make it easier for users to know that this decorator should only be used with
|
|
176
|
-
a Neo Cloud like Nebius. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
175
|
+
Specifies the resources needed when executing this step.
|
|
177
176
|
|
|
177
|
+
Use `@resources` to specify the resource requirements
|
|
178
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
You can choose the compute layer on the command line by executing e.g.
|
|
181
|
+
```
|
|
182
|
+
python myflow.py run --with batch
|
|
183
|
+
```
|
|
184
|
+
or
|
|
185
|
+
```
|
|
186
|
+
python myflow.py run --with kubernetes
|
|
187
|
+
```
|
|
188
|
+
which executes the flow on the desired system using the
|
|
189
|
+
requirements specified in `@resources`.
|
|
181
190
|
|
|
182
|
-
This decorator requires an integration in the Outerbounds platform that
|
|
183
|
-
points to an external bucket. It affects S3 operations performed via
|
|
184
|
-
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
185
191
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
Parameters
|
|
193
|
+
----------
|
|
194
|
+
cpu : int, default 1
|
|
195
|
+
Number of CPUs required for this step.
|
|
196
|
+
gpu : int, optional, default None
|
|
197
|
+
Number of GPUs required for this step.
|
|
198
|
+
disk : int, optional, default None
|
|
199
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
200
|
+
memory : int, default 4096
|
|
201
|
+
Memory size (in MB) required for this step.
|
|
202
|
+
shared_memory : int, optional, default None
|
|
203
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
204
|
+
This parameter maps to the `--shm-size` option in Docker.
|
|
205
|
+
"""
|
|
206
|
+
...
|
|
207
|
+
|
|
208
|
+
@typing.overload
|
|
209
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
210
|
+
...
|
|
211
|
+
|
|
212
|
+
@typing.overload
|
|
213
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
214
|
+
...
|
|
215
|
+
|
|
216
|
+
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):
|
|
217
|
+
"""
|
|
218
|
+
Specifies the resources needed when executing this step.
|
|
192
219
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
- If the object is present in the external object store, the proxy
|
|
196
|
-
streams it directly from there without accessing the requested origin
|
|
197
|
-
bucket.
|
|
198
|
-
- If the object is not present in the external storage, the proxy
|
|
199
|
-
fetches it from the requested bucket, caches it in the external
|
|
200
|
-
storage, and streams the response from the origin bucket.
|
|
220
|
+
Use `@resources` to specify the resource requirements
|
|
221
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
201
222
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
223
|
+
You can choose the compute layer on the command line by executing e.g.
|
|
224
|
+
```
|
|
225
|
+
python myflow.py run --with batch
|
|
226
|
+
```
|
|
227
|
+
or
|
|
228
|
+
```
|
|
229
|
+
python myflow.py run --with kubernetes
|
|
230
|
+
```
|
|
231
|
+
which executes the flow on the desired system using the
|
|
232
|
+
requirements specified in `@resources`.
|
|
208
233
|
|
|
209
|
-
Write operations
|
|
210
|
-
----------------
|
|
211
|
-
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
212
|
-
whether writes also persist objects in the cache.
|
|
213
234
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
235
|
+
Parameters
|
|
236
|
+
----------
|
|
237
|
+
cpu : int, default 1
|
|
238
|
+
Number of CPUs required for this step.
|
|
239
|
+
gpu : int, optional, default None
|
|
240
|
+
Number of GPUs required for this step.
|
|
241
|
+
disk : int, optional, default None
|
|
242
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
243
|
+
memory : int, default 4096
|
|
244
|
+
Memory size (in MB) required for this step.
|
|
245
|
+
shared_memory : int, optional, default None
|
|
246
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
247
|
+
This parameter maps to the `--shm-size` option in Docker.
|
|
248
|
+
"""
|
|
249
|
+
...
|
|
250
|
+
|
|
251
|
+
@typing.overload
|
|
252
|
+
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]]]:
|
|
253
|
+
"""
|
|
254
|
+
Specifies environment variables to be set prior to the execution of a step.
|
|
218
255
|
|
|
219
256
|
|
|
220
257
|
Parameters
|
|
221
258
|
----------
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
259
|
+
vars : Dict[str, str], default {}
|
|
260
|
+
Dictionary of environment variables to set.
|
|
261
|
+
"""
|
|
262
|
+
...
|
|
263
|
+
|
|
264
|
+
@typing.overload
|
|
265
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
266
|
+
...
|
|
267
|
+
|
|
268
|
+
@typing.overload
|
|
269
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
270
|
+
...
|
|
271
|
+
|
|
272
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
|
273
|
+
"""
|
|
274
|
+
Specifies environment variables to be set prior to the execution of a step.
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
Parameters
|
|
278
|
+
----------
|
|
279
|
+
vars : Dict[str, str], default {}
|
|
280
|
+
Dictionary of environment variables to set.
|
|
281
|
+
"""
|
|
282
|
+
...
|
|
283
|
+
|
|
284
|
+
@typing.overload
|
|
285
|
+
def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
286
|
+
"""
|
|
287
|
+
A simple decorator that demonstrates using CardDecoratorInjector
|
|
288
|
+
to inject a card and render simple markdown content.
|
|
289
|
+
"""
|
|
290
|
+
...
|
|
291
|
+
|
|
292
|
+
@typing.overload
|
|
293
|
+
def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
294
|
+
...
|
|
295
|
+
|
|
296
|
+
def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
297
|
+
"""
|
|
298
|
+
A simple decorator that demonstrates using CardDecoratorInjector
|
|
299
|
+
to inject a card and render simple markdown content.
|
|
233
300
|
"""
|
|
234
301
|
...
|
|
235
302
|
|
|
@@ -293,149 +360,76 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
|
293
360
|
...
|
|
294
361
|
|
|
295
362
|
@typing.overload
|
|
296
|
-
def
|
|
363
|
+
def retry(*, times: int = 3, minutes_between_retries: int = 2) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
297
364
|
"""
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
> Examples
|
|
301
|
-
|
|
302
|
-
- Saving Checkpoints
|
|
303
|
-
|
|
304
|
-
```python
|
|
305
|
-
@checkpoint
|
|
306
|
-
@step
|
|
307
|
-
def train(self):
|
|
308
|
-
model = create_model(self.parameters, checkpoint_path = None)
|
|
309
|
-
for i in range(self.epochs):
|
|
310
|
-
# some training logic
|
|
311
|
-
loss = model.train(self.dataset)
|
|
312
|
-
if i % 10 == 0:
|
|
313
|
-
model.save(
|
|
314
|
-
current.checkpoint.directory,
|
|
315
|
-
)
|
|
316
|
-
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
|
317
|
-
# and returns a reference dictionary to the checkpoint saved in the datastore
|
|
318
|
-
self.latest_checkpoint = current.checkpoint.save(
|
|
319
|
-
name="epoch_checkpoint",
|
|
320
|
-
metadata={
|
|
321
|
-
"epoch": i,
|
|
322
|
-
"loss": loss,
|
|
323
|
-
}
|
|
324
|
-
)
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
- Using Loaded Checkpoints
|
|
365
|
+
Specifies the number of times the task corresponding
|
|
366
|
+
to a step needs to be retried.
|
|
328
367
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
@step
|
|
333
|
-
def train(self):
|
|
334
|
-
# Assume that the task has restarted and the previous attempt of the task
|
|
335
|
-
# saved a checkpoint
|
|
336
|
-
checkpoint_path = None
|
|
337
|
-
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
|
338
|
-
print("Loaded checkpoint from the previous attempt")
|
|
339
|
-
checkpoint_path = current.checkpoint.directory
|
|
368
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
|
369
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
370
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
|
340
371
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
```
|
|
372
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
373
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
|
374
|
+
ensuring that the flow execution can continue.
|
|
345
375
|
|
|
346
376
|
|
|
347
377
|
Parameters
|
|
348
378
|
----------
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
will be loaded at the start of the task.
|
|
354
|
-
- "none": Do not load any checkpoint
|
|
355
|
-
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
356
|
-
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
357
|
-
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
358
|
-
created within the task will be loaded when the task is retries execution on failure.
|
|
359
|
-
|
|
360
|
-
temp_dir_root : str, default: None
|
|
361
|
-
The root directory under which `current.checkpoint.directory` will be created.
|
|
379
|
+
times : int, default 3
|
|
380
|
+
Number of times to retry this task.
|
|
381
|
+
minutes_between_retries : int, default 2
|
|
382
|
+
Number of minutes between retries.
|
|
362
383
|
"""
|
|
363
384
|
...
|
|
364
385
|
|
|
365
386
|
@typing.overload
|
|
366
|
-
def
|
|
387
|
+
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
367
388
|
...
|
|
368
389
|
|
|
369
390
|
@typing.overload
|
|
370
|
-
def
|
|
391
|
+
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
371
392
|
...
|
|
372
393
|
|
|
373
|
-
def
|
|
394
|
+
def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, times: int = 3, minutes_between_retries: int = 2):
|
|
374
395
|
"""
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
> Examples
|
|
396
|
+
Specifies the number of times the task corresponding
|
|
397
|
+
to a step needs to be retried.
|
|
378
398
|
|
|
379
|
-
|
|
399
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
|
400
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
401
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
|
380
402
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
def train(self):
|
|
385
|
-
model = create_model(self.parameters, checkpoint_path = None)
|
|
386
|
-
for i in range(self.epochs):
|
|
387
|
-
# some training logic
|
|
388
|
-
loss = model.train(self.dataset)
|
|
389
|
-
if i % 10 == 0:
|
|
390
|
-
model.save(
|
|
391
|
-
current.checkpoint.directory,
|
|
392
|
-
)
|
|
393
|
-
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
|
394
|
-
# and returns a reference dictionary to the checkpoint saved in the datastore
|
|
395
|
-
self.latest_checkpoint = current.checkpoint.save(
|
|
396
|
-
name="epoch_checkpoint",
|
|
397
|
-
metadata={
|
|
398
|
-
"epoch": i,
|
|
399
|
-
"loss": loss,
|
|
400
|
-
}
|
|
401
|
-
)
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
- Using Loaded Checkpoints
|
|
405
|
-
|
|
406
|
-
```python
|
|
407
|
-
@retry(times=3)
|
|
408
|
-
@checkpoint
|
|
409
|
-
@step
|
|
410
|
-
def train(self):
|
|
411
|
-
# Assume that the task has restarted and the previous attempt of the task
|
|
412
|
-
# saved a checkpoint
|
|
413
|
-
checkpoint_path = None
|
|
414
|
-
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
|
415
|
-
print("Loaded checkpoint from the previous attempt")
|
|
416
|
-
checkpoint_path = current.checkpoint.directory
|
|
417
|
-
|
|
418
|
-
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
|
419
|
-
for i in range(self.epochs):
|
|
420
|
-
...
|
|
421
|
-
```
|
|
403
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
404
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
|
405
|
+
ensuring that the flow execution can continue.
|
|
422
406
|
|
|
423
407
|
|
|
424
408
|
Parameters
|
|
425
409
|
----------
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
410
|
+
times : int, default 3
|
|
411
|
+
Number of times to retry this task.
|
|
412
|
+
minutes_between_retries : int, default 2
|
|
413
|
+
Number of minutes between retries.
|
|
414
|
+
"""
|
|
415
|
+
...
|
|
416
|
+
|
|
417
|
+
@typing.overload
|
|
418
|
+
def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
419
|
+
"""
|
|
420
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
421
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
422
|
+
"""
|
|
423
|
+
...
|
|
424
|
+
|
|
425
|
+
@typing.overload
|
|
426
|
+
def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
427
|
+
...
|
|
428
|
+
|
|
429
|
+
def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
430
|
+
"""
|
|
431
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
432
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
439
433
|
"""
|
|
440
434
|
...
|
|
441
435
|
|
|
@@ -488,408 +482,207 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
|
|
|
488
482
|
"""
|
|
489
483
|
...
|
|
490
484
|
|
|
491
|
-
|
|
492
|
-
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
493
|
-
"""
|
|
494
|
-
Internal decorator to support Fast bakery
|
|
495
|
-
"""
|
|
496
|
-
...
|
|
497
|
-
|
|
498
|
-
@typing.overload
|
|
499
|
-
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
500
|
-
...
|
|
501
|
-
|
|
502
|
-
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
503
|
-
"""
|
|
504
|
-
Internal decorator to support Fast bakery
|
|
505
|
-
"""
|
|
506
|
-
...
|
|
507
|
-
|
|
508
|
-
@typing.overload
|
|
509
|
-
def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
510
|
-
"""
|
|
511
|
-
Decorator prototype for all step decorators. This function gets specialized
|
|
512
|
-
and imported for all decorators types by _import_plugin_decorators().
|
|
513
|
-
"""
|
|
514
|
-
...
|
|
515
|
-
|
|
516
|
-
@typing.overload
|
|
517
|
-
def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
518
|
-
...
|
|
519
|
-
|
|
520
|
-
def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
485
|
+
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]]]:
|
|
521
486
|
"""
|
|
522
|
-
|
|
523
|
-
|
|
487
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
|
488
|
+
|
|
489
|
+
User code call
|
|
490
|
+
--------------
|
|
491
|
+
@ollama(
|
|
492
|
+
models=[...],
|
|
493
|
+
...
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
Valid backend options
|
|
497
|
+
---------------------
|
|
498
|
+
- 'local': Run as a separate process on the local task machine.
|
|
499
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
|
500
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
|
501
|
+
|
|
502
|
+
Valid model options
|
|
503
|
+
-------------------
|
|
504
|
+
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
Parameters
|
|
508
|
+
----------
|
|
509
|
+
models: list[str]
|
|
510
|
+
List of Ollama containers running models in sidecars.
|
|
511
|
+
backend: str
|
|
512
|
+
Determines where and how to run the Ollama process.
|
|
513
|
+
force_pull: bool
|
|
514
|
+
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
|
515
|
+
cache_update_policy: str
|
|
516
|
+
Cache update policy: "auto", "force", or "never".
|
|
517
|
+
force_cache_update: bool
|
|
518
|
+
Simple override for "force" cache update policy.
|
|
519
|
+
debug: bool
|
|
520
|
+
Whether to turn on verbose debugging logs.
|
|
521
|
+
circuit_breaker_config: dict
|
|
522
|
+
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
|
523
|
+
timeout_config: dict
|
|
524
|
+
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
|
524
525
|
"""
|
|
525
526
|
...
|
|
526
527
|
|
|
527
528
|
@typing.overload
|
|
528
|
-
def
|
|
529
|
+
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]]]:
|
|
529
530
|
"""
|
|
530
|
-
|
|
531
|
+
Enables checkpointing for a step.
|
|
531
532
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
533
|
+
> Examples
|
|
534
|
+
|
|
535
|
+
- Saving Checkpoints
|
|
536
|
+
|
|
537
|
+
```python
|
|
538
|
+
@checkpoint
|
|
539
|
+
@step
|
|
540
|
+
def train(self):
|
|
541
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
|
542
|
+
for i in range(self.epochs):
|
|
543
|
+
# some training logic
|
|
544
|
+
loss = model.train(self.dataset)
|
|
545
|
+
if i % 10 == 0:
|
|
546
|
+
model.save(
|
|
547
|
+
current.checkpoint.directory,
|
|
548
|
+
)
|
|
549
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
|
550
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
|
551
|
+
self.latest_checkpoint = current.checkpoint.save(
|
|
552
|
+
name="epoch_checkpoint",
|
|
553
|
+
metadata={
|
|
554
|
+
"epoch": i,
|
|
555
|
+
"loss": loss,
|
|
556
|
+
}
|
|
557
|
+
)
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
- Using Loaded Checkpoints
|
|
561
|
+
|
|
562
|
+
```python
|
|
563
|
+
@retry(times=3)
|
|
564
|
+
@checkpoint
|
|
565
|
+
@step
|
|
566
|
+
def train(self):
|
|
567
|
+
# Assume that the task has restarted and the previous attempt of the task
|
|
568
|
+
# saved a checkpoint
|
|
569
|
+
checkpoint_path = None
|
|
570
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
|
571
|
+
print("Loaded checkpoint from the previous attempt")
|
|
572
|
+
checkpoint_path = current.checkpoint.directory
|
|
573
|
+
|
|
574
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
|
575
|
+
for i in range(self.epochs):
|
|
576
|
+
...
|
|
577
|
+
```
|
|
536
578
|
|
|
537
579
|
|
|
538
580
|
Parameters
|
|
539
581
|
----------
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
582
|
+
load_policy : str, default: "fresh"
|
|
583
|
+
The policy for loading the checkpoint. The following policies are supported:
|
|
584
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
|
585
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
|
586
|
+
will be loaded at the start of the task.
|
|
587
|
+
- "none": Do not load any checkpoint
|
|
588
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
589
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
590
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
591
|
+
created within the task will be loaded when the task is retries execution on failure.
|
|
592
|
+
|
|
593
|
+
temp_dir_root : str, default: None
|
|
594
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
|
546
595
|
"""
|
|
547
596
|
...
|
|
548
597
|
|
|
549
598
|
@typing.overload
|
|
550
|
-
def
|
|
599
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
551
600
|
...
|
|
552
601
|
|
|
553
602
|
@typing.overload
|
|
554
|
-
def
|
|
603
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
555
604
|
...
|
|
556
605
|
|
|
557
|
-
def
|
|
606
|
+
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):
|
|
558
607
|
"""
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
Information in this decorator will augment any
|
|
562
|
-
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
563
|
-
you can use `@pypi_base` to set packages required by all
|
|
564
|
-
steps and use `@pypi` to specify step-specific overrides.
|
|
565
|
-
|
|
608
|
+
Enables checkpointing for a step.
|
|
566
609
|
|
|
567
|
-
|
|
568
|
-
----------
|
|
569
|
-
packages : Dict[str, str], default: {}
|
|
570
|
-
Packages to use for this step. The key is the name of the package
|
|
571
|
-
and the value is the version to use.
|
|
572
|
-
python : str, optional, default: None
|
|
573
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
574
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
575
|
-
"""
|
|
576
|
-
...
|
|
577
|
-
|
|
578
|
-
def coreweave_s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode: typing.Optional[str] = None, debug: typing.Optional[bool] = 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]]]:
|
|
579
|
-
"""
|
|
580
|
-
`@coreweave_s3_proxy` is a CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
581
|
-
It exists to make it easier for users to know that this decorator should only be used with
|
|
582
|
-
a Neo Cloud like CoreWeave. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
610
|
+
> Examples
|
|
583
611
|
|
|
612
|
+
- Saving Checkpoints
|
|
584
613
|
|
|
585
|
-
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
586
|
-
for S3 read and write requests.
|
|
587
|
-
|
|
588
|
-
This decorator requires an integration in the Outerbounds platform that
|
|
589
|
-
points to an external bucket. It affects S3 operations performed via
|
|
590
|
-
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
591
|
-
|
|
592
|
-
Read operations
|
|
593
|
-
---------------
|
|
594
|
-
All read operations pass through the proxy. If an object does not already
|
|
595
|
-
exist in the external bucket, it is cached there. For example, if code reads
|
|
596
|
-
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
597
|
-
buckets are cached in the external bucket.
|
|
598
|
-
|
|
599
|
-
During task execution, all S3‑related read requests are routed through the
|
|
600
|
-
proxy:
|
|
601
|
-
- If the object is present in the external object store, the proxy
|
|
602
|
-
streams it directly from there without accessing the requested origin
|
|
603
|
-
bucket.
|
|
604
|
-
- If the object is not present in the external storage, the proxy
|
|
605
|
-
fetches it from the requested bucket, caches it in the external
|
|
606
|
-
storage, and streams the response from the origin bucket.
|
|
607
|
-
|
|
608
|
-
Warning
|
|
609
|
-
-------
|
|
610
|
-
All READ operations (e.g., GetObject, HeadObject) pass through the external
|
|
611
|
-
bucket regardless of the bucket specified in user code. Even
|
|
612
|
-
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
613
|
-
external bucket cache.
|
|
614
|
-
|
|
615
|
-
Write operations
|
|
616
|
-
----------------
|
|
617
|
-
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
618
|
-
whether writes also persist objects in the cache.
|
|
619
|
-
|
|
620
|
-
`write_mode` values:
|
|
621
|
-
- `origin-and-cache`: objects are written both to the cache and to their
|
|
622
|
-
intended origin bucket.
|
|
623
|
-
- `origin`: objects are written only to their intended origin bucket.
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
Parameters
|
|
627
|
-
----------
|
|
628
|
-
integration_name : str, optional
|
|
629
|
-
[Outerbounds integration name](https://docs.outerbounds.com/outerbounds/configuring-secrets/#integrations-view)
|
|
630
|
-
that holds the configuration for the external, S3‑compatible object
|
|
631
|
-
storage bucket. If not specified, the only available S3 proxy
|
|
632
|
-
integration in the namespace is used (fails if multiple exist).
|
|
633
|
-
write_mode : str, optional
|
|
634
|
-
Controls whether writes also go to the external bucket.
|
|
635
|
-
- `origin` (default)
|
|
636
|
-
- `origin-and-cache`
|
|
637
|
-
debug : bool, optional
|
|
638
|
-
Enables debug logging for proxy operations.
|
|
639
|
-
"""
|
|
640
|
-
...
|
|
641
|
-
|
|
642
|
-
@typing.overload
|
|
643
|
-
def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
644
|
-
"""
|
|
645
|
-
A simple decorator that demonstrates using CardDecoratorInjector
|
|
646
|
-
to inject a card and render simple markdown content.
|
|
647
|
-
"""
|
|
648
|
-
...
|
|
649
|
-
|
|
650
|
-
@typing.overload
|
|
651
|
-
def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
652
|
-
...
|
|
653
|
-
|
|
654
|
-
def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
655
|
-
"""
|
|
656
|
-
A simple decorator that demonstrates using CardDecoratorInjector
|
|
657
|
-
to inject a card and render simple markdown content.
|
|
658
|
-
"""
|
|
659
|
-
...
|
|
660
|
-
|
|
661
|
-
@typing.overload
|
|
662
|
-
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]]]:
|
|
663
|
-
"""
|
|
664
|
-
Specifies that the step will success under all circumstances.
|
|
665
|
-
|
|
666
|
-
The decorator will create an optional artifact, specified by `var`, which
|
|
667
|
-
contains the exception raised. You can use it to detect the presence
|
|
668
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
|
669
|
-
are missing.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
Parameters
|
|
673
|
-
----------
|
|
674
|
-
var : str, optional, default None
|
|
675
|
-
Name of the artifact in which to store the caught exception.
|
|
676
|
-
If not specified, the exception is not stored.
|
|
677
|
-
print_exception : bool, default True
|
|
678
|
-
Determines whether or not the exception is printed to
|
|
679
|
-
stdout when caught.
|
|
680
|
-
"""
|
|
681
|
-
...
|
|
682
|
-
|
|
683
|
-
@typing.overload
|
|
684
|
-
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
685
|
-
...
|
|
686
|
-
|
|
687
|
-
@typing.overload
|
|
688
|
-
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
689
|
-
...
|
|
690
|
-
|
|
691
|
-
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):
|
|
692
|
-
"""
|
|
693
|
-
Specifies that the step will success under all circumstances.
|
|
694
|
-
|
|
695
|
-
The decorator will create an optional artifact, specified by `var`, which
|
|
696
|
-
contains the exception raised. You can use it to detect the presence
|
|
697
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
|
698
|
-
are missing.
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
Parameters
|
|
702
|
-
----------
|
|
703
|
-
var : str, optional, default None
|
|
704
|
-
Name of the artifact in which to store the caught exception.
|
|
705
|
-
If not specified, the exception is not stored.
|
|
706
|
-
print_exception : bool, default True
|
|
707
|
-
Determines whether or not the exception is printed to
|
|
708
|
-
stdout when caught.
|
|
709
|
-
"""
|
|
710
|
-
...
|
|
711
|
-
|
|
712
|
-
@typing.overload
|
|
713
|
-
def retry(*, times: int = 3, minutes_between_retries: int = 2) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
714
|
-
"""
|
|
715
|
-
Specifies the number of times the task corresponding
|
|
716
|
-
to a step needs to be retried.
|
|
717
|
-
|
|
718
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
|
719
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
720
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
|
721
|
-
|
|
722
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
723
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
|
724
|
-
ensuring that the flow execution can continue.
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
Parameters
|
|
728
|
-
----------
|
|
729
|
-
times : int, default 3
|
|
730
|
-
Number of times to retry this task.
|
|
731
|
-
minutes_between_retries : int, default 2
|
|
732
|
-
Number of minutes between retries.
|
|
733
|
-
"""
|
|
734
|
-
...
|
|
735
|
-
|
|
736
|
-
@typing.overload
|
|
737
|
-
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
738
|
-
...
|
|
739
|
-
|
|
740
|
-
@typing.overload
|
|
741
|
-
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
742
|
-
...
|
|
743
|
-
|
|
744
|
-
def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, times: int = 3, minutes_between_retries: int = 2):
|
|
745
|
-
"""
|
|
746
|
-
Specifies the number of times the task corresponding
|
|
747
|
-
to a step needs to be retried.
|
|
748
|
-
|
|
749
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
|
750
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
751
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
|
752
|
-
|
|
753
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
754
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
|
755
|
-
ensuring that the flow execution can continue.
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
Parameters
|
|
759
|
-
----------
|
|
760
|
-
times : int, default 3
|
|
761
|
-
Number of times to retry this task.
|
|
762
|
-
minutes_between_retries : int, default 2
|
|
763
|
-
Number of minutes between retries.
|
|
764
|
-
"""
|
|
765
|
-
...
|
|
766
|
-
|
|
767
|
-
@typing.overload
|
|
768
|
-
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]]]:
|
|
769
|
-
"""
|
|
770
|
-
Enables loading / saving of models within a step.
|
|
771
|
-
|
|
772
|
-
> Examples
|
|
773
|
-
- Saving Models
|
|
774
614
|
```python
|
|
775
|
-
@
|
|
615
|
+
@checkpoint
|
|
776
616
|
@step
|
|
777
617
|
def train(self):
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
|
796
|
-
self.next(self.end)
|
|
618
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
|
619
|
+
for i in range(self.epochs):
|
|
620
|
+
# some training logic
|
|
621
|
+
loss = model.train(self.dataset)
|
|
622
|
+
if i % 10 == 0:
|
|
623
|
+
model.save(
|
|
624
|
+
current.checkpoint.directory,
|
|
625
|
+
)
|
|
626
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
|
627
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
|
628
|
+
self.latest_checkpoint = current.checkpoint.save(
|
|
629
|
+
name="epoch_checkpoint",
|
|
630
|
+
metadata={
|
|
631
|
+
"epoch": i,
|
|
632
|
+
"loss": loss,
|
|
633
|
+
}
|
|
634
|
+
)
|
|
797
635
|
```
|
|
798
636
|
|
|
799
|
-
-
|
|
637
|
+
- Using Loaded Checkpoints
|
|
638
|
+
|
|
800
639
|
```python
|
|
640
|
+
@retry(times=3)
|
|
641
|
+
@checkpoint
|
|
801
642
|
@step
|
|
802
643
|
def train(self):
|
|
803
|
-
#
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
644
|
+
# Assume that the task has restarted and the previous attempt of the task
|
|
645
|
+
# saved a checkpoint
|
|
646
|
+
checkpoint_path = None
|
|
647
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
|
648
|
+
print("Loaded checkpoint from the previous attempt")
|
|
649
|
+
checkpoint_path = current.checkpoint.directory
|
|
650
|
+
|
|
651
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
|
652
|
+
for i in range(self.epochs):
|
|
653
|
+
...
|
|
811
654
|
```
|
|
812
655
|
|
|
813
656
|
|
|
814
657
|
Parameters
|
|
815
658
|
----------
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
659
|
+
load_policy : str, default: "fresh"
|
|
660
|
+
The policy for loading the checkpoint. The following policies are supported:
|
|
661
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
|
662
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
|
663
|
+
will be loaded at the start of the task.
|
|
664
|
+
- "none": Do not load any checkpoint
|
|
665
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
|
666
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
|
667
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
|
668
|
+
created within the task will be loaded when the task is retries execution on failure.
|
|
822
669
|
|
|
823
670
|
temp_dir_root : str, default: None
|
|
824
|
-
The root directory under which `current.
|
|
671
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
|
825
672
|
"""
|
|
826
673
|
...
|
|
827
674
|
|
|
828
|
-
|
|
829
|
-
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
830
|
-
...
|
|
831
|
-
|
|
832
|
-
@typing.overload
|
|
833
|
-
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
834
|
-
...
|
|
835
|
-
|
|
836
|
-
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):
|
|
675
|
+
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]]]:
|
|
837
676
|
"""
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
> Examples
|
|
841
|
-
- Saving Models
|
|
842
|
-
```python
|
|
843
|
-
@model
|
|
844
|
-
@step
|
|
845
|
-
def train(self):
|
|
846
|
-
# current.model.save returns a dictionary reference to the model saved
|
|
847
|
-
self.my_model = current.model.save(
|
|
848
|
-
path_to_my_model,
|
|
849
|
-
label="my_model",
|
|
850
|
-
metadata={
|
|
851
|
-
"epochs": 10,
|
|
852
|
-
"batch-size": 32,
|
|
853
|
-
"learning-rate": 0.001,
|
|
854
|
-
}
|
|
855
|
-
)
|
|
856
|
-
self.next(self.test)
|
|
857
|
-
|
|
858
|
-
@model(load="my_model")
|
|
859
|
-
@step
|
|
860
|
-
def test(self):
|
|
861
|
-
# `current.model.loaded` returns a dictionary of the loaded models
|
|
862
|
-
# where the key is the name of the artifact and the value is the path to the model
|
|
863
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
|
864
|
-
self.next(self.end)
|
|
865
|
-
```
|
|
866
|
-
|
|
867
|
-
- Loading models
|
|
868
|
-
```python
|
|
869
|
-
@step
|
|
870
|
-
def train(self):
|
|
871
|
-
# current.model.load returns the path to the model loaded
|
|
872
|
-
checkpoint_path = current.model.load(
|
|
873
|
-
self.checkpoint_key,
|
|
874
|
-
)
|
|
875
|
-
model_path = current.model.load(
|
|
876
|
-
self.model,
|
|
877
|
-
)
|
|
878
|
-
self.next(self.test)
|
|
879
|
-
```
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
Parameters
|
|
883
|
-
----------
|
|
884
|
-
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
885
|
-
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
886
|
-
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`.
|
|
887
|
-
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
|
|
888
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
889
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
677
|
+
Specifies that this step should execute on DGX cloud.
|
|
890
678
|
|
|
891
|
-
|
|
892
|
-
|
|
679
|
+
|
|
680
|
+
Parameters
|
|
681
|
+
----------
|
|
682
|
+
gpu : int
|
|
683
|
+
Number of GPUs to use.
|
|
684
|
+
gpu_type : str
|
|
685
|
+
Type of Nvidia GPU to use.
|
|
893
686
|
"""
|
|
894
687
|
...
|
|
895
688
|
|
|
@@ -982,65 +775,308 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
|
|
|
982
775
|
"""
|
|
983
776
|
...
|
|
984
777
|
|
|
985
|
-
def
|
|
778
|
+
def s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode: typing.Optional[str] = None, debug: typing.Optional[bool] = 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]]]:
|
|
986
779
|
"""
|
|
987
|
-
|
|
780
|
+
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
781
|
+
for S3 read and write requests.
|
|
988
782
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
models=[...],
|
|
993
|
-
...
|
|
994
|
-
)
|
|
783
|
+
This decorator requires an integration in the Outerbounds platform that
|
|
784
|
+
points to an external bucket. It affects S3 operations performed via
|
|
785
|
+
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
995
786
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
787
|
+
Read operations
|
|
788
|
+
---------------
|
|
789
|
+
All read operations pass through the proxy. If an object does not already
|
|
790
|
+
exist in the external bucket, it is cached there. For example, if code reads
|
|
791
|
+
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
792
|
+
buckets are cached in the external bucket.
|
|
1001
793
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
794
|
+
During task execution, all S3‑related read requests are routed through the
|
|
795
|
+
proxy:
|
|
796
|
+
- If the object is present in the external object store, the proxy
|
|
797
|
+
streams it directly from there without accessing the requested origin
|
|
798
|
+
bucket.
|
|
799
|
+
- If the object is not present in the external storage, the proxy
|
|
800
|
+
fetches it from the requested bucket, caches it in the external
|
|
801
|
+
storage, and streams the response from the origin bucket.
|
|
802
|
+
|
|
803
|
+
Warning
|
|
804
|
+
-------
|
|
805
|
+
All READ operations (e.g., GetObject, HeadObject) pass through the external
|
|
806
|
+
bucket regardless of the bucket specified in user code. Even
|
|
807
|
+
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
808
|
+
external bucket cache.
|
|
809
|
+
|
|
810
|
+
Write operations
|
|
811
|
+
----------------
|
|
812
|
+
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
813
|
+
whether writes also persist objects in the cache.
|
|
814
|
+
|
|
815
|
+
`write_mode` values:
|
|
816
|
+
- `origin-and-cache`: objects are written both to the cache and to their
|
|
817
|
+
intended origin bucket.
|
|
818
|
+
- `origin`: objects are written only to their intended origin bucket.
|
|
1005
819
|
|
|
1006
820
|
|
|
1007
821
|
Parameters
|
|
1008
822
|
----------
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
823
|
+
integration_name : str, optional
|
|
824
|
+
[Outerbounds integration name](https://docs.outerbounds.com/outerbounds/configuring-secrets/#integrations-view)
|
|
825
|
+
that holds the configuration for the external, S3‑compatible object
|
|
826
|
+
storage bucket. If not specified, the only available S3 proxy
|
|
827
|
+
integration in the namespace is used (fails if multiple exist).
|
|
828
|
+
write_mode : str, optional
|
|
829
|
+
Controls whether writes also go to the external bucket.
|
|
830
|
+
- `origin` (default)
|
|
831
|
+
- `origin-and-cache`
|
|
832
|
+
debug : bool, optional
|
|
833
|
+
Enables debug logging for proxy operations.
|
|
834
|
+
"""
|
|
835
|
+
...
|
|
836
|
+
|
|
837
|
+
def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, cache_scope: typing.Optional[str] = None, load: typing.Union[typing.List[str], typing.List[typing.Tuple[typing.Dict, str]], typing.List[typing.Tuple[str, str]], typing.List[typing.Dict], None]) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
838
|
+
"""
|
|
839
|
+
Decorator that helps cache, version, and store models/datasets from the Hugging Face Hub.
|
|
840
|
+
|
|
841
|
+
Examples
|
|
842
|
+
--------
|
|
843
|
+
|
|
844
|
+
```python
|
|
845
|
+
# **Usage: creating references to models from the Hugging Face Hub that may be loaded in downstream steps**
|
|
846
|
+
@huggingface_hub
|
|
847
|
+
@step
|
|
848
|
+
def pull_model_from_huggingface(self):
|
|
849
|
+
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
|
850
|
+
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
|
851
|
+
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
|
852
|
+
# value of the function is a reference to the model in the backend storage.
|
|
853
|
+
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
|
854
|
+
|
|
855
|
+
self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
|
|
856
|
+
self.llama_model = current.huggingface_hub.snapshot_download(
|
|
857
|
+
repo_id=self.model_id,
|
|
858
|
+
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
|
859
|
+
)
|
|
860
|
+
self.next(self.train)
|
|
861
|
+
|
|
862
|
+
# **Usage: explicitly loading models at runtime from the Hugging Face Hub or from cache (from Metaflow's datastore)**
|
|
863
|
+
@huggingface_hub
|
|
864
|
+
@step
|
|
865
|
+
def run_training(self):
|
|
866
|
+
# Temporary directory (auto-cleaned on exit)
|
|
867
|
+
with current.huggingface_hub.load(
|
|
868
|
+
repo_id="google-bert/bert-base-uncased",
|
|
869
|
+
allow_patterns=["*.bin"],
|
|
870
|
+
) as local_path:
|
|
871
|
+
# Use files under local_path
|
|
872
|
+
train_model(local_path)
|
|
873
|
+
...
|
|
874
|
+
|
|
875
|
+
# **Usage: loading models directly from the Hugging Face Hub or from cache (from Metaflow's datastore)**
|
|
876
|
+
|
|
877
|
+
@huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
|
|
878
|
+
@step
|
|
879
|
+
def pull_model_from_huggingface(self):
|
|
880
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
881
|
+
|
|
882
|
+
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora", "/my-lora-directory")])
|
|
883
|
+
@step
|
|
884
|
+
def finetune_model(self):
|
|
885
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
886
|
+
# path_to_model will be /my-directory
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
# Takes all the arguments passed to `snapshot_download`
|
|
890
|
+
# except for `local_dir`
|
|
891
|
+
@huggingface_hub(load=[
|
|
892
|
+
{
|
|
893
|
+
"repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"repo_id": "myorg/mistral-lora",
|
|
897
|
+
"repo_type": "model",
|
|
898
|
+
},
|
|
899
|
+
])
|
|
900
|
+
@step
|
|
901
|
+
def finetune_model(self):
|
|
902
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
903
|
+
# path_to_model will be /my-directory
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
Parameters
|
|
908
|
+
----------
|
|
909
|
+
temp_dir_root : str, optional
|
|
910
|
+
The root directory that will hold the temporary directory where objects will be downloaded.
|
|
911
|
+
|
|
912
|
+
cache_scope : str, optional
|
|
913
|
+
The scope of the cache. Can be `checkpoint` / `flow` / `global`.
|
|
914
|
+
- `checkpoint` (default): All repos are stored like objects saved by `@checkpoint`.
|
|
915
|
+
i.e., the cached path is derived from the namespace, flow, step, and Metaflow foreach iteration.
|
|
916
|
+
Any repo downloaded under this scope will only be retrieved from the cache when the step runs under the same namespace in the same flow (at the same foreach index).
|
|
917
|
+
|
|
918
|
+
- `flow`: All repos are cached under the flow, regardless of namespace.
|
|
919
|
+
i.e., the cached path is derived solely from the flow name.
|
|
920
|
+
When to use this mode: (1) Multiple users are executing the same flow and want shared access to the repos cached by the decorator. (2) Multiple versions of a flow are deployed, all needing access to the same repos cached by the decorator.
|
|
921
|
+
|
|
922
|
+
- `global`: All repos are cached under a globally static path.
|
|
923
|
+
i.e., the base path of the cache is static and all repos are stored under it.
|
|
924
|
+
When to use this mode:
|
|
925
|
+
- All repos from the Hugging Face Hub need to be shared by users across all flow executions.
|
|
926
|
+
- Each caching scope comes with its own trade-offs:
|
|
927
|
+
- `checkpoint`:
|
|
928
|
+
- Has explicit control over when caches are populated (controlled by the same flow that has the `@huggingface_hub` decorator) but ends up hitting the Hugging Face Hub more often if there are many users/namespaces/steps.
|
|
929
|
+
- Since objects are written on a `namespace/flow/step` basis, the blast radius of a bad checkpoint is limited to a particular flow in a namespace.
|
|
930
|
+
- `flow`:
|
|
931
|
+
- Has less control over when caches are populated (can be written by any execution instance of a flow from any namespace) but results in more cache hits.
|
|
932
|
+
- The blast radius of a bad checkpoint is limited to all runs of a particular flow.
|
|
933
|
+
- It doesn't promote cache reuse across flows.
|
|
934
|
+
- `global`:
|
|
935
|
+
- Has no control over when caches are populated (can be written by any flow execution) but has the highest cache hit rate.
|
|
936
|
+
- It promotes cache reuse across flows.
|
|
937
|
+
- The blast radius of a bad checkpoint spans every flow that could be using a particular repo.
|
|
938
|
+
|
|
939
|
+
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
|
940
|
+
The list of repos (models/datasets) to load.
|
|
941
|
+
|
|
942
|
+
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
|
943
|
+
|
|
944
|
+
- If repo (model/dataset) is not found in the datastore:
|
|
945
|
+
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
|
946
|
+
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
|
947
|
+
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
|
948
|
+
|
|
949
|
+
- If repo is found in the datastore:
|
|
950
|
+
- Loads it directly from datastore to local path (can be temporary directory or specified path)
|
|
951
|
+
"""
|
|
952
|
+
...
|
|
953
|
+
|
|
954
|
+
@typing.overload
|
|
955
|
+
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]]]:
|
|
956
|
+
"""
|
|
957
|
+
Enables loading / saving of models within a step.
|
|
958
|
+
|
|
959
|
+
> Examples
|
|
960
|
+
- Saving Models
|
|
961
|
+
```python
|
|
962
|
+
@model
|
|
963
|
+
@step
|
|
964
|
+
def train(self):
|
|
965
|
+
# current.model.save returns a dictionary reference to the model saved
|
|
966
|
+
self.my_model = current.model.save(
|
|
967
|
+
path_to_my_model,
|
|
968
|
+
label="my_model",
|
|
969
|
+
metadata={
|
|
970
|
+
"epochs": 10,
|
|
971
|
+
"batch-size": 32,
|
|
972
|
+
"learning-rate": 0.001,
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
self.next(self.test)
|
|
976
|
+
|
|
977
|
+
@model(load="my_model")
|
|
978
|
+
@step
|
|
979
|
+
def test(self):
|
|
980
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
|
981
|
+
# where the key is the name of the artifact and the value is the path to the model
|
|
982
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
|
983
|
+
self.next(self.end)
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
- Loading models
|
|
987
|
+
```python
|
|
988
|
+
@step
|
|
989
|
+
def train(self):
|
|
990
|
+
# current.model.load returns the path to the model loaded
|
|
991
|
+
checkpoint_path = current.model.load(
|
|
992
|
+
self.checkpoint_key,
|
|
993
|
+
)
|
|
994
|
+
model_path = current.model.load(
|
|
995
|
+
self.model,
|
|
996
|
+
)
|
|
997
|
+
self.next(self.test)
|
|
998
|
+
```
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
Parameters
|
|
1002
|
+
----------
|
|
1003
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
1004
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
1005
|
+
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`.
|
|
1006
|
+
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
|
|
1007
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
1008
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
1009
|
+
|
|
1010
|
+
temp_dir_root : str, default: None
|
|
1011
|
+
The root directory under which `current.model.loaded` will store loaded models
|
|
1025
1012
|
"""
|
|
1026
1013
|
...
|
|
1027
1014
|
|
|
1028
1015
|
@typing.overload
|
|
1029
|
-
def
|
|
1030
|
-
"""
|
|
1031
|
-
Decorator prototype for all step decorators. This function gets specialized
|
|
1032
|
-
and imported for all decorators types by _import_plugin_decorators().
|
|
1033
|
-
"""
|
|
1016
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1034
1017
|
...
|
|
1035
1018
|
|
|
1036
1019
|
@typing.overload
|
|
1037
|
-
def
|
|
1020
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1038
1021
|
...
|
|
1039
1022
|
|
|
1040
|
-
def
|
|
1023
|
+
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):
|
|
1041
1024
|
"""
|
|
1042
|
-
|
|
1043
|
-
|
|
1025
|
+
Enables loading / saving of models within a step.
|
|
1026
|
+
|
|
1027
|
+
> Examples
|
|
1028
|
+
- Saving Models
|
|
1029
|
+
```python
|
|
1030
|
+
@model
|
|
1031
|
+
@step
|
|
1032
|
+
def train(self):
|
|
1033
|
+
# current.model.save returns a dictionary reference to the model saved
|
|
1034
|
+
self.my_model = current.model.save(
|
|
1035
|
+
path_to_my_model,
|
|
1036
|
+
label="my_model",
|
|
1037
|
+
metadata={
|
|
1038
|
+
"epochs": 10,
|
|
1039
|
+
"batch-size": 32,
|
|
1040
|
+
"learning-rate": 0.001,
|
|
1041
|
+
}
|
|
1042
|
+
)
|
|
1043
|
+
self.next(self.test)
|
|
1044
|
+
|
|
1045
|
+
@model(load="my_model")
|
|
1046
|
+
@step
|
|
1047
|
+
def test(self):
|
|
1048
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
|
1049
|
+
# where the key is the name of the artifact and the value is the path to the model
|
|
1050
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
|
1051
|
+
self.next(self.end)
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
- Loading models
|
|
1055
|
+
```python
|
|
1056
|
+
@step
|
|
1057
|
+
def train(self):
|
|
1058
|
+
# current.model.load returns the path to the model loaded
|
|
1059
|
+
checkpoint_path = current.model.load(
|
|
1060
|
+
self.checkpoint_key,
|
|
1061
|
+
)
|
|
1062
|
+
model_path = current.model.load(
|
|
1063
|
+
self.model,
|
|
1064
|
+
)
|
|
1065
|
+
self.next(self.test)
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
Parameters
|
|
1070
|
+
----------
|
|
1071
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
1072
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
1073
|
+
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`.
|
|
1074
|
+
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
|
|
1075
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
1076
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
1077
|
+
|
|
1078
|
+
temp_dir_root : str, default: None
|
|
1079
|
+
The root directory under which `current.model.loaded` will store loaded models
|
|
1044
1080
|
"""
|
|
1045
1081
|
...
|
|
1046
1082
|
|
|
@@ -1060,50 +1096,67 @@ def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[t
|
|
|
1060
1096
|
"""
|
|
1061
1097
|
...
|
|
1062
1098
|
|
|
1063
|
-
def
|
|
1099
|
+
def coreweave_s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode: typing.Optional[str] = None, debug: typing.Optional[bool] = 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]]]:
|
|
1064
1100
|
"""
|
|
1065
|
-
|
|
1101
|
+
`@coreweave_s3_proxy` is a CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
1102
|
+
It exists to make it easier for users to know that this decorator should only be used with
|
|
1103
|
+
a Neo Cloud like CoreWeave. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
1066
1104
|
|
|
1067
1105
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
gpu : int
|
|
1071
|
-
Number of GPUs to use.
|
|
1072
|
-
gpu_type : str
|
|
1073
|
-
Type of Nvidia GPU to use.
|
|
1074
|
-
"""
|
|
1075
|
-
...
|
|
1076
|
-
|
|
1077
|
-
@typing.overload
|
|
1078
|
-
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]]]:
|
|
1079
|
-
"""
|
|
1080
|
-
Specifies environment variables to be set prior to the execution of a step.
|
|
1106
|
+
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
1107
|
+
for S3 read and write requests.
|
|
1081
1108
|
|
|
1109
|
+
This decorator requires an integration in the Outerbounds platform that
|
|
1110
|
+
points to an external bucket. It affects S3 operations performed via
|
|
1111
|
+
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
1082
1112
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1113
|
+
Read operations
|
|
1114
|
+
---------------
|
|
1115
|
+
All read operations pass through the proxy. If an object does not already
|
|
1116
|
+
exist in the external bucket, it is cached there. For example, if code reads
|
|
1117
|
+
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
1118
|
+
buckets are cached in the external bucket.
|
|
1119
|
+
|
|
1120
|
+
During task execution, all S3‑related read requests are routed through the
|
|
1121
|
+
proxy:
|
|
1122
|
+
- If the object is present in the external object store, the proxy
|
|
1123
|
+
streams it directly from there without accessing the requested origin
|
|
1124
|
+
bucket.
|
|
1125
|
+
- If the object is not present in the external storage, the proxy
|
|
1126
|
+
fetches it from the requested bucket, caches it in the external
|
|
1127
|
+
storage, and streams the response from the origin bucket.
|
|
1128
|
+
|
|
1129
|
+
Warning
|
|
1130
|
+
-------
|
|
1131
|
+
All READ operations (e.g., GetObject, HeadObject) pass through the external
|
|
1132
|
+
bucket regardless of the bucket specified in user code. Even
|
|
1133
|
+
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
1134
|
+
external bucket cache.
|
|
1135
|
+
|
|
1136
|
+
Write operations
|
|
1137
|
+
----------------
|
|
1138
|
+
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
1139
|
+
whether writes also persist objects in the cache.
|
|
1140
|
+
|
|
1141
|
+
`write_mode` values:
|
|
1142
|
+
- `origin-and-cache`: objects are written both to the cache and to their
|
|
1143
|
+
intended origin bucket.
|
|
1144
|
+
- `origin`: objects are written only to their intended origin bucket.
|
|
1101
1145
|
|
|
1102
1146
|
|
|
1103
1147
|
Parameters
|
|
1104
1148
|
----------
|
|
1105
|
-
|
|
1106
|
-
|
|
1149
|
+
integration_name : str, optional
|
|
1150
|
+
[Outerbounds integration name](https://docs.outerbounds.com/outerbounds/configuring-secrets/#integrations-view)
|
|
1151
|
+
that holds the configuration for the external, S3‑compatible object
|
|
1152
|
+
storage bucket. If not specified, the only available S3 proxy
|
|
1153
|
+
integration in the namespace is used (fails if multiple exist).
|
|
1154
|
+
write_mode : str, optional
|
|
1155
|
+
Controls whether writes also go to the external bucket.
|
|
1156
|
+
- `origin` (default)
|
|
1157
|
+
- `origin-and-cache`
|
|
1158
|
+
debug : bool, optional
|
|
1159
|
+
Enables debug logging for proxy operations.
|
|
1107
1160
|
"""
|
|
1108
1161
|
...
|
|
1109
1162
|
|
|
@@ -1166,62 +1219,70 @@ def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
|
1166
1219
|
"""
|
|
1167
1220
|
...
|
|
1168
1221
|
|
|
1169
|
-
def
|
|
1222
|
+
def vllm(*, model: str, backend: str, openai_api_server: bool, debug: bool, card_refresh_interval: int, max_retries: int, retry_alert_frequency: int, engine_args: 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]]]:
|
|
1170
1223
|
"""
|
|
1171
|
-
|
|
1172
|
-
for S3 read and write requests.
|
|
1173
|
-
|
|
1174
|
-
This decorator requires an integration in the Outerbounds platform that
|
|
1175
|
-
points to an external bucket. It affects S3 operations performed via
|
|
1176
|
-
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
1177
|
-
|
|
1178
|
-
Read operations
|
|
1179
|
-
---------------
|
|
1180
|
-
All read operations pass through the proxy. If an object does not already
|
|
1181
|
-
exist in the external bucket, it is cached there. For example, if code reads
|
|
1182
|
-
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
1183
|
-
buckets are cached in the external bucket.
|
|
1224
|
+
This decorator is used to run vllm APIs as Metaflow task sidecars.
|
|
1184
1225
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
fetches it from the requested bucket, caches it in the external
|
|
1192
|
-
storage, and streams the response from the origin bucket.
|
|
1226
|
+
User code call
|
|
1227
|
+
--------------
|
|
1228
|
+
@vllm(
|
|
1229
|
+
model="...",
|
|
1230
|
+
...
|
|
1231
|
+
)
|
|
1193
1232
|
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
bucket regardless of the bucket specified in user code. Even
|
|
1198
|
-
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
1199
|
-
external bucket cache.
|
|
1233
|
+
Valid backend options
|
|
1234
|
+
---------------------
|
|
1235
|
+
- 'local': Run as a separate process on the local task machine.
|
|
1200
1236
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
whether writes also persist objects in the cache.
|
|
1237
|
+
Valid model options
|
|
1238
|
+
-------------------
|
|
1239
|
+
Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
|
|
1205
1240
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
intended origin bucket.
|
|
1209
|
-
- `origin`: objects are written only to their intended origin bucket.
|
|
1241
|
+
NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
|
|
1242
|
+
If you need multiple models, you must create multiple @vllm decorators.
|
|
1210
1243
|
|
|
1211
1244
|
|
|
1212
1245
|
Parameters
|
|
1213
1246
|
----------
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1247
|
+
model: str
|
|
1248
|
+
HuggingFace model identifier to be served by vLLM.
|
|
1249
|
+
backend: str
|
|
1250
|
+
Determines where and how to run the vLLM process.
|
|
1251
|
+
openai_api_server: bool
|
|
1252
|
+
Whether to use OpenAI-compatible API server mode (subprocess) instead of native engine.
|
|
1253
|
+
Default is False (uses native engine).
|
|
1254
|
+
Set to True for backward compatibility with existing code.
|
|
1255
|
+
debug: bool
|
|
1256
|
+
Whether to turn on verbose debugging logs.
|
|
1257
|
+
card_refresh_interval: int
|
|
1258
|
+
Interval in seconds for refreshing the vLLM status card.
|
|
1259
|
+
Only used when openai_api_server=True.
|
|
1260
|
+
max_retries: int
|
|
1261
|
+
Maximum number of retries checking for vLLM server startup.
|
|
1262
|
+
Only used when openai_api_server=True.
|
|
1263
|
+
retry_alert_frequency: int
|
|
1264
|
+
Frequency of alert logs for vLLM server startup retries.
|
|
1265
|
+
Only used when openai_api_server=True.
|
|
1266
|
+
engine_args : dict
|
|
1267
|
+
Additional keyword arguments to pass to the vLLM engine.
|
|
1268
|
+
For example, `tensor_parallel_size=2`.
|
|
1269
|
+
"""
|
|
1270
|
+
...
|
|
1271
|
+
|
|
1272
|
+
@typing.overload
|
|
1273
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1274
|
+
"""
|
|
1275
|
+
Internal decorator to support Fast bakery
|
|
1276
|
+
"""
|
|
1277
|
+
...
|
|
1278
|
+
|
|
1279
|
+
@typing.overload
|
|
1280
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1281
|
+
...
|
|
1282
|
+
|
|
1283
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
1284
|
+
"""
|
|
1285
|
+
Internal decorator to support Fast bakery
|
|
1225
1286
|
"""
|
|
1226
1287
|
...
|
|
1227
1288
|
|
|
@@ -1265,248 +1326,187 @@ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
|
1265
1326
|
...
|
|
1266
1327
|
|
|
1267
1328
|
@typing.overload
|
|
1268
|
-
def
|
|
1329
|
+
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]]]:
|
|
1269
1330
|
"""
|
|
1270
|
-
Specifies the
|
|
1271
|
-
|
|
1272
|
-
Use `@resources` to specify the resource requirements
|
|
1273
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
1331
|
+
Specifies that the step will success under all circumstances.
|
|
1274
1332
|
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
or
|
|
1280
|
-
```
|
|
1281
|
-
python myflow.py run --with kubernetes
|
|
1282
|
-
```
|
|
1283
|
-
which executes the flow on the desired system using the
|
|
1284
|
-
requirements specified in `@resources`.
|
|
1333
|
+
The decorator will create an optional artifact, specified by `var`, which
|
|
1334
|
+
contains the exception raised. You can use it to detect the presence
|
|
1335
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
|
1336
|
+
are missing.
|
|
1285
1337
|
|
|
1286
1338
|
|
|
1287
1339
|
Parameters
|
|
1288
1340
|
----------
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
memory : int, default 4096
|
|
1296
|
-
Memory size (in MB) required for this step.
|
|
1297
|
-
shared_memory : int, optional, default None
|
|
1298
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
1299
|
-
This parameter maps to the `--shm-size` option in Docker.
|
|
1341
|
+
var : str, optional, default None
|
|
1342
|
+
Name of the artifact in which to store the caught exception.
|
|
1343
|
+
If not specified, the exception is not stored.
|
|
1344
|
+
print_exception : bool, default True
|
|
1345
|
+
Determines whether or not the exception is printed to
|
|
1346
|
+
stdout when caught.
|
|
1300
1347
|
"""
|
|
1301
1348
|
...
|
|
1302
1349
|
|
|
1303
1350
|
@typing.overload
|
|
1304
|
-
def
|
|
1351
|
+
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1305
1352
|
...
|
|
1306
1353
|
|
|
1307
1354
|
@typing.overload
|
|
1308
|
-
def
|
|
1355
|
+
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1309
1356
|
...
|
|
1310
1357
|
|
|
1311
|
-
def
|
|
1358
|
+
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):
|
|
1312
1359
|
"""
|
|
1313
|
-
Specifies the
|
|
1314
|
-
|
|
1315
|
-
Use `@resources` to specify the resource requirements
|
|
1316
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
1360
|
+
Specifies that the step will success under all circumstances.
|
|
1317
1361
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
or
|
|
1323
|
-
```
|
|
1324
|
-
python myflow.py run --with kubernetes
|
|
1325
|
-
```
|
|
1326
|
-
which executes the flow on the desired system using the
|
|
1327
|
-
requirements specified in `@resources`.
|
|
1362
|
+
The decorator will create an optional artifact, specified by `var`, which
|
|
1363
|
+
contains the exception raised. You can use it to detect the presence
|
|
1364
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
|
1365
|
+
are missing.
|
|
1328
1366
|
|
|
1329
1367
|
|
|
1330
1368
|
Parameters
|
|
1331
1369
|
----------
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
memory : int, default 4096
|
|
1339
|
-
Memory size (in MB) required for this step.
|
|
1340
|
-
shared_memory : int, optional, default None
|
|
1341
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
1342
|
-
This parameter maps to the `--shm-size` option in Docker.
|
|
1370
|
+
var : str, optional, default None
|
|
1371
|
+
Name of the artifact in which to store the caught exception.
|
|
1372
|
+
If not specified, the exception is not stored.
|
|
1373
|
+
print_exception : bool, default True
|
|
1374
|
+
Determines whether or not the exception is printed to
|
|
1375
|
+
stdout when caught.
|
|
1343
1376
|
"""
|
|
1344
1377
|
...
|
|
1345
1378
|
|
|
1346
|
-
|
|
1379
|
+
@typing.overload
|
|
1380
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1347
1381
|
"""
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
User code call
|
|
1351
|
-
--------------
|
|
1352
|
-
@vllm(
|
|
1353
|
-
model="...",
|
|
1354
|
-
...
|
|
1355
|
-
)
|
|
1356
|
-
|
|
1357
|
-
Valid backend options
|
|
1358
|
-
---------------------
|
|
1359
|
-
- 'local': Run as a separate process on the local task machine.
|
|
1360
|
-
|
|
1361
|
-
Valid model options
|
|
1362
|
-
-------------------
|
|
1363
|
-
Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
|
|
1364
|
-
|
|
1365
|
-
NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
|
|
1366
|
-
If you need multiple models, you must create multiple @vllm decorators.
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
Parameters
|
|
1370
|
-
----------
|
|
1371
|
-
model: str
|
|
1372
|
-
HuggingFace model identifier to be served by vLLM.
|
|
1373
|
-
backend: str
|
|
1374
|
-
Determines where and how to run the vLLM process.
|
|
1375
|
-
openai_api_server: bool
|
|
1376
|
-
Whether to use OpenAI-compatible API server mode (subprocess) instead of native engine.
|
|
1377
|
-
Default is False (uses native engine).
|
|
1378
|
-
Set to True for backward compatibility with existing code.
|
|
1379
|
-
debug: bool
|
|
1380
|
-
Whether to turn on verbose debugging logs.
|
|
1381
|
-
card_refresh_interval: int
|
|
1382
|
-
Interval in seconds for refreshing the vLLM status card.
|
|
1383
|
-
Only used when openai_api_server=True.
|
|
1384
|
-
max_retries: int
|
|
1385
|
-
Maximum number of retries checking for vLLM server startup.
|
|
1386
|
-
Only used when openai_api_server=True.
|
|
1387
|
-
retry_alert_frequency: int
|
|
1388
|
-
Frequency of alert logs for vLLM server startup retries.
|
|
1389
|
-
Only used when openai_api_server=True.
|
|
1390
|
-
engine_args : dict
|
|
1391
|
-
Additional keyword arguments to pass to the vLLM engine.
|
|
1392
|
-
For example, `tensor_parallel_size=2`.
|
|
1382
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
1383
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
1393
1384
|
"""
|
|
1394
1385
|
...
|
|
1395
1386
|
|
|
1396
|
-
|
|
1387
|
+
@typing.overload
|
|
1388
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1389
|
+
...
|
|
1390
|
+
|
|
1391
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
1397
1392
|
"""
|
|
1398
|
-
Decorator
|
|
1393
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
1394
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
1395
|
+
"""
|
|
1396
|
+
...
|
|
1397
|
+
|
|
1398
|
+
def nebius_s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode: typing.Optional[str] = None, debug: typing.Optional[bool] = 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]]]:
|
|
1399
|
+
"""
|
|
1400
|
+
`@nebius_s3_proxy` is a Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
1401
|
+
It exists to make it easier for users to know that this decorator should only be used with
|
|
1402
|
+
a Neo Cloud like Nebius. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
1399
1403
|
|
|
1400
|
-
Examples
|
|
1401
|
-
--------
|
|
1402
1404
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
@huggingface_hub
|
|
1406
|
-
@step
|
|
1407
|
-
def pull_model_from_huggingface(self):
|
|
1408
|
-
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
|
1409
|
-
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
|
1410
|
-
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
|
1411
|
-
# value of the function is a reference to the model in the backend storage.
|
|
1412
|
-
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
|
1405
|
+
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
1406
|
+
for S3 read and write requests.
|
|
1413
1407
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
|
1418
|
-
)
|
|
1419
|
-
self.next(self.train)
|
|
1408
|
+
This decorator requires an integration in the Outerbounds platform that
|
|
1409
|
+
points to an external bucket. It affects S3 operations performed via
|
|
1410
|
+
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
1420
1411
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
repo_id="google-bert/bert-base-uncased",
|
|
1428
|
-
allow_patterns=["*.bin"],
|
|
1429
|
-
) as local_path:
|
|
1430
|
-
# Use files under local_path
|
|
1431
|
-
train_model(local_path)
|
|
1432
|
-
...
|
|
1412
|
+
Read operations
|
|
1413
|
+
---------------
|
|
1414
|
+
All read operations pass through the proxy. If an object does not already
|
|
1415
|
+
exist in the external bucket, it is cached there. For example, if code reads
|
|
1416
|
+
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
1417
|
+
buckets are cached in the external bucket.
|
|
1433
1418
|
|
|
1434
|
-
|
|
1419
|
+
During task execution, all S3‑related read requests are routed through the
|
|
1420
|
+
proxy:
|
|
1421
|
+
- If the object is present in the external object store, the proxy
|
|
1422
|
+
streams it directly from there without accessing the requested origin
|
|
1423
|
+
bucket.
|
|
1424
|
+
- If the object is not present in the external storage, the proxy
|
|
1425
|
+
fetches it from the requested bucket, caches it in the external
|
|
1426
|
+
storage, and streams the response from the origin bucket.
|
|
1435
1427
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1428
|
+
Warning
|
|
1429
|
+
-------
|
|
1430
|
+
All READ operations (e.g., GetObject, HeadObject) pass through the external
|
|
1431
|
+
bucket regardless of the bucket specified in user code. Even
|
|
1432
|
+
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
1433
|
+
external bucket cache.
|
|
1440
1434
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
# path_to_model will be /my-directory
|
|
1435
|
+
Write operations
|
|
1436
|
+
----------------
|
|
1437
|
+
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
1438
|
+
whether writes also persist objects in the cache.
|
|
1446
1439
|
|
|
1440
|
+
`write_mode` values:
|
|
1441
|
+
- `origin-and-cache`: objects are written both to the cache and to their
|
|
1442
|
+
intended origin bucket.
|
|
1443
|
+
- `origin`: objects are written only to their intended origin bucket.
|
|
1447
1444
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1445
|
+
|
|
1446
|
+
Parameters
|
|
1447
|
+
----------
|
|
1448
|
+
integration_name : str, optional
|
|
1449
|
+
[Outerbounds integration name](https://docs.outerbounds.com/outerbounds/configuring-secrets/#integrations-view)
|
|
1450
|
+
that holds the configuration for the external, S3‑compatible object
|
|
1451
|
+
storage bucket. If not specified, the only available S3 proxy
|
|
1452
|
+
integration in the namespace is used (fails if multiple exist).
|
|
1453
|
+
write_mode : str, optional
|
|
1454
|
+
Controls whether writes also go to the external bucket.
|
|
1455
|
+
- `origin` (default)
|
|
1456
|
+
- `origin-and-cache`
|
|
1457
|
+
debug : bool, optional
|
|
1458
|
+
Enables debug logging for proxy operations.
|
|
1459
|
+
"""
|
|
1460
|
+
...
|
|
1461
|
+
|
|
1462
|
+
@typing.overload
|
|
1463
|
+
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]]]:
|
|
1464
|
+
"""
|
|
1465
|
+
Specifies the PyPI packages for the step.
|
|
1466
|
+
|
|
1467
|
+
Information in this decorator will augment any
|
|
1468
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
1469
|
+
you can use `@pypi_base` to set packages required by all
|
|
1470
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1464
1471
|
|
|
1465
1472
|
|
|
1466
1473
|
Parameters
|
|
1467
1474
|
----------
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
- Since objects are written on a `namespace/flow/step` basis, the blast radius of a bad checkpoint is limited to a particular flow in a namespace.
|
|
1489
|
-
- `flow`:
|
|
1490
|
-
- Has less control over when caches are populated (can be written by any execution instance of a flow from any namespace) but results in more cache hits.
|
|
1491
|
-
- The blast radius of a bad checkpoint is limited to all runs of a particular flow.
|
|
1492
|
-
- It doesn't promote cache reuse across flows.
|
|
1493
|
-
- `global`:
|
|
1494
|
-
- Has no control over when caches are populated (can be written by any flow execution) but has the highest cache hit rate.
|
|
1495
|
-
- It promotes cache reuse across flows.
|
|
1496
|
-
- The blast radius of a bad checkpoint spans every flow that could be using a particular repo.
|
|
1497
|
-
|
|
1498
|
-
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
|
1499
|
-
The list of repos (models/datasets) to load.
|
|
1475
|
+
packages : Dict[str, str], default: {}
|
|
1476
|
+
Packages to use for this step. The key is the name of the package
|
|
1477
|
+
and the value is the version to use.
|
|
1478
|
+
python : str, optional, default: None
|
|
1479
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1480
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1481
|
+
"""
|
|
1482
|
+
...
|
|
1483
|
+
|
|
1484
|
+
@typing.overload
|
|
1485
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1486
|
+
...
|
|
1487
|
+
|
|
1488
|
+
@typing.overload
|
|
1489
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1490
|
+
...
|
|
1491
|
+
|
|
1492
|
+
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):
|
|
1493
|
+
"""
|
|
1494
|
+
Specifies the PyPI packages for the step.
|
|
1500
1495
|
|
|
1501
|
-
|
|
1496
|
+
Information in this decorator will augment any
|
|
1497
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
1498
|
+
you can use `@pypi_base` to set packages required by all
|
|
1499
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1502
1500
|
|
|
1503
|
-
- If repo (model/dataset) is not found in the datastore:
|
|
1504
|
-
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
|
1505
|
-
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
|
1506
|
-
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
|
1507
1501
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1502
|
+
Parameters
|
|
1503
|
+
----------
|
|
1504
|
+
packages : Dict[str, str], default: {}
|
|
1505
|
+
Packages to use for this step. The key is the name of the package
|
|
1506
|
+
and the value is the version to use.
|
|
1507
|
+
python : str, optional, default: None
|
|
1508
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1509
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1510
1510
|
"""
|
|
1511
1511
|
...
|
|
1512
1512
|
|
|
@@ -1561,49 +1561,6 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
|
|
|
1561
1561
|
"""
|
|
1562
1562
|
...
|
|
1563
1563
|
|
|
1564
|
-
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]]:
|
|
1565
|
-
"""
|
|
1566
|
-
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.
|
|
1567
|
-
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.
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
Parameters
|
|
1571
|
-
----------
|
|
1572
|
-
timeout : int
|
|
1573
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
|
1574
|
-
poke_interval : int
|
|
1575
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
|
1576
|
-
mode : str
|
|
1577
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
|
1578
|
-
exponential_backoff : bool
|
|
1579
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
|
1580
|
-
pool : str
|
|
1581
|
-
the slot pool this task should run in,
|
|
1582
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
1583
|
-
soft_fail : bool
|
|
1584
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
1585
|
-
name : str
|
|
1586
|
-
Name of the sensor on Airflow
|
|
1587
|
-
description : str
|
|
1588
|
-
Description of sensor in the Airflow UI
|
|
1589
|
-
external_dag_id : str
|
|
1590
|
-
The dag_id that contains the task you want to wait for.
|
|
1591
|
-
external_task_ids : List[str]
|
|
1592
|
-
The list of task_ids that you want to wait for.
|
|
1593
|
-
If None (default value) the sensor waits for the DAG. (Default: None)
|
|
1594
|
-
allowed_states : List[str]
|
|
1595
|
-
Iterable of allowed states, (Default: ['success'])
|
|
1596
|
-
failed_states : List[str]
|
|
1597
|
-
Iterable of failed or dis-allowed states. (Default: None)
|
|
1598
|
-
execution_delta : datetime.timedelta
|
|
1599
|
-
time difference with the previous execution to look at,
|
|
1600
|
-
the default is the same logical date as the current task or DAG. (Default: None)
|
|
1601
|
-
check_existence: bool
|
|
1602
|
-
Set to True to check if the external task exists or check if
|
|
1603
|
-
the DAG to wait for exists. (Default: True)
|
|
1604
|
-
"""
|
|
1605
|
-
...
|
|
1606
|
-
|
|
1607
1564
|
def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, exponential_backoff: bool, pool: str, soft_fail: bool, name: str, description: str, bucket_key: typing.Union[str, typing.List[str]], bucket_name: str, wildcard_match: bool, aws_conn_id: str, verify: bool) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1608
1565
|
"""
|
|
1609
1566
|
The `@airflow_s3_key_sensor` decorator attaches a Airflow [S3KeySensor](https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_api/airflow/providers/amazon/aws/sensors/s3/index.html#airflow.providers.amazon.aws.sensors.s3.S3KeySensor)
|
|
@@ -1647,82 +1604,6 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
|
|
|
1647
1604
|
"""
|
|
1648
1605
|
...
|
|
1649
1606
|
|
|
1650
|
-
@typing.overload
|
|
1651
|
-
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1652
|
-
"""
|
|
1653
|
-
Specifies the PyPI packages for all steps of the flow.
|
|
1654
|
-
|
|
1655
|
-
Use `@pypi_base` to set common packages required by all
|
|
1656
|
-
steps and use `@pypi` to specify step-specific overrides.
|
|
1657
|
-
|
|
1658
|
-
Parameters
|
|
1659
|
-
----------
|
|
1660
|
-
packages : Dict[str, str], default: {}
|
|
1661
|
-
Packages to use for this flow. The key is the name of the package
|
|
1662
|
-
and the value is the version to use.
|
|
1663
|
-
python : str, optional, default: None
|
|
1664
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1665
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1666
|
-
"""
|
|
1667
|
-
...
|
|
1668
|
-
|
|
1669
|
-
@typing.overload
|
|
1670
|
-
def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1671
|
-
...
|
|
1672
|
-
|
|
1673
|
-
def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
|
1674
|
-
"""
|
|
1675
|
-
Specifies the PyPI packages for all steps of the flow.
|
|
1676
|
-
|
|
1677
|
-
Use `@pypi_base` to set common packages required by all
|
|
1678
|
-
steps and use `@pypi` to specify step-specific overrides.
|
|
1679
|
-
|
|
1680
|
-
Parameters
|
|
1681
|
-
----------
|
|
1682
|
-
packages : Dict[str, str], default: {}
|
|
1683
|
-
Packages to use for this flow. The key is the name of the package
|
|
1684
|
-
and the value is the version to use.
|
|
1685
|
-
python : str, optional, default: None
|
|
1686
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1687
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1688
|
-
"""
|
|
1689
|
-
...
|
|
1690
|
-
|
|
1691
|
-
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1692
|
-
"""
|
|
1693
|
-
Specifies what flows belong to the same project.
|
|
1694
|
-
|
|
1695
|
-
A project-specific namespace is created for all flows that
|
|
1696
|
-
use the same `@project(name)`.
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
Parameters
|
|
1700
|
-
----------
|
|
1701
|
-
name : str
|
|
1702
|
-
Project name. Make sure that the name is unique amongst all
|
|
1703
|
-
projects that use the same production scheduler. The name may
|
|
1704
|
-
contain only lowercase alphanumeric characters and underscores.
|
|
1705
|
-
|
|
1706
|
-
branch : Optional[str], default None
|
|
1707
|
-
The branch to use. If not specified, the branch is set to
|
|
1708
|
-
`user.<username>` unless `production` is set to `True`. This can
|
|
1709
|
-
also be set on the command line using `--branch` as a top-level option.
|
|
1710
|
-
It is an error to specify `branch` in the decorator and on the command line.
|
|
1711
|
-
|
|
1712
|
-
production : bool, default False
|
|
1713
|
-
Whether or not the branch is the production branch. This can also be set on the
|
|
1714
|
-
command line using `--production` as a top-level option. It is an error to specify
|
|
1715
|
-
`production` in the decorator and on the command line.
|
|
1716
|
-
The project branch name will be:
|
|
1717
|
-
- if `branch` is specified:
|
|
1718
|
-
- if `production` is True: `prod.<branch>`
|
|
1719
|
-
- if `production` is False: `test.<branch>`
|
|
1720
|
-
- if `branch` is not specified:
|
|
1721
|
-
- if `production` is True: `prod`
|
|
1722
|
-
- if `production` is False: `user.<username>`
|
|
1723
|
-
"""
|
|
1724
|
-
...
|
|
1725
|
-
|
|
1726
1607
|
@typing.overload
|
|
1727
1608
|
def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1728
1609
|
"""
|
|
@@ -1755,115 +1636,100 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
|
|
|
1755
1636
|
"""
|
|
1756
1637
|
Specifies the Conda environment for all steps of the flow.
|
|
1757
1638
|
|
|
1758
|
-
Use `@conda_base` to set common libraries required by all
|
|
1759
|
-
steps and use `@conda` to specify step-specific additions.
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
Parameters
|
|
1763
|
-
----------
|
|
1764
|
-
packages : Dict[str, str], default {}
|
|
1765
|
-
Packages to use for this flow. The key is the name of the package
|
|
1766
|
-
and the value is the version to use.
|
|
1767
|
-
libraries : Dict[str, str], default {}
|
|
1768
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
1769
|
-
python : str, optional, default None
|
|
1770
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1771
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1772
|
-
disabled : bool, default False
|
|
1773
|
-
If set to True, disables Conda.
|
|
1774
|
-
"""
|
|
1775
|
-
...
|
|
1776
|
-
|
|
1777
|
-
@typing.overload
|
|
1778
|
-
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]]:
|
|
1779
|
-
"""
|
|
1780
|
-
Specifies the event(s) that this flow depends on.
|
|
1781
|
-
|
|
1782
|
-
```
|
|
1783
|
-
@trigger(event='foo')
|
|
1784
|
-
```
|
|
1785
|
-
or
|
|
1786
|
-
```
|
|
1787
|
-
@trigger(events=['foo', 'bar'])
|
|
1788
|
-
```
|
|
1789
|
-
|
|
1790
|
-
Additionally, you can specify the parameter mappings
|
|
1791
|
-
to map event payload to Metaflow parameters for the flow.
|
|
1792
|
-
```
|
|
1793
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
1794
|
-
```
|
|
1795
|
-
or
|
|
1796
|
-
```
|
|
1797
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
1798
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
1799
|
-
```
|
|
1800
|
-
|
|
1801
|
-
'parameters' can also be a list of strings and tuples like so:
|
|
1802
|
-
```
|
|
1803
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
1804
|
-
```
|
|
1805
|
-
This is equivalent to:
|
|
1806
|
-
```
|
|
1807
|
-
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
1808
|
-
```
|
|
1639
|
+
Use `@conda_base` to set common libraries required by all
|
|
1640
|
+
steps and use `@conda` to specify step-specific additions.
|
|
1809
1641
|
|
|
1810
1642
|
|
|
1811
1643
|
Parameters
|
|
1812
1644
|
----------
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1645
|
+
packages : Dict[str, str], default {}
|
|
1646
|
+
Packages to use for this flow. The key is the name of the package
|
|
1647
|
+
and the value is the version to use.
|
|
1648
|
+
libraries : Dict[str, str], default {}
|
|
1649
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
1650
|
+
python : str, optional, default None
|
|
1651
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1652
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1653
|
+
disabled : bool, default False
|
|
1654
|
+
If set to True, disables Conda.
|
|
1819
1655
|
"""
|
|
1820
1656
|
...
|
|
1821
1657
|
|
|
1822
|
-
|
|
1823
|
-
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1824
|
-
...
|
|
1825
|
-
|
|
1826
|
-
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] = {}):
|
|
1658
|
+
def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1827
1659
|
"""
|
|
1828
|
-
Specifies
|
|
1660
|
+
Specifies what flows belong to the same project.
|
|
1829
1661
|
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
```
|
|
1833
|
-
or
|
|
1834
|
-
```
|
|
1835
|
-
@trigger(events=['foo', 'bar'])
|
|
1836
|
-
```
|
|
1662
|
+
A project-specific namespace is created for all flows that
|
|
1663
|
+
use the same `@project(name)`.
|
|
1837
1664
|
|
|
1838
|
-
Additionally, you can specify the parameter mappings
|
|
1839
|
-
to map event payload to Metaflow parameters for the flow.
|
|
1840
|
-
```
|
|
1841
|
-
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
1842
|
-
```
|
|
1843
|
-
or
|
|
1844
|
-
```
|
|
1845
|
-
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
1846
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
1847
|
-
```
|
|
1848
1665
|
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1666
|
+
Parameters
|
|
1667
|
+
----------
|
|
1668
|
+
name : str
|
|
1669
|
+
Project name. Make sure that the name is unique amongst all
|
|
1670
|
+
projects that use the same production scheduler. The name may
|
|
1671
|
+
contain only lowercase alphanumeric characters and underscores.
|
|
1672
|
+
|
|
1673
|
+
branch : Optional[str], default None
|
|
1674
|
+
The branch to use. If not specified, the branch is set to
|
|
1675
|
+
`user.<username>` unless `production` is set to `True`. This can
|
|
1676
|
+
also be set on the command line using `--branch` as a top-level option.
|
|
1677
|
+
It is an error to specify `branch` in the decorator and on the command line.
|
|
1678
|
+
|
|
1679
|
+
production : bool, default False
|
|
1680
|
+
Whether or not the branch is the production branch. This can also be set on the
|
|
1681
|
+
command line using `--production` as a top-level option. It is an error to specify
|
|
1682
|
+
`production` in the decorator and on the command line.
|
|
1683
|
+
The project branch name will be:
|
|
1684
|
+
- if `branch` is specified:
|
|
1685
|
+
- if `production` is True: `prod.<branch>`
|
|
1686
|
+
- if `production` is False: `test.<branch>`
|
|
1687
|
+
- if `branch` is not specified:
|
|
1688
|
+
- if `production` is True: `prod`
|
|
1689
|
+
- if `production` is False: `user.<username>`
|
|
1690
|
+
"""
|
|
1691
|
+
...
|
|
1692
|
+
|
|
1693
|
+
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]]:
|
|
1694
|
+
"""
|
|
1695
|
+
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.
|
|
1696
|
+
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.
|
|
1857
1697
|
|
|
1858
1698
|
|
|
1859
1699
|
Parameters
|
|
1860
1700
|
----------
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1701
|
+
timeout : int
|
|
1702
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
|
1703
|
+
poke_interval : int
|
|
1704
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
|
1705
|
+
mode : str
|
|
1706
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
|
1707
|
+
exponential_backoff : bool
|
|
1708
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
|
1709
|
+
pool : str
|
|
1710
|
+
the slot pool this task should run in,
|
|
1711
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
1712
|
+
soft_fail : bool
|
|
1713
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
1714
|
+
name : str
|
|
1715
|
+
Name of the sensor on Airflow
|
|
1716
|
+
description : str
|
|
1717
|
+
Description of sensor in the Airflow UI
|
|
1718
|
+
external_dag_id : str
|
|
1719
|
+
The dag_id that contains the task you want to wait for.
|
|
1720
|
+
external_task_ids : List[str]
|
|
1721
|
+
The list of task_ids that you want to wait for.
|
|
1722
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
|
1723
|
+
allowed_states : List[str]
|
|
1724
|
+
Iterable of allowed states, (Default: ['success'])
|
|
1725
|
+
failed_states : List[str]
|
|
1726
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
|
1727
|
+
execution_delta : datetime.timedelta
|
|
1728
|
+
time difference with the previous execution to look at,
|
|
1729
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
|
1730
|
+
check_existence: bool
|
|
1731
|
+
Set to True to check if the external task exists or check if
|
|
1732
|
+
the DAG to wait for exists. (Default: True)
|
|
1867
1733
|
"""
|
|
1868
1734
|
...
|
|
1869
1735
|
|
|
@@ -2082,5 +1948,139 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
|
|
|
2082
1948
|
"""
|
|
2083
1949
|
...
|
|
2084
1950
|
|
|
1951
|
+
@typing.overload
|
|
1952
|
+
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1953
|
+
"""
|
|
1954
|
+
Specifies the PyPI packages for all steps of the flow.
|
|
1955
|
+
|
|
1956
|
+
Use `@pypi_base` to set common packages required by all
|
|
1957
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1958
|
+
|
|
1959
|
+
Parameters
|
|
1960
|
+
----------
|
|
1961
|
+
packages : Dict[str, str], default: {}
|
|
1962
|
+
Packages to use for this flow. The key is the name of the package
|
|
1963
|
+
and the value is the version to use.
|
|
1964
|
+
python : str, optional, default: None
|
|
1965
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1966
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1967
|
+
"""
|
|
1968
|
+
...
|
|
1969
|
+
|
|
1970
|
+
@typing.overload
|
|
1971
|
+
def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1972
|
+
...
|
|
1973
|
+
|
|
1974
|
+
def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
|
1975
|
+
"""
|
|
1976
|
+
Specifies the PyPI packages for all steps of the flow.
|
|
1977
|
+
|
|
1978
|
+
Use `@pypi_base` to set common packages required by all
|
|
1979
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1980
|
+
|
|
1981
|
+
Parameters
|
|
1982
|
+
----------
|
|
1983
|
+
packages : Dict[str, str], default: {}
|
|
1984
|
+
Packages to use for this flow. The key is the name of the package
|
|
1985
|
+
and the value is the version to use.
|
|
1986
|
+
python : str, optional, default: None
|
|
1987
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1988
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1989
|
+
"""
|
|
1990
|
+
...
|
|
1991
|
+
|
|
1992
|
+
@typing.overload
|
|
1993
|
+
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]]:
|
|
1994
|
+
"""
|
|
1995
|
+
Specifies the event(s) that this flow depends on.
|
|
1996
|
+
|
|
1997
|
+
```
|
|
1998
|
+
@trigger(event='foo')
|
|
1999
|
+
```
|
|
2000
|
+
or
|
|
2001
|
+
```
|
|
2002
|
+
@trigger(events=['foo', 'bar'])
|
|
2003
|
+
```
|
|
2004
|
+
|
|
2005
|
+
Additionally, you can specify the parameter mappings
|
|
2006
|
+
to map event payload to Metaflow parameters for the flow.
|
|
2007
|
+
```
|
|
2008
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
2009
|
+
```
|
|
2010
|
+
or
|
|
2011
|
+
```
|
|
2012
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
2013
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
2014
|
+
```
|
|
2015
|
+
|
|
2016
|
+
'parameters' can also be a list of strings and tuples like so:
|
|
2017
|
+
```
|
|
2018
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
2019
|
+
```
|
|
2020
|
+
This is equivalent to:
|
|
2021
|
+
```
|
|
2022
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
2023
|
+
```
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
Parameters
|
|
2027
|
+
----------
|
|
2028
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
|
2029
|
+
Event dependency for this flow.
|
|
2030
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
|
2031
|
+
Events dependency for this flow.
|
|
2032
|
+
options : Dict[str, Any], default {}
|
|
2033
|
+
Backend-specific configuration for tuning eventing behavior.
|
|
2034
|
+
"""
|
|
2035
|
+
...
|
|
2036
|
+
|
|
2037
|
+
@typing.overload
|
|
2038
|
+
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
2039
|
+
...
|
|
2040
|
+
|
|
2041
|
+
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] = {}):
|
|
2042
|
+
"""
|
|
2043
|
+
Specifies the event(s) that this flow depends on.
|
|
2044
|
+
|
|
2045
|
+
```
|
|
2046
|
+
@trigger(event='foo')
|
|
2047
|
+
```
|
|
2048
|
+
or
|
|
2049
|
+
```
|
|
2050
|
+
@trigger(events=['foo', 'bar'])
|
|
2051
|
+
```
|
|
2052
|
+
|
|
2053
|
+
Additionally, you can specify the parameter mappings
|
|
2054
|
+
to map event payload to Metaflow parameters for the flow.
|
|
2055
|
+
```
|
|
2056
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
|
2057
|
+
```
|
|
2058
|
+
or
|
|
2059
|
+
```
|
|
2060
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
|
2061
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
|
2062
|
+
```
|
|
2063
|
+
|
|
2064
|
+
'parameters' can also be a list of strings and tuples like so:
|
|
2065
|
+
```
|
|
2066
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
|
2067
|
+
```
|
|
2068
|
+
This is equivalent to:
|
|
2069
|
+
```
|
|
2070
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
|
2071
|
+
```
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
Parameters
|
|
2075
|
+
----------
|
|
2076
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
|
2077
|
+
Event dependency for this flow.
|
|
2078
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
|
2079
|
+
Events dependency for this flow.
|
|
2080
|
+
options : Dict[str, Any], default {}
|
|
2081
|
+
Backend-specific configuration for tuning eventing behavior.
|
|
2082
|
+
"""
|
|
2083
|
+
...
|
|
2084
|
+
|
|
2085
2085
|
pkg_name: str
|
|
2086
2086
|
|