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