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