ob-metaflow-stubs 6.0.10.14__py2.py3-none-any.whl → 6.0.10.15__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 +965 -965
- metaflow-stubs/cards.pyi +1 -1
- metaflow-stubs/cli.pyi +1 -1
- metaflow-stubs/cli_components/__init__.pyi +1 -1
- metaflow-stubs/cli_components/utils.pyi +1 -1
- metaflow-stubs/client/__init__.pyi +1 -1
- metaflow-stubs/client/core.pyi +3 -3
- metaflow-stubs/client/filecache.pyi +1 -1
- metaflow-stubs/events.pyi +2 -2
- metaflow-stubs/exception.pyi +1 -1
- metaflow-stubs/flowspec.pyi +3 -3
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +2 -2
- metaflow-stubs/meta_files.pyi +1 -1
- metaflow-stubs/metadata_provider/__init__.pyi +1 -1
- metaflow-stubs/metadata_provider/heartbeat.pyi +1 -1
- metaflow-stubs/metadata_provider/metadata.pyi +1 -1
- metaflow-stubs/metadata_provider/util.pyi +1 -1
- metaflow-stubs/metaflow_config.pyi +1 -1
- metaflow-stubs/metaflow_current.pyi +82 -82
- metaflow-stubs/metaflow_git.pyi +1 -1
- metaflow-stubs/mf_extensions/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/cards/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/cards/hf_hub_card.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +1 -1
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_state_machine.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/spinners.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_cli.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/capsule.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/click_importer.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/code_packager.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/cli_generator.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/config_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/schema_export.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/typed_configs.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/unified_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/dependencies.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/deployer.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/experimental/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/perimeters.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/utils.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/aws/assume_role_decorator.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
- metaflow-stubs/mf_extensions/outerbounds/toplevel/s3_proxy.pyi +1 -1
- metaflow-stubs/multicore_utils.pyi +1 -1
- metaflow-stubs/ob_internal.pyi +1 -1
- metaflow-stubs/packaging_sys/__init__.pyi +5 -5
- metaflow-stubs/packaging_sys/backend.pyi +1 -1
- metaflow-stubs/packaging_sys/distribution_support.pyi +4 -4
- metaflow-stubs/packaging_sys/tar_backend.pyi +4 -4
- metaflow-stubs/packaging_sys/utils.pyi +1 -1
- metaflow-stubs/packaging_sys/v1.pyi +1 -1
- metaflow-stubs/parameters.pyi +2 -2
- metaflow-stubs/plugins/__init__.pyi +13 -13
- metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
- metaflow-stubs/plugins/airflow/exception.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
- metaflow-stubs/plugins/argo/__init__.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_workflows.pyi +1 -1
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +1 -1
- metaflow-stubs/plugins/argo/exit_hooks.pyi +1 -1
- metaflow-stubs/plugins/aws/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
- metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +1 -1
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +1 -1
- metaflow-stubs/plugins/azure/__init__.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
- metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/cards/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_client.pyi +1 -1
- metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
- metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/json_viewer.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
- metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
- metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
- metaflow-stubs/plugins/cards/exception.pyi +1 -1
- metaflow-stubs/plugins/catch_decorator.pyi +2 -2
- metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/local.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
- metaflow-stubs/plugins/debug_logger.pyi +1 -1
- metaflow-stubs/plugins/debug_monitor.pyi +1 -1
- metaflow-stubs/plugins/environment_decorator.pyi +1 -1
- metaflow-stubs/plugins/events_decorator.pyi +1 -1
- metaflow-stubs/plugins/exit_hook/__init__.pyi +1 -1
- metaflow-stubs/plugins/exit_hook/exit_hook_decorator.pyi +1 -1
- metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
- metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
- metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
- metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
- metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
- metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
- metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/plugins/optuna/__init__.pyi +1 -1
- metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
- metaflow-stubs/plugins/parsers.pyi +1 -1
- metaflow-stubs/plugins/perimeters.pyi +1 -1
- metaflow-stubs/plugins/project_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
- metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
- metaflow-stubs/plugins/pypi/utils.pyi +1 -1
- metaflow-stubs/plugins/resources_decorator.pyi +1 -1
- metaflow-stubs/plugins/retry_decorator.pyi +1 -1
- metaflow-stubs/plugins/secrets/__init__.pyi +1 -1
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +1 -1
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
- metaflow-stubs/plugins/secrets/secrets_func.pyi +1 -1
- metaflow-stubs/plugins/secrets/secrets_spec.pyi +1 -1
- metaflow-stubs/plugins/secrets/utils.pyi +1 -1
- metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
- metaflow-stubs/plugins/storage_executor.pyi +1 -1
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
- metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
- metaflow-stubs/plugins/torchtune/__init__.pyi +1 -1
- metaflow-stubs/plugins/uv/__init__.pyi +1 -1
- metaflow-stubs/plugins/uv/uv_environment.pyi +1 -1
- metaflow-stubs/profilers/__init__.pyi +1 -1
- metaflow-stubs/pylint_wrapper.pyi +1 -1
- metaflow-stubs/runner/__init__.pyi +1 -1
- metaflow-stubs/runner/deployer.pyi +3 -3
- metaflow-stubs/runner/deployer_impl.pyi +1 -1
- metaflow-stubs/runner/metaflow_runner.pyi +2 -2
- metaflow-stubs/runner/nbdeploy.pyi +1 -1
- metaflow-stubs/runner/nbrun.pyi +1 -1
- metaflow-stubs/runner/subprocess_manager.pyi +1 -1
- metaflow-stubs/runner/utils.pyi +2 -2
- metaflow-stubs/system/__init__.pyi +1 -1
- metaflow-stubs/system/system_logger.pyi +1 -1
- metaflow-stubs/system/system_monitor.pyi +1 -1
- metaflow-stubs/tagging_util.pyi +1 -1
- metaflow-stubs/tuple_util.pyi +1 -1
- metaflow-stubs/user_configs/__init__.pyi +1 -1
- metaflow-stubs/user_configs/config_options.pyi +1 -1
- metaflow-stubs/user_configs/config_parameters.pyi +6 -6
- metaflow-stubs/user_decorators/__init__.pyi +1 -1
- metaflow-stubs/user_decorators/common.pyi +1 -1
- metaflow-stubs/user_decorators/mutable_flow.pyi +4 -4
- metaflow-stubs/user_decorators/mutable_step.pyi +5 -5
- metaflow-stubs/user_decorators/user_flow_decorator.pyi +2 -2
- metaflow-stubs/user_decorators/user_step_decorator.pyi +3 -3
- {ob_metaflow_stubs-6.0.10.14.dist-info → ob_metaflow_stubs-6.0.10.15.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.10.15.dist-info/RECORD +266 -0
- ob_metaflow_stubs-6.0.10.14.dist-info/RECORD +0 -266
- {ob_metaflow_stubs-6.0.10.14.dist-info → ob_metaflow_stubs-6.0.10.15.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.10.14.dist-info → ob_metaflow_stubs-6.0.10.15.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
######################################################################################################
|
|
2
2
|
# Auto-generated Metaflow stub file #
|
|
3
3
|
# MF version: 2.18.10.1+obcheckpoint(0.2.8);ob(v1) #
|
|
4
|
-
# Generated on 2025-10-
|
|
4
|
+
# Generated on 2025-10-09T09:15:42.339267 #
|
|
5
5
|
######################################################################################################
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
@@ -39,19 +39,19 @@ 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 metaflow_git as metaflow_git
|
|
42
43
|
from . import cards as cards
|
|
43
|
-
from . import events as events
|
|
44
44
|
from . import tuple_util as tuple_util
|
|
45
|
-
from . import
|
|
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
|
|
49
49
|
from . import includefile as includefile
|
|
50
50
|
from .includefile import IncludeFile as IncludeFile
|
|
51
|
+
from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
|
|
51
52
|
from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
|
|
52
|
-
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
|
|
53
53
|
from .plugins.parsers import yaml_parser as yaml_parser
|
|
54
|
-
from .plugins.pypi.parsers import
|
|
54
|
+
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_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
|
|
@@ -170,107 +170,188 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
|
170
170
|
...
|
|
171
171
|
|
|
172
172
|
@typing.overload
|
|
173
|
-
def
|
|
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]]]:
|
|
174
174
|
"""
|
|
175
|
-
Specifies
|
|
176
|
-
|
|
177
|
-
This decorator is useful if this step may hang indefinitely.
|
|
175
|
+
Specifies the resources needed when executing this step.
|
|
178
176
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
177
|
+
Use `@resources` to specify the resource requirements
|
|
178
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
182
179
|
|
|
183
|
-
|
|
184
|
-
|
|
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`.
|
|
185
190
|
|
|
186
191
|
|
|
187
192
|
Parameters
|
|
188
193
|
----------
|
|
189
|
-
|
|
190
|
-
Number of
|
|
191
|
-
|
|
192
|
-
Number of
|
|
193
|
-
|
|
194
|
-
|
|
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.
|
|
195
205
|
"""
|
|
196
206
|
...
|
|
197
207
|
|
|
198
208
|
@typing.overload
|
|
199
|
-
def
|
|
209
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
200
210
|
...
|
|
201
211
|
|
|
202
212
|
@typing.overload
|
|
203
|
-
def
|
|
213
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
204
214
|
...
|
|
205
215
|
|
|
206
|
-
def
|
|
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):
|
|
207
217
|
"""
|
|
208
|
-
Specifies
|
|
209
|
-
|
|
210
|
-
This decorator is useful if this step may hang indefinitely.
|
|
218
|
+
Specifies the resources needed when executing this step.
|
|
211
219
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
220
|
+
Use `@resources` to specify the resource requirements
|
|
221
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
215
222
|
|
|
216
|
-
|
|
217
|
-
|
|
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`.
|
|
218
233
|
|
|
219
234
|
|
|
220
235
|
Parameters
|
|
221
236
|
----------
|
|
222
|
-
|
|
223
|
-
Number of
|
|
224
|
-
|
|
225
|
-
Number of
|
|
226
|
-
|
|
227
|
-
|
|
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.
|
|
228
248
|
"""
|
|
229
249
|
...
|
|
230
250
|
|
|
231
251
|
@typing.overload
|
|
232
|
-
def
|
|
252
|
+
def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
233
253
|
"""
|
|
234
|
-
|
|
254
|
+
Specifies the Conda environment for the step.
|
|
255
|
+
|
|
256
|
+
Information in this decorator will augment any
|
|
257
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
258
|
+
you can use `@conda_base` to set packages required by all
|
|
259
|
+
steps and use `@conda` to specify step-specific overrides.
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
Parameters
|
|
263
|
+
----------
|
|
264
|
+
packages : Dict[str, str], default {}
|
|
265
|
+
Packages to use for this step. The key is the name of the package
|
|
266
|
+
and the value is the version to use.
|
|
267
|
+
libraries : Dict[str, str], default {}
|
|
268
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
269
|
+
python : str, optional, default None
|
|
270
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
271
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
272
|
+
disabled : bool, default False
|
|
273
|
+
If set to True, disables @conda.
|
|
235
274
|
"""
|
|
236
275
|
...
|
|
237
276
|
|
|
238
277
|
@typing.overload
|
|
239
|
-
def
|
|
278
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
240
279
|
...
|
|
241
280
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
Internal decorator to support Fast bakery
|
|
245
|
-
"""
|
|
281
|
+
@typing.overload
|
|
282
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
246
283
|
...
|
|
247
284
|
|
|
248
|
-
|
|
249
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
285
|
+
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
|
250
286
|
"""
|
|
251
|
-
|
|
252
|
-
|
|
287
|
+
Specifies the Conda environment for the step.
|
|
288
|
+
|
|
289
|
+
Information in this decorator will augment any
|
|
290
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
291
|
+
you can use `@conda_base` to set packages required by all
|
|
292
|
+
steps and use `@conda` to specify step-specific overrides.
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
Parameters
|
|
296
|
+
----------
|
|
297
|
+
packages : Dict[str, str], default {}
|
|
298
|
+
Packages to use for this step. The key is the name of the package
|
|
299
|
+
and the value is the version to use.
|
|
300
|
+
libraries : Dict[str, str], default {}
|
|
301
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
302
|
+
python : str, optional, default None
|
|
303
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
304
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
305
|
+
disabled : bool, default False
|
|
306
|
+
If set to True, disables @conda.
|
|
253
307
|
"""
|
|
254
308
|
...
|
|
255
309
|
|
|
256
|
-
|
|
257
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
258
|
-
...
|
|
259
|
-
|
|
260
|
-
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
310
|
+
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]]]:
|
|
261
311
|
"""
|
|
262
|
-
|
|
263
|
-
|
|
312
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
|
313
|
+
|
|
314
|
+
User code call
|
|
315
|
+
--------------
|
|
316
|
+
@ollama(
|
|
317
|
+
models=[...],
|
|
318
|
+
...
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
Valid backend options
|
|
322
|
+
---------------------
|
|
323
|
+
- 'local': Run as a separate process on the local task machine.
|
|
324
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
|
325
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
|
326
|
+
|
|
327
|
+
Valid model options
|
|
328
|
+
-------------------
|
|
329
|
+
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
Parameters
|
|
333
|
+
----------
|
|
334
|
+
models: list[str]
|
|
335
|
+
List of Ollama containers running models in sidecars.
|
|
336
|
+
backend: str
|
|
337
|
+
Determines where and how to run the Ollama process.
|
|
338
|
+
force_pull: bool
|
|
339
|
+
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
|
340
|
+
cache_update_policy: str
|
|
341
|
+
Cache update policy: "auto", "force", or "never".
|
|
342
|
+
force_cache_update: bool
|
|
343
|
+
Simple override for "force" cache update policy.
|
|
344
|
+
debug: bool
|
|
345
|
+
Whether to turn on verbose debugging logs.
|
|
346
|
+
circuit_breaker_config: dict
|
|
347
|
+
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
|
348
|
+
timeout_config: dict
|
|
349
|
+
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
|
264
350
|
"""
|
|
265
351
|
...
|
|
266
352
|
|
|
267
|
-
def
|
|
353
|
+
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]]]:
|
|
268
354
|
"""
|
|
269
|
-
`@coreweave_s3_proxy` is a CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
270
|
-
It exists to make it easier for users to know that this decorator should only be used with
|
|
271
|
-
a Neo Cloud like CoreWeave. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
272
|
-
|
|
273
|
-
|
|
274
355
|
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
275
356
|
for S3 read and write requests.
|
|
276
357
|
|
|
@@ -329,207 +410,59 @@ def coreweave_s3_proxy(*, integration_name: typing.Optional[str] = None, write_m
|
|
|
329
410
|
...
|
|
330
411
|
|
|
331
412
|
@typing.overload
|
|
332
|
-
def
|
|
413
|
+
def card(*, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
333
414
|
"""
|
|
334
|
-
|
|
415
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
|
416
|
+
|
|
417
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
|
335
418
|
|
|
336
419
|
|
|
337
420
|
Parameters
|
|
338
421
|
----------
|
|
339
|
-
|
|
340
|
-
|
|
422
|
+
type : str, default 'default'
|
|
423
|
+
Card type.
|
|
424
|
+
id : str, optional, default None
|
|
425
|
+
If multiple cards are present, use this id to identify this card.
|
|
426
|
+
options : Dict[str, Any], default {}
|
|
427
|
+
Options passed to the card. The contents depend on the card type.
|
|
428
|
+
timeout : int, default 45
|
|
429
|
+
Interrupt reporting if it takes more than this many seconds.
|
|
341
430
|
"""
|
|
342
431
|
...
|
|
343
432
|
|
|
344
433
|
@typing.overload
|
|
345
|
-
def
|
|
434
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
346
435
|
...
|
|
347
436
|
|
|
348
437
|
@typing.overload
|
|
349
|
-
def
|
|
438
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
350
439
|
...
|
|
351
440
|
|
|
352
|
-
def
|
|
441
|
+
def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45):
|
|
353
442
|
"""
|
|
354
|
-
|
|
443
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
|
444
|
+
|
|
445
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
|
355
446
|
|
|
356
447
|
|
|
357
448
|
Parameters
|
|
358
449
|
----------
|
|
359
|
-
|
|
360
|
-
|
|
450
|
+
type : str, default 'default'
|
|
451
|
+
Card type.
|
|
452
|
+
id : str, optional, default None
|
|
453
|
+
If multiple cards are present, use this id to identify this card.
|
|
454
|
+
options : Dict[str, Any], default {}
|
|
455
|
+
Options passed to the card. The contents depend on the card type.
|
|
456
|
+
timeout : int, default 45
|
|
457
|
+
Interrupt reporting if it takes more than this many seconds.
|
|
361
458
|
"""
|
|
362
459
|
...
|
|
363
460
|
|
|
364
|
-
def
|
|
461
|
+
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]]]:
|
|
365
462
|
"""
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
Parameters
|
|
370
|
-
----------
|
|
371
|
-
gpu : int
|
|
372
|
-
Number of GPUs to use.
|
|
373
|
-
gpu_type : str
|
|
374
|
-
Type of Nvidia GPU to use.
|
|
375
|
-
queue_timeout : int
|
|
376
|
-
Time to keep the job in NVCF's queue.
|
|
377
|
-
"""
|
|
378
|
-
...
|
|
379
|
-
|
|
380
|
-
@typing.overload
|
|
381
|
-
def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
382
|
-
"""
|
|
383
|
-
A simple decorator that demonstrates using CardDecoratorInjector
|
|
384
|
-
to inject a card and render simple markdown content.
|
|
385
|
-
"""
|
|
386
|
-
...
|
|
387
|
-
|
|
388
|
-
@typing.overload
|
|
389
|
-
def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
390
|
-
...
|
|
391
|
-
|
|
392
|
-
def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
393
|
-
"""
|
|
394
|
-
A simple decorator that demonstrates using CardDecoratorInjector
|
|
395
|
-
to inject a card and render simple markdown content.
|
|
396
|
-
"""
|
|
397
|
-
...
|
|
398
|
-
|
|
399
|
-
@typing.overload
|
|
400
|
-
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]]]:
|
|
401
|
-
"""
|
|
402
|
-
Specifies the resources needed when executing this step.
|
|
403
|
-
|
|
404
|
-
Use `@resources` to specify the resource requirements
|
|
405
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
406
|
-
|
|
407
|
-
You can choose the compute layer on the command line by executing e.g.
|
|
408
|
-
```
|
|
409
|
-
python myflow.py run --with batch
|
|
410
|
-
```
|
|
411
|
-
or
|
|
412
|
-
```
|
|
413
|
-
python myflow.py run --with kubernetes
|
|
414
|
-
```
|
|
415
|
-
which executes the flow on the desired system using the
|
|
416
|
-
requirements specified in `@resources`.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
Parameters
|
|
420
|
-
----------
|
|
421
|
-
cpu : int, default 1
|
|
422
|
-
Number of CPUs required for this step.
|
|
423
|
-
gpu : int, optional, default None
|
|
424
|
-
Number of GPUs required for this step.
|
|
425
|
-
disk : int, optional, default None
|
|
426
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
427
|
-
memory : int, default 4096
|
|
428
|
-
Memory size (in MB) required for this step.
|
|
429
|
-
shared_memory : int, optional, default None
|
|
430
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
431
|
-
This parameter maps to the `--shm-size` option in Docker.
|
|
432
|
-
"""
|
|
433
|
-
...
|
|
434
|
-
|
|
435
|
-
@typing.overload
|
|
436
|
-
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
437
|
-
...
|
|
438
|
-
|
|
439
|
-
@typing.overload
|
|
440
|
-
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
441
|
-
...
|
|
442
|
-
|
|
443
|
-
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):
|
|
444
|
-
"""
|
|
445
|
-
Specifies the resources needed when executing this step.
|
|
446
|
-
|
|
447
|
-
Use `@resources` to specify the resource requirements
|
|
448
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
|
449
|
-
|
|
450
|
-
You can choose the compute layer on the command line by executing e.g.
|
|
451
|
-
```
|
|
452
|
-
python myflow.py run --with batch
|
|
453
|
-
```
|
|
454
|
-
or
|
|
455
|
-
```
|
|
456
|
-
python myflow.py run --with kubernetes
|
|
457
|
-
```
|
|
458
|
-
which executes the flow on the desired system using the
|
|
459
|
-
requirements specified in `@resources`.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
Parameters
|
|
463
|
-
----------
|
|
464
|
-
cpu : int, default 1
|
|
465
|
-
Number of CPUs required for this step.
|
|
466
|
-
gpu : int, optional, default None
|
|
467
|
-
Number of GPUs required for this step.
|
|
468
|
-
disk : int, optional, default None
|
|
469
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
|
470
|
-
memory : int, default 4096
|
|
471
|
-
Memory size (in MB) required for this step.
|
|
472
|
-
shared_memory : int, optional, default None
|
|
473
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
|
474
|
-
This parameter maps to the `--shm-size` option in Docker.
|
|
475
|
-
"""
|
|
476
|
-
...
|
|
477
|
-
|
|
478
|
-
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]]]:
|
|
479
|
-
"""
|
|
480
|
-
This decorator is used to run vllm APIs as Metaflow task sidecars.
|
|
481
|
-
|
|
482
|
-
User code call
|
|
483
|
-
--------------
|
|
484
|
-
@vllm(
|
|
485
|
-
model="...",
|
|
486
|
-
...
|
|
487
|
-
)
|
|
488
|
-
|
|
489
|
-
Valid backend options
|
|
490
|
-
---------------------
|
|
491
|
-
- 'local': Run as a separate process on the local task machine.
|
|
492
|
-
|
|
493
|
-
Valid model options
|
|
494
|
-
-------------------
|
|
495
|
-
Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
|
|
496
|
-
|
|
497
|
-
NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
|
|
498
|
-
If you need multiple models, you must create multiple @vllm decorators.
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
Parameters
|
|
502
|
-
----------
|
|
503
|
-
model: str
|
|
504
|
-
HuggingFace model identifier to be served by vLLM.
|
|
505
|
-
backend: str
|
|
506
|
-
Determines where and how to run the vLLM process.
|
|
507
|
-
openai_api_server: bool
|
|
508
|
-
Whether to use OpenAI-compatible API server mode (subprocess) instead of native engine.
|
|
509
|
-
Default is False (uses native engine).
|
|
510
|
-
Set to True for backward compatibility with existing code.
|
|
511
|
-
debug: bool
|
|
512
|
-
Whether to turn on verbose debugging logs.
|
|
513
|
-
card_refresh_interval: int
|
|
514
|
-
Interval in seconds for refreshing the vLLM status card.
|
|
515
|
-
Only used when openai_api_server=True.
|
|
516
|
-
max_retries: int
|
|
517
|
-
Maximum number of retries checking for vLLM server startup.
|
|
518
|
-
Only used when openai_api_server=True.
|
|
519
|
-
retry_alert_frequency: int
|
|
520
|
-
Frequency of alert logs for vLLM server startup retries.
|
|
521
|
-
Only used when openai_api_server=True.
|
|
522
|
-
engine_args : dict
|
|
523
|
-
Additional keyword arguments to pass to the vLLM engine.
|
|
524
|
-
For example, `tensor_parallel_size=2`.
|
|
525
|
-
"""
|
|
526
|
-
...
|
|
527
|
-
|
|
528
|
-
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]]]:
|
|
529
|
-
"""
|
|
530
|
-
`@nebius_s3_proxy` is a Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
531
|
-
It exists to make it easier for users to know that this decorator should only be used with
|
|
532
|
-
a Neo Cloud like Nebius. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
463
|
+
`@nebius_s3_proxy` is a Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
464
|
+
It exists to make it easier for users to know that this decorator should only be used with
|
|
465
|
+
a Neo Cloud like Nebius. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
533
466
|
|
|
534
467
|
|
|
535
468
|
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
@@ -589,61 +522,6 @@ def nebius_s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode
|
|
|
589
522
|
"""
|
|
590
523
|
...
|
|
591
524
|
|
|
592
|
-
@typing.overload
|
|
593
|
-
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]]]:
|
|
594
|
-
"""
|
|
595
|
-
Specifies the number of times the task corresponding
|
|
596
|
-
to a step needs to be retried.
|
|
597
|
-
|
|
598
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
|
599
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
600
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
|
601
|
-
|
|
602
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
603
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
|
604
|
-
ensuring that the flow execution can continue.
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
Parameters
|
|
608
|
-
----------
|
|
609
|
-
times : int, default 3
|
|
610
|
-
Number of times to retry this task.
|
|
611
|
-
minutes_between_retries : int, default 2
|
|
612
|
-
Number of minutes between retries.
|
|
613
|
-
"""
|
|
614
|
-
...
|
|
615
|
-
|
|
616
|
-
@typing.overload
|
|
617
|
-
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
618
|
-
...
|
|
619
|
-
|
|
620
|
-
@typing.overload
|
|
621
|
-
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
622
|
-
...
|
|
623
|
-
|
|
624
|
-
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):
|
|
625
|
-
"""
|
|
626
|
-
Specifies the number of times the task corresponding
|
|
627
|
-
to a step needs to be retried.
|
|
628
|
-
|
|
629
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
|
630
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
631
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
|
632
|
-
|
|
633
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
634
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
|
635
|
-
ensuring that the flow execution can continue.
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
Parameters
|
|
639
|
-
----------
|
|
640
|
-
times : int, default 3
|
|
641
|
-
Number of times to retry this task.
|
|
642
|
-
minutes_between_retries : int, default 2
|
|
643
|
-
Number of minutes between retries.
|
|
644
|
-
"""
|
|
645
|
-
...
|
|
646
|
-
|
|
647
525
|
@typing.overload
|
|
648
526
|
def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
649
527
|
"""
|
|
@@ -683,205 +561,136 @@ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
|
683
561
|
"""
|
|
684
562
|
...
|
|
685
563
|
|
|
686
|
-
|
|
687
|
-
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]]]:
|
|
564
|
+
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]]]:
|
|
688
565
|
"""
|
|
689
|
-
|
|
566
|
+
Decorator that helps cache, version, and store models/datasets from the Hugging Face Hub.
|
|
567
|
+
|
|
568
|
+
Examples
|
|
569
|
+
--------
|
|
690
570
|
|
|
691
|
-
> Examples
|
|
692
|
-
- Saving Models
|
|
693
571
|
```python
|
|
694
|
-
|
|
572
|
+
# **Usage: creating references to models from the Hugging Face Hub that may be loaded in downstream steps**
|
|
573
|
+
@huggingface_hub
|
|
695
574
|
@step
|
|
696
|
-
def
|
|
697
|
-
# current.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
575
|
+
def pull_model_from_huggingface(self):
|
|
576
|
+
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
|
577
|
+
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
|
578
|
+
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
|
579
|
+
# value of the function is a reference to the model in the backend storage.
|
|
580
|
+
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
|
581
|
+
|
|
582
|
+
self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
|
|
583
|
+
self.llama_model = current.huggingface_hub.snapshot_download(
|
|
584
|
+
repo_id=self.model_id,
|
|
585
|
+
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
|
706
586
|
)
|
|
707
|
-
self.next(self.
|
|
587
|
+
self.next(self.train)
|
|
708
588
|
|
|
709
|
-
|
|
589
|
+
# **Usage: explicitly loading models at runtime from the Hugging Face Hub or from cache (from Metaflow's datastore)**
|
|
590
|
+
@huggingface_hub
|
|
710
591
|
@step
|
|
711
|
-
def
|
|
712
|
-
#
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
@step
|
|
721
|
-
def train(self):
|
|
722
|
-
# current.model.load returns the path to the model loaded
|
|
723
|
-
checkpoint_path = current.model.load(
|
|
724
|
-
self.checkpoint_key,
|
|
725
|
-
)
|
|
726
|
-
model_path = current.model.load(
|
|
727
|
-
self.model,
|
|
728
|
-
)
|
|
729
|
-
self.next(self.test)
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
Parameters
|
|
734
|
-
----------
|
|
735
|
-
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
736
|
-
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
737
|
-
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`.
|
|
738
|
-
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
|
|
739
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
740
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
592
|
+
def run_training(self):
|
|
593
|
+
# Temporary directory (auto-cleaned on exit)
|
|
594
|
+
with current.huggingface_hub.load(
|
|
595
|
+
repo_id="google-bert/bert-base-uncased",
|
|
596
|
+
allow_patterns=["*.bin"],
|
|
597
|
+
) as local_path:
|
|
598
|
+
# Use files under local_path
|
|
599
|
+
train_model(local_path)
|
|
600
|
+
...
|
|
741
601
|
|
|
742
|
-
|
|
743
|
-
The root directory under which `current.model.loaded` will store loaded models
|
|
744
|
-
"""
|
|
745
|
-
...
|
|
746
|
-
|
|
747
|
-
@typing.overload
|
|
748
|
-
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
749
|
-
...
|
|
750
|
-
|
|
751
|
-
@typing.overload
|
|
752
|
-
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
753
|
-
...
|
|
754
|
-
|
|
755
|
-
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):
|
|
756
|
-
"""
|
|
757
|
-
Enables loading / saving of models within a step.
|
|
602
|
+
# **Usage: loading models directly from the Hugging Face Hub or from cache (from Metaflow's datastore)**
|
|
758
603
|
|
|
759
|
-
|
|
760
|
-
- Saving Models
|
|
761
|
-
```python
|
|
762
|
-
@model
|
|
604
|
+
@huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
|
|
763
605
|
@step
|
|
764
|
-
def
|
|
765
|
-
|
|
766
|
-
self.my_model = current.model.save(
|
|
767
|
-
path_to_my_model,
|
|
768
|
-
label="my_model",
|
|
769
|
-
metadata={
|
|
770
|
-
"epochs": 10,
|
|
771
|
-
"batch-size": 32,
|
|
772
|
-
"learning-rate": 0.001,
|
|
773
|
-
}
|
|
774
|
-
)
|
|
775
|
-
self.next(self.test)
|
|
606
|
+
def pull_model_from_huggingface(self):
|
|
607
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
776
608
|
|
|
777
|
-
@
|
|
609
|
+
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora", "/my-lora-directory")])
|
|
778
610
|
@step
|
|
779
|
-
def
|
|
780
|
-
|
|
781
|
-
#
|
|
782
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
|
783
|
-
self.next(self.end)
|
|
784
|
-
```
|
|
611
|
+
def finetune_model(self):
|
|
612
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
613
|
+
# path_to_model will be /my-directory
|
|
785
614
|
|
|
786
|
-
|
|
787
|
-
|
|
615
|
+
|
|
616
|
+
# Takes all the arguments passed to `snapshot_download`
|
|
617
|
+
# except for `local_dir`
|
|
618
|
+
@huggingface_hub(load=[
|
|
619
|
+
{
|
|
620
|
+
"repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"repo_id": "myorg/mistral-lora",
|
|
624
|
+
"repo_type": "model",
|
|
625
|
+
},
|
|
626
|
+
])
|
|
788
627
|
@step
|
|
789
|
-
def
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
self.checkpoint_key,
|
|
793
|
-
)
|
|
794
|
-
model_path = current.model.load(
|
|
795
|
-
self.model,
|
|
796
|
-
)
|
|
797
|
-
self.next(self.test)
|
|
628
|
+
def finetune_model(self):
|
|
629
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
630
|
+
# path_to_model will be /my-directory
|
|
798
631
|
```
|
|
799
632
|
|
|
800
633
|
|
|
801
634
|
Parameters
|
|
802
635
|
----------
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
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`.
|
|
806
|
-
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
|
|
807
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
808
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
636
|
+
temp_dir_root : str, optional
|
|
637
|
+
The root directory that will hold the temporary directory where objects will be downloaded.
|
|
809
638
|
|
|
810
|
-
|
|
811
|
-
The
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
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]]]:
|
|
816
|
-
"""
|
|
817
|
-
Specifies that this step should execute on DGX cloud.
|
|
639
|
+
cache_scope : str, optional
|
|
640
|
+
The scope of the cache. Can be `checkpoint` / `flow` / `global`.
|
|
641
|
+
- `checkpoint` (default): All repos are stored like objects saved by `@checkpoint`.
|
|
642
|
+
i.e., the cached path is derived from the namespace, flow, step, and Metaflow foreach iteration.
|
|
643
|
+
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).
|
|
818
644
|
|
|
645
|
+
- `flow`: All repos are cached under the flow, regardless of namespace.
|
|
646
|
+
i.e., the cached path is derived solely from the flow name.
|
|
647
|
+
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.
|
|
819
648
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
649
|
+
- `global`: All repos are cached under a globally static path.
|
|
650
|
+
i.e., the base path of the cache is static and all repos are stored under it.
|
|
651
|
+
When to use this mode:
|
|
652
|
+
- All repos from the Hugging Face Hub need to be shared by users across all flow executions.
|
|
653
|
+
- Each caching scope comes with its own trade-offs:
|
|
654
|
+
- `checkpoint`:
|
|
655
|
+
- 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.
|
|
656
|
+
- 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.
|
|
657
|
+
- `flow`:
|
|
658
|
+
- 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.
|
|
659
|
+
- The blast radius of a bad checkpoint is limited to all runs of a particular flow.
|
|
660
|
+
- It doesn't promote cache reuse across flows.
|
|
661
|
+
- `global`:
|
|
662
|
+
- Has no control over when caches are populated (can be written by any flow execution) but has the highest cache hit rate.
|
|
663
|
+
- It promotes cache reuse across flows.
|
|
664
|
+
- The blast radius of a bad checkpoint spans every flow that could be using a particular repo.
|
|
833
665
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
you can use `@conda_base` to set packages required by all
|
|
837
|
-
steps and use `@conda` to specify step-specific overrides.
|
|
666
|
+
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
|
667
|
+
The list of repos (models/datasets) to load.
|
|
838
668
|
|
|
669
|
+
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
|
839
670
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
python : str, optional, default None
|
|
848
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
849
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
850
|
-
disabled : bool, default False
|
|
851
|
-
If set to True, disables @conda.
|
|
671
|
+
- If repo (model/dataset) is not found in the datastore:
|
|
672
|
+
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
|
673
|
+
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
|
674
|
+
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
|
675
|
+
|
|
676
|
+
- If repo is found in the datastore:
|
|
677
|
+
- Loads it directly from datastore to local path (can be temporary directory or specified path)
|
|
852
678
|
"""
|
|
853
679
|
...
|
|
854
680
|
|
|
855
|
-
|
|
856
|
-
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
857
|
-
...
|
|
858
|
-
|
|
859
|
-
@typing.overload
|
|
860
|
-
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
861
|
-
...
|
|
862
|
-
|
|
863
|
-
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
|
681
|
+
def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
864
682
|
"""
|
|
865
|
-
Specifies
|
|
866
|
-
|
|
867
|
-
Information in this decorator will augment any
|
|
868
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
|
869
|
-
you can use `@conda_base` to set packages required by all
|
|
870
|
-
steps and use `@conda` to specify step-specific overrides.
|
|
683
|
+
Specifies that this step should execute on DGX cloud.
|
|
871
684
|
|
|
872
685
|
|
|
873
686
|
Parameters
|
|
874
687
|
----------
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
882
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
883
|
-
disabled : bool, default False
|
|
884
|
-
If set to True, disables @conda.
|
|
688
|
+
gpu : int
|
|
689
|
+
Number of GPUs to use.
|
|
690
|
+
gpu_type : str
|
|
691
|
+
Type of Nvidia GPU to use.
|
|
692
|
+
queue_timeout : int
|
|
693
|
+
Time to keep the job in NVCF's queue.
|
|
885
694
|
"""
|
|
886
695
|
...
|
|
887
696
|
|
|
@@ -1033,96 +842,149 @@ def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None
|
|
|
1033
842
|
...
|
|
1034
843
|
|
|
1035
844
|
@typing.overload
|
|
1036
|
-
def
|
|
845
|
+
def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1037
846
|
"""
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
The decorator will create an optional artifact, specified by `var`, which
|
|
1041
|
-
contains the exception raised. You can use it to detect the presence
|
|
1042
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
|
1043
|
-
are missing.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
Parameters
|
|
1047
|
-
----------
|
|
1048
|
-
var : str, optional, default None
|
|
1049
|
-
Name of the artifact in which to store the caught exception.
|
|
1050
|
-
If not specified, the exception is not stored.
|
|
1051
|
-
print_exception : bool, default True
|
|
1052
|
-
Determines whether or not the exception is printed to
|
|
1053
|
-
stdout when caught.
|
|
847
|
+
A simple decorator that demonstrates using CardDecoratorInjector
|
|
848
|
+
to inject a card and render simple markdown content.
|
|
1054
849
|
"""
|
|
1055
850
|
...
|
|
1056
851
|
|
|
1057
852
|
@typing.overload
|
|
1058
|
-
def
|
|
853
|
+
def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1059
854
|
...
|
|
1060
855
|
|
|
1061
|
-
|
|
1062
|
-
|
|
856
|
+
def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
857
|
+
"""
|
|
858
|
+
A simple decorator that demonstrates using CardDecoratorInjector
|
|
859
|
+
to inject a card and render simple markdown content.
|
|
860
|
+
"""
|
|
1063
861
|
...
|
|
1064
862
|
|
|
1065
|
-
def
|
|
863
|
+
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]]]:
|
|
1066
864
|
"""
|
|
1067
|
-
|
|
865
|
+
`@coreweave_s3_proxy` is a CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
|
|
866
|
+
It exists to make it easier for users to know that this decorator should only be used with
|
|
867
|
+
a Neo Cloud like CoreWeave. The underlying mechanics of the decorator is the same as the `@s3_proxy`:
|
|
1068
868
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
869
|
+
|
|
870
|
+
Set up an S3 proxy that caches objects in an external, S3‑compatible bucket
|
|
871
|
+
for S3 read and write requests.
|
|
872
|
+
|
|
873
|
+
This decorator requires an integration in the Outerbounds platform that
|
|
874
|
+
points to an external bucket. It affects S3 operations performed via
|
|
875
|
+
Metaflow's `get_aws_client` and `S3` within a `@step`.
|
|
876
|
+
|
|
877
|
+
Read operations
|
|
878
|
+
---------------
|
|
879
|
+
All read operations pass through the proxy. If an object does not already
|
|
880
|
+
exist in the external bucket, it is cached there. For example, if code reads
|
|
881
|
+
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
882
|
+
buckets are cached in the external bucket.
|
|
883
|
+
|
|
884
|
+
During task execution, all S3‑related read requests are routed through the
|
|
885
|
+
proxy:
|
|
886
|
+
- If the object is present in the external object store, the proxy
|
|
887
|
+
streams it directly from there without accessing the requested origin
|
|
888
|
+
bucket.
|
|
889
|
+
- If the object is not present in the external storage, the proxy
|
|
890
|
+
fetches it from the requested bucket, caches it in the external
|
|
891
|
+
storage, and streams the response from the origin bucket.
|
|
892
|
+
|
|
893
|
+
Warning
|
|
894
|
+
-------
|
|
895
|
+
All READ operations (e.g., GetObject, HeadObject) pass through the external
|
|
896
|
+
bucket regardless of the bucket specified in user code. Even
|
|
897
|
+
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
898
|
+
external bucket cache.
|
|
899
|
+
|
|
900
|
+
Write operations
|
|
901
|
+
----------------
|
|
902
|
+
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
903
|
+
whether writes also persist objects in the cache.
|
|
904
|
+
|
|
905
|
+
`write_mode` values:
|
|
906
|
+
- `origin-and-cache`: objects are written both to the cache and to their
|
|
907
|
+
intended origin bucket.
|
|
908
|
+
- `origin`: objects are written only to their intended origin bucket.
|
|
1073
909
|
|
|
1074
910
|
|
|
1075
911
|
Parameters
|
|
1076
912
|
----------
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
913
|
+
integration_name : str, optional
|
|
914
|
+
[Outerbounds integration name](https://docs.outerbounds.com/outerbounds/configuring-secrets/#integrations-view)
|
|
915
|
+
that holds the configuration for the external, S3‑compatible object
|
|
916
|
+
storage bucket. If not specified, the only available S3 proxy
|
|
917
|
+
integration in the namespace is used (fails if multiple exist).
|
|
918
|
+
write_mode : str, optional
|
|
919
|
+
Controls whether writes also go to the external bucket.
|
|
920
|
+
- `origin` (default)
|
|
921
|
+
- `origin-and-cache`
|
|
922
|
+
debug : bool, optional
|
|
923
|
+
Enables debug logging for proxy operations.
|
|
1083
924
|
"""
|
|
1084
925
|
...
|
|
1085
926
|
|
|
1086
|
-
def
|
|
927
|
+
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]]]:
|
|
1087
928
|
"""
|
|
1088
|
-
|
|
929
|
+
Specifies that this step should execute on DGX cloud.
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
Parameters
|
|
933
|
+
----------
|
|
934
|
+
gpu : int
|
|
935
|
+
Number of GPUs to use.
|
|
936
|
+
gpu_type : str
|
|
937
|
+
Type of Nvidia GPU to use.
|
|
938
|
+
"""
|
|
939
|
+
...
|
|
940
|
+
|
|
941
|
+
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]]]:
|
|
942
|
+
"""
|
|
943
|
+
This decorator is used to run vllm APIs as Metaflow task sidecars.
|
|
1089
944
|
|
|
1090
945
|
User code call
|
|
1091
946
|
--------------
|
|
1092
|
-
@
|
|
1093
|
-
|
|
947
|
+
@vllm(
|
|
948
|
+
model="...",
|
|
1094
949
|
...
|
|
1095
950
|
)
|
|
1096
951
|
|
|
1097
952
|
Valid backend options
|
|
1098
953
|
---------------------
|
|
1099
954
|
- 'local': Run as a separate process on the local task machine.
|
|
1100
|
-
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
|
1101
|
-
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
|
1102
955
|
|
|
1103
956
|
Valid model options
|
|
1104
957
|
-------------------
|
|
1105
|
-
Any model
|
|
958
|
+
Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
|
|
959
|
+
|
|
960
|
+
NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
|
|
961
|
+
If you need multiple models, you must create multiple @vllm decorators.
|
|
1106
962
|
|
|
1107
963
|
|
|
1108
964
|
Parameters
|
|
1109
965
|
----------
|
|
1110
|
-
|
|
1111
|
-
|
|
966
|
+
model: str
|
|
967
|
+
HuggingFace model identifier to be served by vLLM.
|
|
1112
968
|
backend: str
|
|
1113
|
-
Determines where and how to run the
|
|
1114
|
-
|
|
1115
|
-
Whether to
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
force_cache_update: bool
|
|
1119
|
-
Simple override for "force" cache update policy.
|
|
969
|
+
Determines where and how to run the vLLM process.
|
|
970
|
+
openai_api_server: bool
|
|
971
|
+
Whether to use OpenAI-compatible API server mode (subprocess) instead of native engine.
|
|
972
|
+
Default is False (uses native engine).
|
|
973
|
+
Set to True for backward compatibility with existing code.
|
|
1120
974
|
debug: bool
|
|
1121
975
|
Whether to turn on verbose debugging logs.
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
976
|
+
card_refresh_interval: int
|
|
977
|
+
Interval in seconds for refreshing the vLLM status card.
|
|
978
|
+
Only used when openai_api_server=True.
|
|
979
|
+
max_retries: int
|
|
980
|
+
Maximum number of retries checking for vLLM server startup.
|
|
981
|
+
Only used when openai_api_server=True.
|
|
982
|
+
retry_alert_frequency: int
|
|
983
|
+
Frequency of alert logs for vLLM server startup retries.
|
|
984
|
+
Only used when openai_api_server=True.
|
|
985
|
+
engine_args : dict
|
|
986
|
+
Additional keyword arguments to pass to the vLLM engine.
|
|
987
|
+
For example, `tensor_parallel_size=2`.
|
|
1126
988
|
"""
|
|
1127
989
|
...
|
|
1128
990
|
|
|
@@ -1146,53 +1008,131 @@ def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None
|
|
|
1146
1008
|
...
|
|
1147
1009
|
|
|
1148
1010
|
@typing.overload
|
|
1149
|
-
def
|
|
1011
|
+
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]]]:
|
|
1150
1012
|
"""
|
|
1151
|
-
|
|
1013
|
+
Enables loading / saving of models within a step.
|
|
1152
1014
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1015
|
+
> Examples
|
|
1016
|
+
- Saving Models
|
|
1017
|
+
```python
|
|
1018
|
+
@model
|
|
1019
|
+
@step
|
|
1020
|
+
def train(self):
|
|
1021
|
+
# current.model.save returns a dictionary reference to the model saved
|
|
1022
|
+
self.my_model = current.model.save(
|
|
1023
|
+
path_to_my_model,
|
|
1024
|
+
label="my_model",
|
|
1025
|
+
metadata={
|
|
1026
|
+
"epochs": 10,
|
|
1027
|
+
"batch-size": 32,
|
|
1028
|
+
"learning-rate": 0.001,
|
|
1029
|
+
}
|
|
1030
|
+
)
|
|
1031
|
+
self.next(self.test)
|
|
1032
|
+
|
|
1033
|
+
@model(load="my_model")
|
|
1034
|
+
@step
|
|
1035
|
+
def test(self):
|
|
1036
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
|
1037
|
+
# where the key is the name of the artifact and the value is the path to the model
|
|
1038
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
|
1039
|
+
self.next(self.end)
|
|
1040
|
+
```
|
|
1041
|
+
|
|
1042
|
+
- Loading models
|
|
1043
|
+
```python
|
|
1044
|
+
@step
|
|
1045
|
+
def train(self):
|
|
1046
|
+
# current.model.load returns the path to the model loaded
|
|
1047
|
+
checkpoint_path = current.model.load(
|
|
1048
|
+
self.checkpoint_key,
|
|
1049
|
+
)
|
|
1050
|
+
model_path = current.model.load(
|
|
1051
|
+
self.model,
|
|
1052
|
+
)
|
|
1053
|
+
self.next(self.test)
|
|
1054
|
+
```
|
|
1157
1055
|
|
|
1158
1056
|
|
|
1159
1057
|
Parameters
|
|
1160
1058
|
----------
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1059
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
1060
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
1061
|
+
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`.
|
|
1062
|
+
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
|
|
1063
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
1064
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
1065
|
+
|
|
1066
|
+
temp_dir_root : str, default: None
|
|
1067
|
+
The root directory under which `current.model.loaded` will store loaded models
|
|
1167
1068
|
"""
|
|
1168
1069
|
...
|
|
1169
1070
|
|
|
1170
1071
|
@typing.overload
|
|
1171
|
-
def
|
|
1072
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1172
1073
|
...
|
|
1173
1074
|
|
|
1174
1075
|
@typing.overload
|
|
1175
|
-
def
|
|
1076
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1176
1077
|
...
|
|
1177
1078
|
|
|
1178
|
-
def
|
|
1079
|
+
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):
|
|
1179
1080
|
"""
|
|
1180
|
-
|
|
1081
|
+
Enables loading / saving of models within a step.
|
|
1181
1082
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1083
|
+
> Examples
|
|
1084
|
+
- Saving Models
|
|
1085
|
+
```python
|
|
1086
|
+
@model
|
|
1087
|
+
@step
|
|
1088
|
+
def train(self):
|
|
1089
|
+
# current.model.save returns a dictionary reference to the model saved
|
|
1090
|
+
self.my_model = current.model.save(
|
|
1091
|
+
path_to_my_model,
|
|
1092
|
+
label="my_model",
|
|
1093
|
+
metadata={
|
|
1094
|
+
"epochs": 10,
|
|
1095
|
+
"batch-size": 32,
|
|
1096
|
+
"learning-rate": 0.001,
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
1099
|
+
self.next(self.test)
|
|
1100
|
+
|
|
1101
|
+
@model(load="my_model")
|
|
1102
|
+
@step
|
|
1103
|
+
def test(self):
|
|
1104
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
|
1105
|
+
# where the key is the name of the artifact and the value is the path to the model
|
|
1106
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
|
1107
|
+
self.next(self.end)
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
- Loading models
|
|
1111
|
+
```python
|
|
1112
|
+
@step
|
|
1113
|
+
def train(self):
|
|
1114
|
+
# current.model.load returns the path to the model loaded
|
|
1115
|
+
checkpoint_path = current.model.load(
|
|
1116
|
+
self.checkpoint_key,
|
|
1117
|
+
)
|
|
1118
|
+
model_path = current.model.load(
|
|
1119
|
+
self.model,
|
|
1120
|
+
)
|
|
1121
|
+
self.next(self.test)
|
|
1122
|
+
```
|
|
1186
1123
|
|
|
1187
1124
|
|
|
1188
1125
|
Parameters
|
|
1189
1126
|
----------
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1127
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
|
1128
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
|
1129
|
+
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`.
|
|
1130
|
+
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
|
|
1131
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
|
1132
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
|
1133
|
+
|
|
1134
|
+
temp_dir_root : str, default: None
|
|
1135
|
+
The root directory under which `current.model.loaded` will store loaded models
|
|
1196
1136
|
"""
|
|
1197
1137
|
...
|
|
1198
1138
|
|
|
@@ -1286,227 +1226,401 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
|
|
|
1286
1226
|
...
|
|
1287
1227
|
|
|
1288
1228
|
@typing.overload
|
|
1289
|
-
def
|
|
1229
|
+
def timeout(*, seconds: int = 0, minutes: int = 0, hours: int = 0) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
|
1290
1230
|
"""
|
|
1291
|
-
|
|
1231
|
+
Specifies a timeout for your step.
|
|
1292
1232
|
|
|
1293
|
-
|
|
1233
|
+
This decorator is useful if this step may hang indefinitely.
|
|
1294
1234
|
|
|
1235
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
|
1236
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
|
1237
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
1295
1238
|
|
|
1296
|
-
|
|
1239
|
+
Note that all the values specified in parameters are added together so if you specify
|
|
1240
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
Parameters
|
|
1297
1244
|
----------
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
timeout : int, default 45
|
|
1305
|
-
Interrupt reporting if it takes more than this many seconds.
|
|
1245
|
+
seconds : int, default 0
|
|
1246
|
+
Number of seconds to wait prior to timing out.
|
|
1247
|
+
minutes : int, default 0
|
|
1248
|
+
Number of minutes to wait prior to timing out.
|
|
1249
|
+
hours : int, default 0
|
|
1250
|
+
Number of hours to wait prior to timing out.
|
|
1306
1251
|
"""
|
|
1307
1252
|
...
|
|
1308
1253
|
|
|
1309
1254
|
@typing.overload
|
|
1310
|
-
def
|
|
1255
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1311
1256
|
...
|
|
1312
1257
|
|
|
1313
1258
|
@typing.overload
|
|
1314
|
-
def
|
|
1259
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1315
1260
|
...
|
|
1316
1261
|
|
|
1317
|
-
def
|
|
1262
|
+
def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, seconds: int = 0, minutes: int = 0, hours: int = 0):
|
|
1318
1263
|
"""
|
|
1319
|
-
|
|
1264
|
+
Specifies a timeout for your step.
|
|
1320
1265
|
|
|
1321
|
-
|
|
1266
|
+
This decorator is useful if this step may hang indefinitely.
|
|
1267
|
+
|
|
1268
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
|
1269
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
|
1270
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
|
1271
|
+
|
|
1272
|
+
Note that all the values specified in parameters are added together so if you specify
|
|
1273
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
|
1322
1274
|
|
|
1323
1275
|
|
|
1324
1276
|
Parameters
|
|
1325
1277
|
----------
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
timeout : int, default 45
|
|
1333
|
-
Interrupt reporting if it takes more than this many seconds.
|
|
1278
|
+
seconds : int, default 0
|
|
1279
|
+
Number of seconds to wait prior to timing out.
|
|
1280
|
+
minutes : int, default 0
|
|
1281
|
+
Number of minutes to wait prior to timing out.
|
|
1282
|
+
hours : int, default 0
|
|
1283
|
+
Number of hours to wait prior to timing out.
|
|
1334
1284
|
"""
|
|
1335
1285
|
...
|
|
1336
1286
|
|
|
1337
|
-
|
|
1287
|
+
@typing.overload
|
|
1288
|
+
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]]]:
|
|
1338
1289
|
"""
|
|
1339
|
-
|
|
1340
|
-
for S3 read and write requests.
|
|
1290
|
+
Specifies that the step will success under all circumstances.
|
|
1341
1291
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1292
|
+
The decorator will create an optional artifact, specified by `var`, which
|
|
1293
|
+
contains the exception raised. You can use it to detect the presence
|
|
1294
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
|
1295
|
+
are missing.
|
|
1345
1296
|
|
|
1346
|
-
Read operations
|
|
1347
|
-
---------------
|
|
1348
|
-
All read operations pass through the proxy. If an object does not already
|
|
1349
|
-
exist in the external bucket, it is cached there. For example, if code reads
|
|
1350
|
-
from buckets `FOO` and `BAR` using the `S3` interface, objects from both
|
|
1351
|
-
buckets are cached in the external bucket.
|
|
1352
1297
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1298
|
+
Parameters
|
|
1299
|
+
----------
|
|
1300
|
+
var : str, optional, default None
|
|
1301
|
+
Name of the artifact in which to store the caught exception.
|
|
1302
|
+
If not specified, the exception is not stored.
|
|
1303
|
+
print_exception : bool, default True
|
|
1304
|
+
Determines whether or not the exception is printed to
|
|
1305
|
+
stdout when caught.
|
|
1306
|
+
"""
|
|
1307
|
+
...
|
|
1308
|
+
|
|
1309
|
+
@typing.overload
|
|
1310
|
+
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1311
|
+
...
|
|
1312
|
+
|
|
1313
|
+
@typing.overload
|
|
1314
|
+
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1315
|
+
...
|
|
1316
|
+
|
|
1317
|
+
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):
|
|
1318
|
+
"""
|
|
1319
|
+
Specifies that the step will success under all circumstances.
|
|
1361
1320
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
`S3(run=self)` and `S3(s3root="mybucketfoo")` requests go through the
|
|
1367
|
-
external bucket cache.
|
|
1321
|
+
The decorator will create an optional artifact, specified by `var`, which
|
|
1322
|
+
contains the exception raised. You can use it to detect the presence
|
|
1323
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
|
1324
|
+
are missing.
|
|
1368
1325
|
|
|
1369
|
-
Write operations
|
|
1370
|
-
----------------
|
|
1371
|
-
Write behavior is controlled by the `write_mode` parameter, which determines
|
|
1372
|
-
whether writes also persist objects in the cache.
|
|
1373
1326
|
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1327
|
+
Parameters
|
|
1328
|
+
----------
|
|
1329
|
+
var : str, optional, default None
|
|
1330
|
+
Name of the artifact in which to store the caught exception.
|
|
1331
|
+
If not specified, the exception is not stored.
|
|
1332
|
+
print_exception : bool, default True
|
|
1333
|
+
Determines whether or not the exception is printed to
|
|
1334
|
+
stdout when caught.
|
|
1335
|
+
"""
|
|
1336
|
+
...
|
|
1337
|
+
|
|
1338
|
+
@typing.overload
|
|
1339
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1340
|
+
"""
|
|
1341
|
+
Internal decorator to support Fast bakery
|
|
1342
|
+
"""
|
|
1343
|
+
...
|
|
1344
|
+
|
|
1345
|
+
@typing.overload
|
|
1346
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1347
|
+
...
|
|
1348
|
+
|
|
1349
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
1350
|
+
"""
|
|
1351
|
+
Internal decorator to support Fast bakery
|
|
1352
|
+
"""
|
|
1353
|
+
...
|
|
1354
|
+
|
|
1355
|
+
@typing.overload
|
|
1356
|
+
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]]]:
|
|
1357
|
+
"""
|
|
1358
|
+
Specifies environment variables to be set prior to the execution of a step.
|
|
1378
1359
|
|
|
1379
1360
|
|
|
1380
1361
|
Parameters
|
|
1381
1362
|
----------
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
that holds the configuration for the external, S3‑compatible object
|
|
1385
|
-
storage bucket. If not specified, the only available S3 proxy
|
|
1386
|
-
integration in the namespace is used (fails if multiple exist).
|
|
1387
|
-
write_mode : str, optional
|
|
1388
|
-
Controls whether writes also go to the external bucket.
|
|
1389
|
-
- `origin` (default)
|
|
1390
|
-
- `origin-and-cache`
|
|
1391
|
-
debug : bool, optional
|
|
1392
|
-
Enables debug logging for proxy operations.
|
|
1363
|
+
vars : Dict[str, str], default {}
|
|
1364
|
+
Dictionary of environment variables to set.
|
|
1393
1365
|
"""
|
|
1394
1366
|
...
|
|
1395
1367
|
|
|
1396
|
-
|
|
1368
|
+
@typing.overload
|
|
1369
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1370
|
+
...
|
|
1371
|
+
|
|
1372
|
+
@typing.overload
|
|
1373
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1374
|
+
...
|
|
1375
|
+
|
|
1376
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
|
1397
1377
|
"""
|
|
1398
|
-
|
|
1378
|
+
Specifies environment variables to be set prior to the execution of a step.
|
|
1399
1379
|
|
|
1400
|
-
Examples
|
|
1401
|
-
--------
|
|
1402
1380
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1381
|
+
Parameters
|
|
1382
|
+
----------
|
|
1383
|
+
vars : Dict[str, str], default {}
|
|
1384
|
+
Dictionary of environment variables to set.
|
|
1385
|
+
"""
|
|
1386
|
+
...
|
|
1387
|
+
|
|
1388
|
+
@typing.overload
|
|
1389
|
+
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]]]:
|
|
1390
|
+
"""
|
|
1391
|
+
Specifies the PyPI packages for the step.
|
|
1413
1392
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
)
|
|
1419
|
-
self.next(self.train)
|
|
1393
|
+
Information in this decorator will augment any
|
|
1394
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
1395
|
+
you can use `@pypi_base` to set packages required by all
|
|
1396
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1420
1397
|
|
|
1421
|
-
# **Usage: explicitly loading models at runtime from the Hugging Face Hub or from cache (from Metaflow's datastore)**
|
|
1422
|
-
@huggingface_hub
|
|
1423
|
-
@step
|
|
1424
|
-
def run_training(self):
|
|
1425
|
-
# Temporary directory (auto-cleaned on exit)
|
|
1426
|
-
with current.huggingface_hub.load(
|
|
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
|
-
...
|
|
1433
1398
|
|
|
1434
|
-
|
|
1399
|
+
Parameters
|
|
1400
|
+
----------
|
|
1401
|
+
packages : Dict[str, str], default: {}
|
|
1402
|
+
Packages to use for this step. The key is the name of the package
|
|
1403
|
+
and the value is the version to use.
|
|
1404
|
+
python : str, optional, default: None
|
|
1405
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1406
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1407
|
+
"""
|
|
1408
|
+
...
|
|
1409
|
+
|
|
1410
|
+
@typing.overload
|
|
1411
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1412
|
+
...
|
|
1413
|
+
|
|
1414
|
+
@typing.overload
|
|
1415
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1416
|
+
...
|
|
1417
|
+
|
|
1418
|
+
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):
|
|
1419
|
+
"""
|
|
1420
|
+
Specifies the PyPI packages for the step.
|
|
1435
1421
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1422
|
+
Information in this decorator will augment any
|
|
1423
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
|
1424
|
+
you can use `@pypi_base` to set packages required by all
|
|
1425
|
+
steps and use `@pypi` to specify step-specific overrides.
|
|
1440
1426
|
|
|
1441
|
-
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora", "/my-lora-directory")])
|
|
1442
|
-
@step
|
|
1443
|
-
def finetune_model(self):
|
|
1444
|
-
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
|
1445
|
-
# path_to_model will be /my-directory
|
|
1446
1427
|
|
|
1428
|
+
Parameters
|
|
1429
|
+
----------
|
|
1430
|
+
packages : Dict[str, str], default: {}
|
|
1431
|
+
Packages to use for this step. The key is the name of the package
|
|
1432
|
+
and the value is the version to use.
|
|
1433
|
+
python : str, optional, default: None
|
|
1434
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1435
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1436
|
+
"""
|
|
1437
|
+
...
|
|
1438
|
+
|
|
1439
|
+
@typing.overload
|
|
1440
|
+
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]]]:
|
|
1441
|
+
"""
|
|
1442
|
+
Specifies the number of times the task corresponding
|
|
1443
|
+
to a step needs to be retried.
|
|
1447
1444
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1445
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
|
1446
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
1447
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
|
1448
|
+
|
|
1449
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
1450
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
|
1451
|
+
ensuring that the flow execution can continue.
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
Parameters
|
|
1455
|
+
----------
|
|
1456
|
+
times : int, default 3
|
|
1457
|
+
Number of times to retry this task.
|
|
1458
|
+
minutes_between_retries : int, default 2
|
|
1459
|
+
Number of minutes between retries.
|
|
1460
|
+
"""
|
|
1461
|
+
...
|
|
1462
|
+
|
|
1463
|
+
@typing.overload
|
|
1464
|
+
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1465
|
+
...
|
|
1466
|
+
|
|
1467
|
+
@typing.overload
|
|
1468
|
+
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1469
|
+
...
|
|
1470
|
+
|
|
1471
|
+
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):
|
|
1472
|
+
"""
|
|
1473
|
+
Specifies the number of times the task corresponding
|
|
1474
|
+
to a step needs to be retried.
|
|
1475
|
+
|
|
1476
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
|
1477
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
|
1478
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
|
1479
|
+
|
|
1480
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
|
1481
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
|
1482
|
+
ensuring that the flow execution can continue.
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
Parameters
|
|
1486
|
+
----------
|
|
1487
|
+
times : int, default 3
|
|
1488
|
+
Number of times to retry this task.
|
|
1489
|
+
minutes_between_retries : int, default 2
|
|
1490
|
+
Number of minutes between retries.
|
|
1491
|
+
"""
|
|
1492
|
+
...
|
|
1493
|
+
|
|
1494
|
+
@typing.overload
|
|
1495
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
|
1496
|
+
"""
|
|
1497
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
1498
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
1499
|
+
"""
|
|
1500
|
+
...
|
|
1501
|
+
|
|
1502
|
+
@typing.overload
|
|
1503
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
|
1504
|
+
...
|
|
1505
|
+
|
|
1506
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
|
1507
|
+
"""
|
|
1508
|
+
Decorator prototype for all step decorators. This function gets specialized
|
|
1509
|
+
and imported for all decorators types by _import_plugin_decorators().
|
|
1510
|
+
"""
|
|
1511
|
+
...
|
|
1512
|
+
|
|
1513
|
+
def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
|
|
1514
|
+
"""
|
|
1515
|
+
Allows setting external datastores to save data for the
|
|
1516
|
+
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
|
1517
|
+
|
|
1518
|
+
This decorator is useful when users wish to save data to a different datastore
|
|
1519
|
+
than what is configured in Metaflow. This can be for variety of reasons:
|
|
1520
|
+
|
|
1521
|
+
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
|
1522
|
+
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
|
1523
|
+
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
|
1524
|
+
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
|
1525
|
+
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
|
1526
|
+
|
|
1527
|
+
Usage:
|
|
1528
|
+
----------
|
|
1529
|
+
|
|
1530
|
+
- Using a custom IAM role to access the datastore.
|
|
1531
|
+
|
|
1532
|
+
```python
|
|
1533
|
+
@with_artifact_store(
|
|
1534
|
+
type="s3",
|
|
1535
|
+
config=lambda: {
|
|
1536
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
|
1537
|
+
"role_arn": ROLE,
|
|
1538
|
+
},
|
|
1539
|
+
)
|
|
1540
|
+
class MyFlow(FlowSpec):
|
|
1541
|
+
|
|
1542
|
+
@checkpoint
|
|
1543
|
+
@step
|
|
1544
|
+
def start(self):
|
|
1545
|
+
with open("my_file.txt", "w") as f:
|
|
1546
|
+
f.write("Hello, World!")
|
|
1547
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1548
|
+
self.next(self.end)
|
|
1549
|
+
|
|
1550
|
+
```
|
|
1464
1551
|
|
|
1552
|
+
- Using credentials to access the s3-compatible datastore.
|
|
1465
1553
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1554
|
+
```python
|
|
1555
|
+
@with_artifact_store(
|
|
1556
|
+
type="s3",
|
|
1557
|
+
config=lambda: {
|
|
1558
|
+
"root": "s3://my-bucket-foo/path/to/root",
|
|
1559
|
+
"client_params": {
|
|
1560
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1561
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1562
|
+
},
|
|
1563
|
+
},
|
|
1564
|
+
)
|
|
1565
|
+
class MyFlow(FlowSpec):
|
|
1470
1566
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1567
|
+
@checkpoint
|
|
1568
|
+
@step
|
|
1569
|
+
def start(self):
|
|
1570
|
+
with open("my_file.txt", "w") as f:
|
|
1571
|
+
f.write("Hello, World!")
|
|
1572
|
+
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1573
|
+
self.next(self.end)
|
|
1476
1574
|
|
|
1477
|
-
|
|
1478
|
-
i.e., the cached path is derived solely from the flow name.
|
|
1479
|
-
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.
|
|
1575
|
+
```
|
|
1480
1576
|
|
|
1481
|
-
|
|
1482
|
-
i.e., the base path of the cache is static and all repos are stored under it.
|
|
1483
|
-
When to use this mode:
|
|
1484
|
-
- All repos from the Hugging Face Hub need to be shared by users across all flow executions.
|
|
1485
|
-
- Each caching scope comes with its own trade-offs:
|
|
1486
|
-
- `checkpoint`:
|
|
1487
|
-
- 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.
|
|
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.
|
|
1577
|
+
- Accessing objects stored in external datastores after task execution.
|
|
1497
1578
|
|
|
1498
|
-
|
|
1499
|
-
|
|
1579
|
+
```python
|
|
1580
|
+
run = Run("CheckpointsTestsFlow/8992")
|
|
1581
|
+
with artifact_store_from(run=run, config={
|
|
1582
|
+
"client_params": {
|
|
1583
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1584
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1585
|
+
},
|
|
1586
|
+
}):
|
|
1587
|
+
with Checkpoint() as cp:
|
|
1588
|
+
latest = cp.list(
|
|
1589
|
+
task=run["start"].task
|
|
1590
|
+
)[0]
|
|
1591
|
+
print(latest)
|
|
1592
|
+
cp.load(
|
|
1593
|
+
latest,
|
|
1594
|
+
"test-checkpoints"
|
|
1595
|
+
)
|
|
1500
1596
|
|
|
1501
|
-
|
|
1597
|
+
task = Task("TorchTuneFlow/8484/train/53673")
|
|
1598
|
+
with artifact_store_from(run=run, config={
|
|
1599
|
+
"client_params": {
|
|
1600
|
+
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1601
|
+
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1602
|
+
},
|
|
1603
|
+
}):
|
|
1604
|
+
load_model(
|
|
1605
|
+
task.data.model_ref,
|
|
1606
|
+
"test-models"
|
|
1607
|
+
)
|
|
1608
|
+
```
|
|
1609
|
+
Parameters:
|
|
1610
|
+
----------
|
|
1502
1611
|
|
|
1503
|
-
|
|
1504
|
-
|
|
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.
|
|
1612
|
+
type: str
|
|
1613
|
+
The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
|
|
1507
1614
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1615
|
+
config: dict or Callable
|
|
1616
|
+
Dictionary of configuration options for the datastore. The following keys are required:
|
|
1617
|
+
- root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
|
|
1618
|
+
- example: 's3://bucket-name/path/to/root'
|
|
1619
|
+
- example: 'gs://bucket-name/path/to/root'
|
|
1620
|
+
- example: 'https://myblockacc.blob.core.windows.net/metaflow/'
|
|
1621
|
+
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
|
1622
|
+
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
|
1623
|
+
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
|
1510
1624
|
"""
|
|
1511
1625
|
...
|
|
1512
1626
|
|
|
@@ -1611,46 +1725,54 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
|
|
|
1611
1725
|
"""
|
|
1612
1726
|
...
|
|
1613
1727
|
|
|
1614
|
-
|
|
1728
|
+
@typing.overload
|
|
1729
|
+
def schedule(*, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
1615
1730
|
"""
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
|
1619
|
-
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
|
1620
|
-
starts only after all sensors finish.
|
|
1731
|
+
Specifies the times when the flow should be run when running on a
|
|
1732
|
+
production scheduler.
|
|
1621
1733
|
|
|
1622
1734
|
|
|
1623
1735
|
Parameters
|
|
1624
1736
|
----------
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1737
|
+
hourly : bool, default False
|
|
1738
|
+
Run the workflow hourly.
|
|
1739
|
+
daily : bool, default True
|
|
1740
|
+
Run the workflow daily.
|
|
1741
|
+
weekly : bool, default False
|
|
1742
|
+
Run the workflow weekly.
|
|
1743
|
+
cron : str, optional, default None
|
|
1744
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
1745
|
+
specified by this expression.
|
|
1746
|
+
timezone : str, optional, default None
|
|
1747
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
1748
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
1749
|
+
"""
|
|
1750
|
+
...
|
|
1751
|
+
|
|
1752
|
+
@typing.overload
|
|
1753
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1754
|
+
...
|
|
1755
|
+
|
|
1756
|
+
def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
|
|
1757
|
+
"""
|
|
1758
|
+
Specifies the times when the flow should be run when running on a
|
|
1759
|
+
production scheduler.
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
Parameters
|
|
1763
|
+
----------
|
|
1764
|
+
hourly : bool, default False
|
|
1765
|
+
Run the workflow hourly.
|
|
1766
|
+
daily : bool, default True
|
|
1767
|
+
Run the workflow daily.
|
|
1768
|
+
weekly : bool, default False
|
|
1769
|
+
Run the workflow weekly.
|
|
1770
|
+
cron : str, optional, default None
|
|
1771
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
1772
|
+
specified by this expression.
|
|
1773
|
+
timezone : str, optional, default None
|
|
1774
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
1775
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
1654
1776
|
"""
|
|
1655
1777
|
...
|
|
1656
1778
|
|
|
@@ -1689,54 +1811,46 @@ def project(*, name: str, branch: typing.Optional[str] = None, production: bool
|
|
|
1689
1811
|
"""
|
|
1690
1812
|
...
|
|
1691
1813
|
|
|
1692
|
-
|
|
1693
|
-
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]]:
|
|
1694
|
-
"""
|
|
1695
|
-
Specifies the Conda environment for all steps of the flow.
|
|
1696
|
-
|
|
1697
|
-
Use `@conda_base` to set common libraries required by all
|
|
1698
|
-
steps and use `@conda` to specify step-specific additions.
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
Parameters
|
|
1702
|
-
----------
|
|
1703
|
-
packages : Dict[str, str], default {}
|
|
1704
|
-
Packages to use for this flow. The key is the name of the package
|
|
1705
|
-
and the value is the version to use.
|
|
1706
|
-
libraries : Dict[str, str], default {}
|
|
1707
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
1708
|
-
python : str, optional, default None
|
|
1709
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1710
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1711
|
-
disabled : bool, default False
|
|
1712
|
-
If set to True, disables Conda.
|
|
1713
|
-
"""
|
|
1714
|
-
...
|
|
1715
|
-
|
|
1716
|
-
@typing.overload
|
|
1717
|
-
def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1718
|
-
...
|
|
1719
|
-
|
|
1720
|
-
def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
|
1814
|
+
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]]:
|
|
1721
1815
|
"""
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1816
|
+
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)
|
|
1817
|
+
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
|
1818
|
+
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
|
1819
|
+
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
|
1820
|
+
starts only after all sensors finish.
|
|
1726
1821
|
|
|
1727
1822
|
|
|
1728
1823
|
Parameters
|
|
1729
1824
|
----------
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1825
|
+
timeout : int
|
|
1826
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
|
1827
|
+
poke_interval : int
|
|
1828
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
|
1829
|
+
mode : str
|
|
1830
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
|
1831
|
+
exponential_backoff : bool
|
|
1832
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
|
1833
|
+
pool : str
|
|
1834
|
+
the slot pool this task should run in,
|
|
1835
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
1836
|
+
soft_fail : bool
|
|
1837
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
1838
|
+
name : str
|
|
1839
|
+
Name of the sensor on Airflow
|
|
1840
|
+
description : str
|
|
1841
|
+
Description of sensor in the Airflow UI
|
|
1842
|
+
bucket_key : Union[str, List[str]]
|
|
1843
|
+
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
|
1844
|
+
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
|
1845
|
+
bucket_name : str
|
|
1846
|
+
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
|
1847
|
+
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
|
1848
|
+
wildcard_match : bool
|
|
1849
|
+
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
|
1850
|
+
aws_conn_id : str
|
|
1851
|
+
a reference to the s3 connection on Airflow. (Default: None)
|
|
1852
|
+
verify : bool
|
|
1853
|
+
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
|
1740
1854
|
"""
|
|
1741
1855
|
...
|
|
1742
1856
|
|
|
@@ -1833,160 +1947,54 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
|
|
|
1833
1947
|
"""
|
|
1834
1948
|
...
|
|
1835
1949
|
|
|
1836
|
-
|
|
1950
|
+
@typing.overload
|
|
1951
|
+
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]]:
|
|
1837
1952
|
"""
|
|
1838
|
-
|
|
1839
|
-
|
|
1953
|
+
Specifies the Conda environment for all steps of the flow.
|
|
1954
|
+
|
|
1955
|
+
Use `@conda_base` to set common libraries required by all
|
|
1956
|
+
steps and use `@conda` to specify step-specific additions.
|
|
1840
1957
|
|
|
1841
1958
|
|
|
1842
1959
|
Parameters
|
|
1843
1960
|
----------
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
1855
|
-
soft_fail : bool
|
|
1856
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
1857
|
-
name : str
|
|
1858
|
-
Name of the sensor on Airflow
|
|
1859
|
-
description : str
|
|
1860
|
-
Description of sensor in the Airflow UI
|
|
1861
|
-
external_dag_id : str
|
|
1862
|
-
The dag_id that contains the task you want to wait for.
|
|
1863
|
-
external_task_ids : List[str]
|
|
1864
|
-
The list of task_ids that you want to wait for.
|
|
1865
|
-
If None (default value) the sensor waits for the DAG. (Default: None)
|
|
1866
|
-
allowed_states : List[str]
|
|
1867
|
-
Iterable of allowed states, (Default: ['success'])
|
|
1868
|
-
failed_states : List[str]
|
|
1869
|
-
Iterable of failed or dis-allowed states. (Default: None)
|
|
1870
|
-
execution_delta : datetime.timedelta
|
|
1871
|
-
time difference with the previous execution to look at,
|
|
1872
|
-
the default is the same logical date as the current task or DAG. (Default: None)
|
|
1873
|
-
check_existence: bool
|
|
1874
|
-
Set to True to check if the external task exists or check if
|
|
1875
|
-
the DAG to wait for exists. (Default: True)
|
|
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
|
+
libraries : Dict[str, str], default {}
|
|
1965
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
1966
|
+
python : str, optional, default None
|
|
1967
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1968
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1969
|
+
disabled : bool, default False
|
|
1970
|
+
If set to True, disables Conda.
|
|
1876
1971
|
"""
|
|
1877
1972
|
...
|
|
1878
1973
|
|
|
1879
|
-
|
|
1974
|
+
@typing.overload
|
|
1975
|
+
def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
1976
|
+
...
|
|
1977
|
+
|
|
1978
|
+
def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
|
1880
1979
|
"""
|
|
1881
|
-
|
|
1882
|
-
`@checkpoint`/`@model`/`@huggingface_hub` decorators.
|
|
1883
|
-
|
|
1884
|
-
This decorator is useful when users wish to save data to a different datastore
|
|
1885
|
-
than what is configured in Metaflow. This can be for variety of reasons:
|
|
1886
|
-
|
|
1887
|
-
1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
|
|
1888
|
-
2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
|
|
1889
|
-
- Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
|
|
1890
|
-
3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
|
|
1891
|
-
- Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
|
|
1892
|
-
|
|
1893
|
-
Usage:
|
|
1894
|
-
----------
|
|
1895
|
-
|
|
1896
|
-
- Using a custom IAM role to access the datastore.
|
|
1897
|
-
|
|
1898
|
-
```python
|
|
1899
|
-
@with_artifact_store(
|
|
1900
|
-
type="s3",
|
|
1901
|
-
config=lambda: {
|
|
1902
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
|
1903
|
-
"role_arn": ROLE,
|
|
1904
|
-
},
|
|
1905
|
-
)
|
|
1906
|
-
class MyFlow(FlowSpec):
|
|
1907
|
-
|
|
1908
|
-
@checkpoint
|
|
1909
|
-
@step
|
|
1910
|
-
def start(self):
|
|
1911
|
-
with open("my_file.txt", "w") as f:
|
|
1912
|
-
f.write("Hello, World!")
|
|
1913
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1914
|
-
self.next(self.end)
|
|
1915
|
-
|
|
1916
|
-
```
|
|
1917
|
-
|
|
1918
|
-
- Using credentials to access the s3-compatible datastore.
|
|
1919
|
-
|
|
1920
|
-
```python
|
|
1921
|
-
@with_artifact_store(
|
|
1922
|
-
type="s3",
|
|
1923
|
-
config=lambda: {
|
|
1924
|
-
"root": "s3://my-bucket-foo/path/to/root",
|
|
1925
|
-
"client_params": {
|
|
1926
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1927
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1928
|
-
},
|
|
1929
|
-
},
|
|
1930
|
-
)
|
|
1931
|
-
class MyFlow(FlowSpec):
|
|
1932
|
-
|
|
1933
|
-
@checkpoint
|
|
1934
|
-
@step
|
|
1935
|
-
def start(self):
|
|
1936
|
-
with open("my_file.txt", "w") as f:
|
|
1937
|
-
f.write("Hello, World!")
|
|
1938
|
-
self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
|
|
1939
|
-
self.next(self.end)
|
|
1940
|
-
|
|
1941
|
-
```
|
|
1980
|
+
Specifies the Conda environment for all steps of the flow.
|
|
1942
1981
|
|
|
1943
|
-
|
|
1982
|
+
Use `@conda_base` to set common libraries required by all
|
|
1983
|
+
steps and use `@conda` to specify step-specific additions.
|
|
1944
1984
|
|
|
1945
|
-
```python
|
|
1946
|
-
run = Run("CheckpointsTestsFlow/8992")
|
|
1947
|
-
with artifact_store_from(run=run, config={
|
|
1948
|
-
"client_params": {
|
|
1949
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1950
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1951
|
-
},
|
|
1952
|
-
}):
|
|
1953
|
-
with Checkpoint() as cp:
|
|
1954
|
-
latest = cp.list(
|
|
1955
|
-
task=run["start"].task
|
|
1956
|
-
)[0]
|
|
1957
|
-
print(latest)
|
|
1958
|
-
cp.load(
|
|
1959
|
-
latest,
|
|
1960
|
-
"test-checkpoints"
|
|
1961
|
-
)
|
|
1962
1985
|
|
|
1963
|
-
|
|
1964
|
-
with artifact_store_from(run=run, config={
|
|
1965
|
-
"client_params": {
|
|
1966
|
-
"aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
|
|
1967
|
-
"aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
|
|
1968
|
-
},
|
|
1969
|
-
}):
|
|
1970
|
-
load_model(
|
|
1971
|
-
task.data.model_ref,
|
|
1972
|
-
"test-models"
|
|
1973
|
-
)
|
|
1974
|
-
```
|
|
1975
|
-
Parameters:
|
|
1986
|
+
Parameters
|
|
1976
1987
|
----------
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
- role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
|
|
1988
|
-
- session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
|
|
1989
|
-
- client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
|
|
1988
|
+
packages : Dict[str, str], default {}
|
|
1989
|
+
Packages to use for this flow. The key is the name of the package
|
|
1990
|
+
and the value is the version to use.
|
|
1991
|
+
libraries : Dict[str, str], default {}
|
|
1992
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
|
1993
|
+
python : str, optional, default None
|
|
1994
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
|
1995
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
|
1996
|
+
disabled : bool, default False
|
|
1997
|
+
If set to True, disables Conda.
|
|
1990
1998
|
"""
|
|
1991
1999
|
...
|
|
1992
2000
|
|
|
@@ -2031,54 +2039,46 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
|
|
|
2031
2039
|
"""
|
|
2032
2040
|
...
|
|
2033
2041
|
|
|
2034
|
-
|
|
2035
|
-
def schedule(*, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
|
2036
|
-
"""
|
|
2037
|
-
Specifies the times when the flow should be run when running on a
|
|
2038
|
-
production scheduler.
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
Parameters
|
|
2042
|
-
----------
|
|
2043
|
-
hourly : bool, default False
|
|
2044
|
-
Run the workflow hourly.
|
|
2045
|
-
daily : bool, default True
|
|
2046
|
-
Run the workflow daily.
|
|
2047
|
-
weekly : bool, default False
|
|
2048
|
-
Run the workflow weekly.
|
|
2049
|
-
cron : str, optional, default None
|
|
2050
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
|
2051
|
-
specified by this expression.
|
|
2052
|
-
timezone : str, optional, default None
|
|
2053
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
|
2054
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
|
2055
|
-
"""
|
|
2056
|
-
...
|
|
2057
|
-
|
|
2058
|
-
@typing.overload
|
|
2059
|
-
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
|
2060
|
-
...
|
|
2061
|
-
|
|
2062
|
-
def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
|
|
2042
|
+
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]]:
|
|
2063
2043
|
"""
|
|
2064
|
-
|
|
2065
|
-
|
|
2044
|
+
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.
|
|
2045
|
+
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.
|
|
2066
2046
|
|
|
2067
2047
|
|
|
2068
2048
|
Parameters
|
|
2069
2049
|
----------
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2050
|
+
timeout : int
|
|
2051
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
|
2052
|
+
poke_interval : int
|
|
2053
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
|
2054
|
+
mode : str
|
|
2055
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
|
2056
|
+
exponential_backoff : bool
|
|
2057
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
|
2058
|
+
pool : str
|
|
2059
|
+
the slot pool this task should run in,
|
|
2060
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
|
2061
|
+
soft_fail : bool
|
|
2062
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
|
2063
|
+
name : str
|
|
2064
|
+
Name of the sensor on Airflow
|
|
2065
|
+
description : str
|
|
2066
|
+
Description of sensor in the Airflow UI
|
|
2067
|
+
external_dag_id : str
|
|
2068
|
+
The dag_id that contains the task you want to wait for.
|
|
2069
|
+
external_task_ids : List[str]
|
|
2070
|
+
The list of task_ids that you want to wait for.
|
|
2071
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
|
2072
|
+
allowed_states : List[str]
|
|
2073
|
+
Iterable of allowed states, (Default: ['success'])
|
|
2074
|
+
failed_states : List[str]
|
|
2075
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
|
2076
|
+
execution_delta : datetime.timedelta
|
|
2077
|
+
time difference with the previous execution to look at,
|
|
2078
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
|
2079
|
+
check_existence: bool
|
|
2080
|
+
Set to True to check if the external task exists or check if
|
|
2081
|
+
the DAG to wait for exists. (Default: True)
|
|
2082
2082
|
"""
|
|
2083
2083
|
...
|
|
2084
2084
|
|