ob-metaflow-stubs 6.0.4.5__py2.py3-none-any.whl → 6.0.4.6__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metaflow-stubs/__init__.pyi +860 -860
- 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 +3 -3
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +5 -5
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +3 -3
- metaflow-stubs/info_file.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 +2 -2
- metaflow-stubs/metadata_provider/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +2 -2
- metaflow-stubs/metaflow_current.pyi +52 -52
- metaflow-stubs/metaflow_git.pyi +2 -2
- metaflow-stubs/mf_extensions/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +3 -3
- 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 +3 -3
- 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 +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +4 -4
- 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 +4 -4
- 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 +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +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 +4 -4
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +3 -3
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +2 -2
- metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_state_machine.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/_vendor/spinner/spinners.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_cli.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/capsule.pyi +4 -4
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/click_importer.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/code_packager.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/cli_generator.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/config_utils.pyi +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 +3 -3
- 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 +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +3 -3
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +2 -2
- metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/ob_internal.pyi +2 -2
- metaflow-stubs/parameters.pyi +3 -3
- metaflow-stubs/plugins/__init__.pyi +12 -12
- metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
- metaflow-stubs/plugins/airflow/exception.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
- metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +2 -2
- metaflow-stubs/plugins/argo/exit_hooks.pyi +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 +4 -4
- 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 +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
- metaflow-stubs/plugins/azure/__init__.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
- metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +4 -4
- metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
- metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
- metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/cards/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_client.pyi +3 -3
- metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
- metaflow-stubs/plugins/cards/card_decorator.pyi +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 +3 -3
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +2 -2
- metaflow-stubs/plugins/cards/exception.pyi +2 -2
- metaflow-stubs/plugins/catch_decorator.pyi +3 -3
- metaflow-stubs/plugins/datatools/__init__.pyi +2 -2
- metaflow-stubs/plugins/datatools/local.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
- metaflow-stubs/plugins/debug_logger.pyi +2 -2
- metaflow-stubs/plugins/debug_monitor.pyi +2 -2
- metaflow-stubs/plugins/environment_decorator.pyi +2 -2
- metaflow-stubs/plugins/events_decorator.pyi +2 -2
- metaflow-stubs/plugins/exit_hook/__init__.pyi +2 -2
- metaflow-stubs/plugins/exit_hook/exit_hook_decorator.pyi +2 -2
- metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
- metaflow-stubs/plugins/frameworks/pytorch.pyi +2 -2
- metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +4 -4
- metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
- metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
- metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +2 -2
- metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
- metaflow-stubs/plugins/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 +2 -2
- 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 +3 -3
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +4 -4
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_func.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_spec.pyi +2 -2
- metaflow-stubs/plugins/secrets/utils.pyi +2 -2
- metaflow-stubs/plugins/snowflake/__init__.pyi +2 -2
- metaflow-stubs/plugins/storage_executor.pyi +2 -2
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
- metaflow-stubs/plugins/timeout_decorator.pyi +3 -3
- metaflow-stubs/plugins/torchtune/__init__.pyi +2 -2
- metaflow-stubs/plugins/uv/__init__.pyi +2 -2
- metaflow-stubs/plugins/uv/uv_environment.pyi +2 -2
- metaflow-stubs/profilers/__init__.pyi +2 -2
- metaflow-stubs/pylint_wrapper.pyi +2 -2
- metaflow-stubs/runner/__init__.pyi +2 -2
- metaflow-stubs/runner/deployer.pyi +28 -28
- metaflow-stubs/runner/deployer_impl.pyi +2 -2
- metaflow-stubs/runner/metaflow_runner.pyi +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 +2 -2
- 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_decorators.pyi +6 -6
- metaflow-stubs/user_configs/config_options.pyi +2 -2
- metaflow-stubs/user_configs/config_parameters.pyi +6 -6
- {ob_metaflow_stubs-6.0.4.5.dist-info → ob_metaflow_stubs-6.0.4.6.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.4.6.dist-info/RECORD +249 -0
- ob_metaflow_stubs-6.0.4.5.dist-info/RECORD +0 -249
- {ob_metaflow_stubs-6.0.4.5.dist-info → ob_metaflow_stubs-6.0.4.6.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.4.5.dist-info → ob_metaflow_stubs-6.0.4.6.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.15.21.
|
4
|
-
# Generated on 2025-07-
|
3
|
+
# MF version: 2.15.21.3+obcheckpoint(0.2.4);ob(v1) #
|
4
|
+
# Generated on 2025-07-21T18:19:17.308440 #
|
5
5
|
######################################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
@@ -37,16 +37,16 @@ from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDec
|
|
37
37
|
from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
|
38
38
|
from . import cards as cards
|
39
39
|
from . import tuple_util as tuple_util
|
40
|
-
from . import metaflow_git as metaflow_git
|
41
40
|
from . import events as events
|
41
|
+
from . import metaflow_git as metaflow_git
|
42
42
|
from . import runner as runner
|
43
43
|
from . import plugins as plugins
|
44
44
|
from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
|
45
45
|
from . import includefile as includefile
|
46
46
|
from .includefile import IncludeFile as IncludeFile
|
47
|
+
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
|
47
48
|
from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
|
48
49
|
from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
|
49
|
-
from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
|
50
50
|
from . import client as client
|
51
51
|
from .client.core import namespace as namespace
|
52
52
|
from .client.core import get_namespace as get_namespace
|
@@ -157,7 +157,46 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
157
157
|
...
|
158
158
|
|
159
159
|
@typing.overload
|
160
|
-
def
|
160
|
+
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]]]:
|
161
|
+
"""
|
162
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
163
|
+
the execution of a step.
|
164
|
+
|
165
|
+
|
166
|
+
Parameters
|
167
|
+
----------
|
168
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
169
|
+
List of secret specs, defining how the secrets are to be retrieved
|
170
|
+
role : str, optional, default: None
|
171
|
+
Role to use for fetching secrets
|
172
|
+
"""
|
173
|
+
...
|
174
|
+
|
175
|
+
@typing.overload
|
176
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
177
|
+
...
|
178
|
+
|
179
|
+
@typing.overload
|
180
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
181
|
+
...
|
182
|
+
|
183
|
+
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):
|
184
|
+
"""
|
185
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
186
|
+
the execution of a step.
|
187
|
+
|
188
|
+
|
189
|
+
Parameters
|
190
|
+
----------
|
191
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
192
|
+
List of secret specs, defining how the secrets are to be retrieved
|
193
|
+
role : str, optional, default: None
|
194
|
+
Role to use for fetching secrets
|
195
|
+
"""
|
196
|
+
...
|
197
|
+
|
198
|
+
@typing.overload
|
199
|
+
def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
161
200
|
"""
|
162
201
|
Decorator prototype for all step decorators. This function gets specialized
|
163
202
|
and imported for all decorators types by _import_plugin_decorators().
|
@@ -165,10 +204,10 @@ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Ca
|
|
165
204
|
...
|
166
205
|
|
167
206
|
@typing.overload
|
168
|
-
def
|
207
|
+
def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
169
208
|
...
|
170
209
|
|
171
|
-
def
|
210
|
+
def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
172
211
|
"""
|
173
212
|
Decorator prototype for all step decorators. This function gets specialized
|
174
213
|
and imported for all decorators types by _import_plugin_decorators().
|
@@ -176,220 +215,312 @@ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
176
215
|
...
|
177
216
|
|
178
217
|
@typing.overload
|
179
|
-
def
|
218
|
+
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]]]:
|
180
219
|
"""
|
181
|
-
Specifies
|
182
|
-
|
183
|
-
This decorator is useful if this step may hang indefinitely.
|
220
|
+
Specifies the number of times the task corresponding
|
221
|
+
to a step needs to be retried.
|
184
222
|
|
185
|
-
This
|
186
|
-
|
187
|
-
|
223
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
224
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
225
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
188
226
|
|
189
|
-
|
190
|
-
|
227
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
228
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
229
|
+
ensuring that the flow execution can continue.
|
191
230
|
|
192
231
|
|
193
232
|
Parameters
|
194
233
|
----------
|
195
|
-
|
196
|
-
Number of
|
197
|
-
|
198
|
-
Number of minutes
|
199
|
-
hours : int, default 0
|
200
|
-
Number of hours to wait prior to timing out.
|
234
|
+
times : int, default 3
|
235
|
+
Number of times to retry this task.
|
236
|
+
minutes_between_retries : int, default 2
|
237
|
+
Number of minutes between retries.
|
201
238
|
"""
|
202
239
|
...
|
203
240
|
|
204
241
|
@typing.overload
|
205
|
-
def
|
242
|
+
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
206
243
|
...
|
207
244
|
|
208
245
|
@typing.overload
|
209
|
-
def
|
246
|
+
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
210
247
|
...
|
211
248
|
|
212
|
-
def
|
249
|
+
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):
|
213
250
|
"""
|
214
|
-
Specifies
|
215
|
-
|
216
|
-
This decorator is useful if this step may hang indefinitely.
|
251
|
+
Specifies the number of times the task corresponding
|
252
|
+
to a step needs to be retried.
|
217
253
|
|
218
|
-
This
|
219
|
-
|
220
|
-
|
254
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
255
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
256
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
221
257
|
|
222
|
-
|
223
|
-
|
258
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
259
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
260
|
+
ensuring that the flow execution can continue.
|
224
261
|
|
225
262
|
|
226
263
|
Parameters
|
227
264
|
----------
|
228
|
-
|
229
|
-
Number of
|
230
|
-
|
231
|
-
Number of minutes
|
232
|
-
hours : int, default 0
|
233
|
-
Number of hours to wait prior to timing out.
|
265
|
+
times : int, default 3
|
266
|
+
Number of times to retry this task.
|
267
|
+
minutes_between_retries : int, default 2
|
268
|
+
Number of minutes between retries.
|
234
269
|
"""
|
235
270
|
...
|
236
271
|
|
237
|
-
|
238
|
-
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]]]:
|
272
|
+
def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
239
273
|
"""
|
240
|
-
|
274
|
+
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
241
275
|
|
242
|
-
|
243
|
-
|
276
|
+
User code call
|
277
|
+
--------------
|
278
|
+
@ollama(
|
279
|
+
models=[...],
|
280
|
+
...
|
281
|
+
)
|
244
282
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
requirements specified in `@resources`.
|
283
|
+
Valid backend options
|
284
|
+
---------------------
|
285
|
+
- 'local': Run as a separate process on the local task machine.
|
286
|
+
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
287
|
+
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
288
|
+
|
289
|
+
Valid model options
|
290
|
+
-------------------
|
291
|
+
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
255
292
|
|
256
293
|
|
257
294
|
Parameters
|
258
295
|
----------
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
296
|
+
models: list[str]
|
297
|
+
List of Ollama containers running models in sidecars.
|
298
|
+
backend: str
|
299
|
+
Determines where and how to run the Ollama process.
|
300
|
+
force_pull: bool
|
301
|
+
Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
|
302
|
+
cache_update_policy: str
|
303
|
+
Cache update policy: "auto", "force", or "never".
|
304
|
+
force_cache_update: bool
|
305
|
+
Simple override for "force" cache update policy.
|
306
|
+
debug: bool
|
307
|
+
Whether to turn on verbose debugging logs.
|
308
|
+
circuit_breaker_config: dict
|
309
|
+
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
310
|
+
timeout_config: dict
|
311
|
+
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
270
312
|
"""
|
271
313
|
...
|
272
314
|
|
273
|
-
|
274
|
-
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
275
|
-
...
|
276
|
-
|
277
|
-
@typing.overload
|
278
|
-
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
279
|
-
...
|
280
|
-
|
281
|
-
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):
|
315
|
+
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]]]:
|
282
316
|
"""
|
283
|
-
|
317
|
+
This decorator is used to run vllm APIs as Metaflow task sidecars.
|
284
318
|
|
285
|
-
|
286
|
-
|
319
|
+
User code call
|
320
|
+
--------------
|
321
|
+
@vllm(
|
322
|
+
model="...",
|
323
|
+
...
|
324
|
+
)
|
287
325
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
326
|
+
Valid backend options
|
327
|
+
---------------------
|
328
|
+
- 'local': Run as a separate process on the local task machine.
|
329
|
+
|
330
|
+
Valid model options
|
331
|
+
-------------------
|
332
|
+
Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
|
333
|
+
|
334
|
+
NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
|
335
|
+
If you need multiple models, you must create multiple @vllm decorators.
|
298
336
|
|
299
337
|
|
300
338
|
Parameters
|
301
339
|
----------
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
340
|
+
model: str
|
341
|
+
HuggingFace model identifier to be served by vLLM.
|
342
|
+
backend: str
|
343
|
+
Determines where and how to run the vLLM process.
|
344
|
+
openai_api_server: bool
|
345
|
+
Whether to use OpenAI-compatible API server mode (subprocess) instead of native engine.
|
346
|
+
Default is False (uses native engine).
|
347
|
+
Set to True for backward compatibility with existing code.
|
348
|
+
debug: bool
|
349
|
+
Whether to turn on verbose debugging logs.
|
350
|
+
card_refresh_interval: int
|
351
|
+
Interval in seconds for refreshing the vLLM status card.
|
352
|
+
Only used when openai_api_server=True.
|
353
|
+
max_retries: int
|
354
|
+
Maximum number of retries checking for vLLM server startup.
|
355
|
+
Only used when openai_api_server=True.
|
356
|
+
retry_alert_frequency: int
|
357
|
+
Frequency of alert logs for vLLM server startup retries.
|
358
|
+
Only used when openai_api_server=True.
|
359
|
+
engine_args : dict
|
360
|
+
Additional keyword arguments to pass to the vLLM engine.
|
361
|
+
For example, `tensor_parallel_size=2`.
|
313
362
|
"""
|
314
363
|
...
|
315
364
|
|
316
|
-
|
365
|
+
@typing.overload
|
366
|
+
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]]]:
|
317
367
|
"""
|
318
|
-
|
368
|
+
Enables loading / saving of models within a step.
|
319
369
|
|
320
370
|
> Examples
|
321
|
-
|
322
|
-
**Usage: creating references of models from huggingface that may be loaded in downstream steps**
|
371
|
+
- Saving Models
|
323
372
|
```python
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
373
|
+
@model
|
374
|
+
@step
|
375
|
+
def train(self):
|
376
|
+
# current.model.save returns a dictionary reference to the model saved
|
377
|
+
self.my_model = current.model.save(
|
378
|
+
path_to_my_model,
|
379
|
+
label="my_model",
|
380
|
+
metadata={
|
381
|
+
"epochs": 10,
|
382
|
+
"batch-size": 32,
|
383
|
+
"learning-rate": 0.001,
|
384
|
+
}
|
385
|
+
)
|
386
|
+
self.next(self.test)
|
332
387
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
388
|
+
@model(load="my_model")
|
389
|
+
@step
|
390
|
+
def test(self):
|
391
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
392
|
+
# where the key is the name of the artifact and the value is the path to the model
|
393
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
394
|
+
self.next(self.end)
|
339
395
|
```
|
340
396
|
|
341
|
-
|
397
|
+
- Loading models
|
342
398
|
```python
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
399
|
+
@step
|
400
|
+
def train(self):
|
401
|
+
# current.model.load returns the path to the model loaded
|
402
|
+
checkpoint_path = current.model.load(
|
403
|
+
self.checkpoint_key,
|
404
|
+
)
|
405
|
+
model_path = current.model.load(
|
406
|
+
self.model,
|
407
|
+
)
|
408
|
+
self.next(self.test)
|
347
409
|
```
|
348
410
|
|
411
|
+
|
412
|
+
Parameters
|
413
|
+
----------
|
414
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
415
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
416
|
+
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`.
|
417
|
+
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
|
418
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
419
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
420
|
+
|
421
|
+
temp_dir_root : str, default: None
|
422
|
+
The root directory under which `current.model.loaded` will store loaded models
|
423
|
+
"""
|
424
|
+
...
|
425
|
+
|
426
|
+
@typing.overload
|
427
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
428
|
+
...
|
429
|
+
|
430
|
+
@typing.overload
|
431
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
432
|
+
...
|
433
|
+
|
434
|
+
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):
|
435
|
+
"""
|
436
|
+
Enables loading / saving of models within a step.
|
437
|
+
|
438
|
+
> Examples
|
439
|
+
- Saving Models
|
349
440
|
```python
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
441
|
+
@model
|
442
|
+
@step
|
443
|
+
def train(self):
|
444
|
+
# current.model.save returns a dictionary reference to the model saved
|
445
|
+
self.my_model = current.model.save(
|
446
|
+
path_to_my_model,
|
447
|
+
label="my_model",
|
448
|
+
metadata={
|
449
|
+
"epochs": 10,
|
450
|
+
"batch-size": 32,
|
451
|
+
"learning-rate": 0.001,
|
452
|
+
}
|
453
|
+
)
|
454
|
+
self.next(self.test)
|
455
|
+
|
456
|
+
@model(load="my_model")
|
457
|
+
@step
|
458
|
+
def test(self):
|
459
|
+
# `current.model.loaded` returns a dictionary of the loaded models
|
460
|
+
# where the key is the name of the artifact and the value is the path to the model
|
461
|
+
print(os.listdir(current.model.loaded["my_model"]))
|
462
|
+
self.next(self.end)
|
355
463
|
```
|
356
464
|
|
465
|
+
- Loading models
|
357
466
|
```python
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
])
|
369
|
-
@step
|
370
|
-
def finetune_model(self):
|
371
|
-
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
372
|
-
# path_to_model will be /my-directory
|
467
|
+
@step
|
468
|
+
def train(self):
|
469
|
+
# current.model.load returns the path to the model loaded
|
470
|
+
checkpoint_path = current.model.load(
|
471
|
+
self.checkpoint_key,
|
472
|
+
)
|
473
|
+
model_path = current.model.load(
|
474
|
+
self.model,
|
475
|
+
)
|
476
|
+
self.next(self.test)
|
373
477
|
```
|
374
478
|
|
375
479
|
|
376
480
|
Parameters
|
377
481
|
----------
|
378
|
-
|
379
|
-
|
482
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
483
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
484
|
+
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`.
|
485
|
+
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
|
486
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
487
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
380
488
|
|
381
|
-
|
382
|
-
The
|
489
|
+
temp_dir_root : str, default: None
|
490
|
+
The root directory under which `current.model.loaded` will store loaded models
|
491
|
+
"""
|
492
|
+
...
|
493
|
+
|
494
|
+
@typing.overload
|
495
|
+
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]]]:
|
496
|
+
"""
|
497
|
+
Specifies environment variables to be set prior to the execution of a step.
|
383
498
|
|
384
|
-
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
385
499
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
500
|
+
Parameters
|
501
|
+
----------
|
502
|
+
vars : Dict[str, str], default {}
|
503
|
+
Dictionary of environment variables to set.
|
504
|
+
"""
|
505
|
+
...
|
506
|
+
|
507
|
+
@typing.overload
|
508
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
509
|
+
...
|
510
|
+
|
511
|
+
@typing.overload
|
512
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
513
|
+
...
|
514
|
+
|
515
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
516
|
+
"""
|
517
|
+
Specifies environment variables to be set prior to the execution of a step.
|
390
518
|
|
391
|
-
|
392
|
-
|
519
|
+
|
520
|
+
Parameters
|
521
|
+
----------
|
522
|
+
vars : Dict[str, str], default {}
|
523
|
+
Dictionary of environment variables to set.
|
393
524
|
"""
|
394
525
|
...
|
395
526
|
|
@@ -442,239 +573,95 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
|
|
442
573
|
"""
|
443
574
|
...
|
444
575
|
|
445
|
-
|
576
|
+
@typing.overload
|
577
|
+
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]]]:
|
446
578
|
"""
|
447
|
-
|
448
|
-
|
449
|
-
User code call
|
450
|
-
--------------
|
451
|
-
@vllm(
|
452
|
-
model="...",
|
453
|
-
...
|
454
|
-
)
|
455
|
-
|
456
|
-
Valid backend options
|
457
|
-
---------------------
|
458
|
-
- 'local': Run as a separate process on the local task machine.
|
459
|
-
|
460
|
-
Valid model options
|
461
|
-
-------------------
|
462
|
-
Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
|
579
|
+
Specifies the Conda environment for the step.
|
463
580
|
|
464
|
-
|
465
|
-
|
581
|
+
Information in this decorator will augment any
|
582
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
583
|
+
you can use `@conda_base` to set packages required by all
|
584
|
+
steps and use `@conda` to specify step-specific overrides.
|
466
585
|
|
467
586
|
|
468
587
|
Parameters
|
469
588
|
----------
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
card_refresh_interval: int
|
481
|
-
Interval in seconds for refreshing the vLLM status card.
|
482
|
-
Only used when openai_api_server=True.
|
483
|
-
max_retries: int
|
484
|
-
Maximum number of retries checking for vLLM server startup.
|
485
|
-
Only used when openai_api_server=True.
|
486
|
-
retry_alert_frequency: int
|
487
|
-
Frequency of alert logs for vLLM server startup retries.
|
488
|
-
Only used when openai_api_server=True.
|
489
|
-
engine_args : dict
|
490
|
-
Additional keyword arguments to pass to the vLLM engine.
|
491
|
-
For example, `tensor_parallel_size=2`.
|
589
|
+
packages : Dict[str, str], default {}
|
590
|
+
Packages to use for this step. The key is the name of the package
|
591
|
+
and the value is the version to use.
|
592
|
+
libraries : Dict[str, str], default {}
|
593
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
594
|
+
python : str, optional, default None
|
595
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
596
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
597
|
+
disabled : bool, default False
|
598
|
+
If set to True, disables @conda.
|
492
599
|
"""
|
493
600
|
...
|
494
601
|
|
495
602
|
@typing.overload
|
496
|
-
def
|
603
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
604
|
+
...
|
605
|
+
|
606
|
+
@typing.overload
|
607
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
608
|
+
...
|
609
|
+
|
610
|
+
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):
|
497
611
|
"""
|
498
|
-
|
612
|
+
Specifies the Conda environment for the step.
|
499
613
|
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
```python
|
505
|
-
@checkpoint
|
506
|
-
@step
|
507
|
-
def train(self):
|
508
|
-
model = create_model(self.parameters, checkpoint_path = None)
|
509
|
-
for i in range(self.epochs):
|
510
|
-
# some training logic
|
511
|
-
loss = model.train(self.dataset)
|
512
|
-
if i % 10 == 0:
|
513
|
-
model.save(
|
514
|
-
current.checkpoint.directory,
|
515
|
-
)
|
516
|
-
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
517
|
-
# and returns a reference dictionary to the checkpoint saved in the datastore
|
518
|
-
self.latest_checkpoint = current.checkpoint.save(
|
519
|
-
name="epoch_checkpoint",
|
520
|
-
metadata={
|
521
|
-
"epoch": i,
|
522
|
-
"loss": loss,
|
523
|
-
}
|
524
|
-
)
|
525
|
-
```
|
526
|
-
|
527
|
-
- Using Loaded Checkpoints
|
528
|
-
|
529
|
-
```python
|
530
|
-
@retry(times=3)
|
531
|
-
@checkpoint
|
532
|
-
@step
|
533
|
-
def train(self):
|
534
|
-
# Assume that the task has restarted and the previous attempt of the task
|
535
|
-
# saved a checkpoint
|
536
|
-
checkpoint_path = None
|
537
|
-
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
538
|
-
print("Loaded checkpoint from the previous attempt")
|
539
|
-
checkpoint_path = current.checkpoint.directory
|
540
|
-
|
541
|
-
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
542
|
-
for i in range(self.epochs):
|
543
|
-
...
|
544
|
-
```
|
614
|
+
Information in this decorator will augment any
|
615
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
616
|
+
you can use `@conda_base` to set packages required by all
|
617
|
+
steps and use `@conda` to specify step-specific overrides.
|
545
618
|
|
546
619
|
|
547
620
|
Parameters
|
548
621
|
----------
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
temp_dir_root : str, default: None
|
561
|
-
The root directory under which `current.checkpoint.directory` will be created.
|
622
|
+
packages : Dict[str, str], default {}
|
623
|
+
Packages to use for this step. The key is the name of the package
|
624
|
+
and the value is the version to use.
|
625
|
+
libraries : Dict[str, str], default {}
|
626
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
627
|
+
python : str, optional, default None
|
628
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
629
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
630
|
+
disabled : bool, default False
|
631
|
+
If set to True, disables @conda.
|
562
632
|
"""
|
563
633
|
...
|
564
634
|
|
565
|
-
|
566
|
-
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
567
|
-
...
|
568
|
-
|
569
|
-
@typing.overload
|
570
|
-
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
571
|
-
...
|
572
|
-
|
573
|
-
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):
|
635
|
+
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]]]:
|
574
636
|
"""
|
575
|
-
|
576
|
-
|
577
|
-
> Examples
|
578
|
-
|
579
|
-
- Saving Checkpoints
|
580
|
-
|
581
|
-
```python
|
582
|
-
@checkpoint
|
583
|
-
@step
|
584
|
-
def train(self):
|
585
|
-
model = create_model(self.parameters, checkpoint_path = None)
|
586
|
-
for i in range(self.epochs):
|
587
|
-
# some training logic
|
588
|
-
loss = model.train(self.dataset)
|
589
|
-
if i % 10 == 0:
|
590
|
-
model.save(
|
591
|
-
current.checkpoint.directory,
|
592
|
-
)
|
593
|
-
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
594
|
-
# and returns a reference dictionary to the checkpoint saved in the datastore
|
595
|
-
self.latest_checkpoint = current.checkpoint.save(
|
596
|
-
name="epoch_checkpoint",
|
597
|
-
metadata={
|
598
|
-
"epoch": i,
|
599
|
-
"loss": loss,
|
600
|
-
}
|
601
|
-
)
|
602
|
-
```
|
603
|
-
|
604
|
-
- Using Loaded Checkpoints
|
605
|
-
|
606
|
-
```python
|
607
|
-
@retry(times=3)
|
608
|
-
@checkpoint
|
609
|
-
@step
|
610
|
-
def train(self):
|
611
|
-
# Assume that the task has restarted and the previous attempt of the task
|
612
|
-
# saved a checkpoint
|
613
|
-
checkpoint_path = None
|
614
|
-
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
615
|
-
print("Loaded checkpoint from the previous attempt")
|
616
|
-
checkpoint_path = current.checkpoint.directory
|
617
|
-
|
618
|
-
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
619
|
-
for i in range(self.epochs):
|
620
|
-
...
|
621
|
-
```
|
637
|
+
Specifies that this step should execute on DGX cloud.
|
622
638
|
|
623
639
|
|
624
640
|
Parameters
|
625
641
|
----------
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
will be loaded at the start of the task.
|
631
|
-
- "none": Do not load any checkpoint
|
632
|
-
- "fresh": Loads the lastest checkpoint created within the running Task.
|
633
|
-
This mode helps loading checkpoints across various retry attempts of the same task.
|
634
|
-
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
635
|
-
created within the task will be loaded when the task is retries execution on failure.
|
636
|
-
|
637
|
-
temp_dir_root : str, default: None
|
638
|
-
The root directory under which `current.checkpoint.directory` will be created.
|
642
|
+
gpu : int
|
643
|
+
Number of GPUs to use.
|
644
|
+
gpu_type : str
|
645
|
+
Type of Nvidia GPU to use.
|
639
646
|
"""
|
640
647
|
...
|
641
648
|
|
642
649
|
@typing.overload
|
643
|
-
def
|
650
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
644
651
|
"""
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
Parameters
|
650
|
-
----------
|
651
|
-
sources : List[Union[str, Dict[str, Any]]], default: []
|
652
|
-
List of secret specs, defining how the secrets are to be retrieved
|
653
|
-
role : str, optional, default: None
|
654
|
-
Role to use for fetching secrets
|
652
|
+
Decorator prototype for all step decorators. This function gets specialized
|
653
|
+
and imported for all decorators types by _import_plugin_decorators().
|
655
654
|
"""
|
656
655
|
...
|
657
656
|
|
658
657
|
@typing.overload
|
659
|
-
def
|
660
|
-
...
|
661
|
-
|
662
|
-
@typing.overload
|
663
|
-
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
658
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
664
659
|
...
|
665
660
|
|
666
|
-
def
|
661
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
667
662
|
"""
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
Parameters
|
673
|
-
----------
|
674
|
-
sources : List[Union[str, Dict[str, Any]]], default: []
|
675
|
-
List of secret specs, defining how the secrets are to be retrieved
|
676
|
-
role : str, optional, default: None
|
677
|
-
Role to use for fetching secrets
|
663
|
+
Decorator prototype for all step decorators. This function gets specialized
|
664
|
+
and imported for all decorators types by _import_plugin_decorators().
|
678
665
|
"""
|
679
666
|
...
|
680
667
|
|
@@ -768,438 +755,287 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
|
|
768
755
|
...
|
769
756
|
|
770
757
|
@typing.overload
|
771
|
-
def
|
758
|
+
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]]]:
|
772
759
|
"""
|
773
|
-
Specifies the
|
760
|
+
Specifies the PyPI packages for the step.
|
774
761
|
|
775
762
|
Information in this decorator will augment any
|
776
|
-
attributes set in the `@
|
777
|
-
you can use `@
|
778
|
-
steps and use `@
|
763
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
764
|
+
you can use `@pypi_base` to set packages required by all
|
765
|
+
steps and use `@pypi` to specify step-specific overrides.
|
779
766
|
|
780
767
|
|
781
768
|
Parameters
|
782
769
|
----------
|
783
|
-
packages : Dict[str, str], default {}
|
770
|
+
packages : Dict[str, str], default: {}
|
784
771
|
Packages to use for this step. The key is the name of the package
|
785
772
|
and the value is the version to use.
|
786
|
-
|
787
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
788
|
-
python : str, optional, default None
|
773
|
+
python : str, optional, default: None
|
789
774
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
790
775
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
791
|
-
disabled : bool, default False
|
792
|
-
If set to True, disables @conda.
|
793
776
|
"""
|
794
777
|
...
|
795
778
|
|
796
779
|
@typing.overload
|
797
|
-
def
|
780
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
798
781
|
...
|
799
782
|
|
800
783
|
@typing.overload
|
801
|
-
def
|
784
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
802
785
|
...
|
803
786
|
|
804
|
-
def
|
787
|
+
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):
|
805
788
|
"""
|
806
|
-
Specifies the
|
789
|
+
Specifies the PyPI packages for the step.
|
807
790
|
|
808
791
|
Information in this decorator will augment any
|
809
|
-
attributes set in the `@
|
810
|
-
you can use `@
|
811
|
-
steps and use `@
|
792
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
793
|
+
you can use `@pypi_base` to set packages required by all
|
794
|
+
steps and use `@pypi` to specify step-specific overrides.
|
812
795
|
|
813
796
|
|
814
797
|
Parameters
|
815
798
|
----------
|
816
|
-
packages : Dict[str, str], default {}
|
799
|
+
packages : Dict[str, str], default: {}
|
817
800
|
Packages to use for this step. The key is the name of the package
|
818
801
|
and the value is the version to use.
|
819
|
-
|
820
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
821
|
-
python : str, optional, default None
|
802
|
+
python : str, optional, default: None
|
822
803
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
823
804
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
824
|
-
disabled : bool, default False
|
825
|
-
If set to True, disables @conda.
|
826
805
|
"""
|
827
806
|
...
|
828
807
|
|
829
|
-
|
830
|
-
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]]]:
|
808
|
+
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]]]:
|
831
809
|
"""
|
832
|
-
|
833
|
-
|
834
|
-
> Examples
|
835
|
-
- Saving Models
|
836
|
-
```python
|
837
|
-
@model
|
838
|
-
@step
|
839
|
-
def train(self):
|
840
|
-
# current.model.save returns a dictionary reference to the model saved
|
841
|
-
self.my_model = current.model.save(
|
842
|
-
path_to_my_model,
|
843
|
-
label="my_model",
|
844
|
-
metadata={
|
845
|
-
"epochs": 10,
|
846
|
-
"batch-size": 32,
|
847
|
-
"learning-rate": 0.001,
|
848
|
-
}
|
849
|
-
)
|
850
|
-
self.next(self.test)
|
851
|
-
|
852
|
-
@model(load="my_model")
|
853
|
-
@step
|
854
|
-
def test(self):
|
855
|
-
# `current.model.loaded` returns a dictionary of the loaded models
|
856
|
-
# where the key is the name of the artifact and the value is the path to the model
|
857
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
858
|
-
self.next(self.end)
|
859
|
-
```
|
860
|
-
|
861
|
-
- Loading models
|
862
|
-
```python
|
863
|
-
@step
|
864
|
-
def train(self):
|
865
|
-
# current.model.load returns the path to the model loaded
|
866
|
-
checkpoint_path = current.model.load(
|
867
|
-
self.checkpoint_key,
|
868
|
-
)
|
869
|
-
model_path = current.model.load(
|
870
|
-
self.model,
|
871
|
-
)
|
872
|
-
self.next(self.test)
|
873
|
-
```
|
810
|
+
Specifies that this step should execute on DGX cloud.
|
874
811
|
|
875
812
|
|
876
813
|
Parameters
|
877
814
|
----------
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
temp_dir_root : str, default: None
|
886
|
-
The root directory under which `current.model.loaded` will store loaded models
|
815
|
+
gpu : int
|
816
|
+
Number of GPUs to use.
|
817
|
+
gpu_type : str
|
818
|
+
Type of Nvidia GPU to use.
|
819
|
+
queue_timeout : int
|
820
|
+
Time to keep the job in NVCF's queue.
|
887
821
|
"""
|
888
822
|
...
|
889
823
|
|
890
824
|
@typing.overload
|
891
|
-
def
|
892
|
-
...
|
893
|
-
|
894
|
-
@typing.overload
|
895
|
-
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
896
|
-
...
|
897
|
-
|
898
|
-
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):
|
825
|
+
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]]]:
|
899
826
|
"""
|
900
|
-
|
827
|
+
Specifies the resources needed when executing this step.
|
901
828
|
|
902
|
-
|
903
|
-
|
904
|
-
```python
|
905
|
-
@model
|
906
|
-
@step
|
907
|
-
def train(self):
|
908
|
-
# current.model.save returns a dictionary reference to the model saved
|
909
|
-
self.my_model = current.model.save(
|
910
|
-
path_to_my_model,
|
911
|
-
label="my_model",
|
912
|
-
metadata={
|
913
|
-
"epochs": 10,
|
914
|
-
"batch-size": 32,
|
915
|
-
"learning-rate": 0.001,
|
916
|
-
}
|
917
|
-
)
|
918
|
-
self.next(self.test)
|
829
|
+
Use `@resources` to specify the resource requirements
|
830
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
919
831
|
|
920
|
-
|
921
|
-
@step
|
922
|
-
def test(self):
|
923
|
-
# `current.model.loaded` returns a dictionary of the loaded models
|
924
|
-
# where the key is the name of the artifact and the value is the path to the model
|
925
|
-
print(os.listdir(current.model.loaded["my_model"]))
|
926
|
-
self.next(self.end)
|
832
|
+
You can choose the compute layer on the command line by executing e.g.
|
927
833
|
```
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
@step
|
932
|
-
def train(self):
|
933
|
-
# current.model.load returns the path to the model loaded
|
934
|
-
checkpoint_path = current.model.load(
|
935
|
-
self.checkpoint_key,
|
936
|
-
)
|
937
|
-
model_path = current.model.load(
|
938
|
-
self.model,
|
939
|
-
)
|
940
|
-
self.next(self.test)
|
834
|
+
python myflow.py run --with batch
|
835
|
+
```
|
836
|
+
or
|
941
837
|
```
|
838
|
+
python myflow.py run --with kubernetes
|
839
|
+
```
|
840
|
+
which executes the flow on the desired system using the
|
841
|
+
requirements specified in `@resources`.
|
942
842
|
|
943
843
|
|
944
844
|
Parameters
|
945
845
|
----------
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
846
|
+
cpu : int, default 1
|
847
|
+
Number of CPUs required for this step.
|
848
|
+
gpu : int, optional, default None
|
849
|
+
Number of GPUs required for this step.
|
850
|
+
disk : int, optional, default None
|
851
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
852
|
+
memory : int, default 4096
|
853
|
+
Memory size (in MB) required for this step.
|
854
|
+
shared_memory : int, optional, default None
|
855
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
856
|
+
This parameter maps to the `--shm-size` option in Docker.
|
955
857
|
"""
|
956
858
|
...
|
957
859
|
|
958
860
|
@typing.overload
|
959
|
-
def
|
960
|
-
"""
|
961
|
-
Internal decorator to support Fast bakery
|
962
|
-
"""
|
861
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
963
862
|
...
|
964
863
|
|
965
864
|
@typing.overload
|
966
|
-
def
|
865
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
967
866
|
...
|
968
867
|
|
969
|
-
def
|
868
|
+
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):
|
970
869
|
"""
|
971
|
-
|
870
|
+
Specifies the resources needed when executing this step.
|
871
|
+
|
872
|
+
Use `@resources` to specify the resource requirements
|
873
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
874
|
+
|
875
|
+
You can choose the compute layer on the command line by executing e.g.
|
876
|
+
```
|
877
|
+
python myflow.py run --with batch
|
878
|
+
```
|
879
|
+
or
|
880
|
+
```
|
881
|
+
python myflow.py run --with kubernetes
|
882
|
+
```
|
883
|
+
which executes the flow on the desired system using the
|
884
|
+
requirements specified in `@resources`.
|
885
|
+
|
886
|
+
|
887
|
+
Parameters
|
888
|
+
----------
|
889
|
+
cpu : int, default 1
|
890
|
+
Number of CPUs required for this step.
|
891
|
+
gpu : int, optional, default None
|
892
|
+
Number of GPUs required for this step.
|
893
|
+
disk : int, optional, default None
|
894
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
895
|
+
memory : int, default 4096
|
896
|
+
Memory size (in MB) required for this step.
|
897
|
+
shared_memory : int, optional, default None
|
898
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
899
|
+
This parameter maps to the `--shm-size` option in Docker.
|
972
900
|
"""
|
973
901
|
...
|
974
902
|
|
975
|
-
def
|
903
|
+
def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.Union[typing.List[str], typing.List[typing.Tuple[typing.Dict, str]], typing.List[typing.Tuple[str, str]], typing.List[typing.Dict], None]) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
976
904
|
"""
|
977
|
-
|
905
|
+
Decorator that helps cache, version and store models/datasets from huggingface hub.
|
906
|
+
|
907
|
+
> Examples
|
908
|
+
|
909
|
+
**Usage: creating references of models from huggingface that may be loaded in downstream steps**
|
910
|
+
```python
|
911
|
+
@huggingface_hub
|
912
|
+
@step
|
913
|
+
def pull_model_from_huggingface(self):
|
914
|
+
# `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
|
915
|
+
# and saves it in the backend storage based on the model's `repo_id`. If there exists a model
|
916
|
+
# with the same `repo_id` in the backend storage, it will not download the model again. The return
|
917
|
+
# value of the function is a reference to the model in the backend storage.
|
918
|
+
# This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
|
919
|
+
|
920
|
+
self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
|
921
|
+
self.llama_model = current.huggingface_hub.snapshot_download(
|
922
|
+
repo_id=self.model_id,
|
923
|
+
allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
|
924
|
+
)
|
925
|
+
self.next(self.train)
|
926
|
+
```
|
927
|
+
|
928
|
+
**Usage: loading models directly from huggingface hub or from cache (from metaflow's datastore)**
|
929
|
+
```python
|
930
|
+
@huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
|
931
|
+
@step
|
932
|
+
def pull_model_from_huggingface(self):
|
933
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
934
|
+
```
|
935
|
+
|
936
|
+
```python
|
937
|
+
@huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora, "/my-lora-directory")])
|
938
|
+
@step
|
939
|
+
def finetune_model(self):
|
940
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
941
|
+
# path_to_model will be /my-directory
|
942
|
+
```
|
943
|
+
|
944
|
+
```python
|
945
|
+
# Takes all the arguments passed to `snapshot_download`
|
946
|
+
# except for `local_dir`
|
947
|
+
@huggingface_hub(load=[
|
948
|
+
{
|
949
|
+
"repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
|
950
|
+
},
|
951
|
+
{
|
952
|
+
"repo_id": "myorg/mistral-lora",
|
953
|
+
"repo_type": "model",
|
954
|
+
},
|
955
|
+
])
|
956
|
+
@step
|
957
|
+
def finetune_model(self):
|
958
|
+
path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
|
959
|
+
# path_to_model will be /my-directory
|
960
|
+
```
|
978
961
|
|
979
962
|
|
980
963
|
Parameters
|
981
964
|
----------
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
965
|
+
temp_dir_root : str, optional
|
966
|
+
The root directory that will hold the temporary directory where objects will be downloaded.
|
967
|
+
|
968
|
+
load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
|
969
|
+
The list of repos (models/datasets) to load.
|
970
|
+
|
971
|
+
Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
|
972
|
+
|
973
|
+
- If repo (model/dataset) is not found in the datastore:
|
974
|
+
- Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
|
975
|
+
- Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
|
976
|
+
- All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
|
977
|
+
|
978
|
+
- If repo is found in the datastore:
|
979
|
+
- Loads it directly from datastore to local path (can be temporary directory or specified path)
|
986
980
|
"""
|
987
981
|
...
|
988
982
|
|
989
983
|
@typing.overload
|
990
|
-
def
|
984
|
+
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]]]:
|
991
985
|
"""
|
992
|
-
Specifies
|
986
|
+
Specifies a timeout for your step.
|
993
987
|
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
988
|
+
This decorator is useful if this step may hang indefinitely.
|
989
|
+
|
990
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
991
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
992
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
993
|
+
|
994
|
+
Note that all the values specified in parameters are added together so if you specify
|
995
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
998
996
|
|
999
997
|
|
1000
998
|
Parameters
|
1001
999
|
----------
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1000
|
+
seconds : int, default 0
|
1001
|
+
Number of seconds to wait prior to timing out.
|
1002
|
+
minutes : int, default 0
|
1003
|
+
Number of minutes to wait prior to timing out.
|
1004
|
+
hours : int, default 0
|
1005
|
+
Number of hours to wait prior to timing out.
|
1008
1006
|
"""
|
1009
1007
|
...
|
1010
1008
|
|
1011
1009
|
@typing.overload
|
1012
|
-
def
|
1010
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1013
1011
|
...
|
1014
1012
|
|
1015
1013
|
@typing.overload
|
1016
|
-
def
|
1014
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1017
1015
|
...
|
1018
1016
|
|
1019
|
-
def
|
1017
|
+
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):
|
1020
1018
|
"""
|
1021
|
-
Specifies
|
1019
|
+
Specifies a timeout for your step.
|
1022
1020
|
|
1023
|
-
|
1024
|
-
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
1025
|
-
you can use `@pypi_base` to set packages required by all
|
1026
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1021
|
+
This decorator is useful if this step may hang indefinitely.
|
1027
1022
|
|
1023
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
1024
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
1025
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
1028
1026
|
|
1029
|
-
|
1030
|
-
|
1031
|
-
packages : Dict[str, str], default: {}
|
1032
|
-
Packages to use for this step. The key is the name of the package
|
1033
|
-
and the value is the version to use.
|
1034
|
-
python : str, optional, default: None
|
1035
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1036
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1037
|
-
"""
|
1038
|
-
...
|
1039
|
-
|
1040
|
-
@typing.overload
|
1041
|
-
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]]]:
|
1042
|
-
"""
|
1043
|
-
Specifies the number of times the task corresponding
|
1044
|
-
to a step needs to be retried.
|
1045
|
-
|
1046
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
1047
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
1048
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
1049
|
-
|
1050
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
1051
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
1052
|
-
ensuring that the flow execution can continue.
|
1053
|
-
|
1054
|
-
|
1055
|
-
Parameters
|
1056
|
-
----------
|
1057
|
-
times : int, default 3
|
1058
|
-
Number of times to retry this task.
|
1059
|
-
minutes_between_retries : int, default 2
|
1060
|
-
Number of minutes between retries.
|
1061
|
-
"""
|
1062
|
-
...
|
1063
|
-
|
1064
|
-
@typing.overload
|
1065
|
-
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1066
|
-
...
|
1067
|
-
|
1068
|
-
@typing.overload
|
1069
|
-
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1070
|
-
...
|
1071
|
-
|
1072
|
-
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):
|
1073
|
-
"""
|
1074
|
-
Specifies the number of times the task corresponding
|
1075
|
-
to a step needs to be retried.
|
1076
|
-
|
1077
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
1078
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
1079
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
1080
|
-
|
1081
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
1082
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
1083
|
-
ensuring that the flow execution can continue.
|
1084
|
-
|
1085
|
-
|
1086
|
-
Parameters
|
1087
|
-
----------
|
1088
|
-
times : int, default 3
|
1089
|
-
Number of times to retry this task.
|
1090
|
-
minutes_between_retries : int, default 2
|
1091
|
-
Number of minutes between retries.
|
1092
|
-
"""
|
1093
|
-
...
|
1094
|
-
|
1095
|
-
@typing.overload
|
1096
|
-
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]]]:
|
1097
|
-
"""
|
1098
|
-
Specifies environment variables to be set prior to the execution of a step.
|
1099
|
-
|
1100
|
-
|
1101
|
-
Parameters
|
1102
|
-
----------
|
1103
|
-
vars : Dict[str, str], default {}
|
1104
|
-
Dictionary of environment variables to set.
|
1105
|
-
"""
|
1106
|
-
...
|
1107
|
-
|
1108
|
-
@typing.overload
|
1109
|
-
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1110
|
-
...
|
1111
|
-
|
1112
|
-
@typing.overload
|
1113
|
-
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1114
|
-
...
|
1115
|
-
|
1116
|
-
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
1117
|
-
"""
|
1118
|
-
Specifies environment variables to be set prior to the execution of a step.
|
1119
|
-
|
1120
|
-
|
1121
|
-
Parameters
|
1122
|
-
----------
|
1123
|
-
vars : Dict[str, str], default {}
|
1124
|
-
Dictionary of environment variables to set.
|
1125
|
-
"""
|
1126
|
-
...
|
1127
|
-
|
1128
|
-
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]]]:
|
1129
|
-
"""
|
1130
|
-
Specifies that this step should execute on DGX cloud.
|
1131
|
-
|
1132
|
-
|
1133
|
-
Parameters
|
1134
|
-
----------
|
1135
|
-
gpu : int
|
1136
|
-
Number of GPUs to use.
|
1137
|
-
gpu_type : str
|
1138
|
-
Type of Nvidia GPU to use.
|
1139
|
-
queue_timeout : int
|
1140
|
-
Time to keep the job in NVCF's queue.
|
1141
|
-
"""
|
1142
|
-
...
|
1143
|
-
|
1144
|
-
def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
1145
|
-
"""
|
1146
|
-
This decorator is used to run Ollama APIs as Metaflow task sidecars.
|
1147
|
-
|
1148
|
-
User code call
|
1149
|
-
--------------
|
1150
|
-
@ollama(
|
1151
|
-
models=[...],
|
1152
|
-
...
|
1153
|
-
)
|
1154
|
-
|
1155
|
-
Valid backend options
|
1156
|
-
---------------------
|
1157
|
-
- 'local': Run as a separate process on the local task machine.
|
1158
|
-
- (TODO) 'managed': Outerbounds hosts and selects compute provider.
|
1159
|
-
- (TODO) 'remote': Spin up separate instance to serve Ollama models.
|
1160
|
-
|
1161
|
-
Valid model options
|
1162
|
-
-------------------
|
1163
|
-
Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
|
1027
|
+
Note that all the values specified in parameters are added together so if you specify
|
1028
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
1164
1029
|
|
1165
1030
|
|
1166
1031
|
Parameters
|
1167
1032
|
----------
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
cache_update_policy: str
|
1175
|
-
Cache update policy: "auto", "force", or "never".
|
1176
|
-
force_cache_update: bool
|
1177
|
-
Simple override for "force" cache update policy.
|
1178
|
-
debug: bool
|
1179
|
-
Whether to turn on verbose debugging logs.
|
1180
|
-
circuit_breaker_config: dict
|
1181
|
-
Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
|
1182
|
-
timeout_config: dict
|
1183
|
-
Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
|
1184
|
-
"""
|
1185
|
-
...
|
1186
|
-
|
1187
|
-
@typing.overload
|
1188
|
-
def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1189
|
-
"""
|
1190
|
-
Decorator prototype for all step decorators. This function gets specialized
|
1191
|
-
and imported for all decorators types by _import_plugin_decorators().
|
1192
|
-
"""
|
1193
|
-
...
|
1194
|
-
|
1195
|
-
@typing.overload
|
1196
|
-
def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1197
|
-
...
|
1198
|
-
|
1199
|
-
def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
1200
|
-
"""
|
1201
|
-
Decorator prototype for all step decorators. This function gets specialized
|
1202
|
-
and imported for all decorators types by _import_plugin_decorators().
|
1033
|
+
seconds : int, default 0
|
1034
|
+
Number of seconds to wait prior to timing out.
|
1035
|
+
minutes : int, default 0
|
1036
|
+
Number of minutes to wait prior to timing out.
|
1037
|
+
hours : int, default 0
|
1038
|
+
Number of hours to wait prior to timing out.
|
1203
1039
|
"""
|
1204
1040
|
...
|
1205
1041
|
|
@@ -1255,154 +1091,260 @@ def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
1255
1091
|
...
|
1256
1092
|
|
1257
1093
|
@typing.overload
|
1258
|
-
def
|
1094
|
+
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]]]:
|
1259
1095
|
"""
|
1260
|
-
|
1096
|
+
Enables checkpointing for a step.
|
1261
1097
|
|
1262
|
-
|
1263
|
-
@trigger_on_finish(flow='FooFlow')
|
1264
|
-
```
|
1265
|
-
or
|
1266
|
-
```
|
1267
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1268
|
-
```
|
1269
|
-
This decorator respects the @project decorator and triggers the flow
|
1270
|
-
when upstream runs within the same namespace complete successfully
|
1098
|
+
> Examples
|
1271
1099
|
|
1272
|
-
|
1273
|
-
by specifying the fully qualified project_flow_name.
|
1274
|
-
```
|
1275
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1276
|
-
```
|
1277
|
-
or
|
1278
|
-
```
|
1279
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1280
|
-
```
|
1100
|
+
- Saving Checkpoints
|
1281
1101
|
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1102
|
+
```python
|
1103
|
+
@checkpoint
|
1104
|
+
@step
|
1105
|
+
def train(self):
|
1106
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
1107
|
+
for i in range(self.epochs):
|
1108
|
+
# some training logic
|
1109
|
+
loss = model.train(self.dataset)
|
1110
|
+
if i % 10 == 0:
|
1111
|
+
model.save(
|
1112
|
+
current.checkpoint.directory,
|
1113
|
+
)
|
1114
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
1115
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
1116
|
+
self.latest_checkpoint = current.checkpoint.save(
|
1117
|
+
name="epoch_checkpoint",
|
1118
|
+
metadata={
|
1119
|
+
"epoch": i,
|
1120
|
+
"loss": loss,
|
1121
|
+
}
|
1122
|
+
)
|
1286
1123
|
```
|
1287
1124
|
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1125
|
+
- Using Loaded Checkpoints
|
1126
|
+
|
1127
|
+
```python
|
1128
|
+
@retry(times=3)
|
1129
|
+
@checkpoint
|
1130
|
+
@step
|
1131
|
+
def train(self):
|
1132
|
+
# Assume that the task has restarted and the previous attempt of the task
|
1133
|
+
# saved a checkpoint
|
1134
|
+
checkpoint_path = None
|
1135
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
1136
|
+
print("Loaded checkpoint from the previous attempt")
|
1137
|
+
checkpoint_path = current.checkpoint.directory
|
1138
|
+
|
1139
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
1140
|
+
for i in range(self.epochs):
|
1141
|
+
...
|
1142
|
+
```
|
1293
1143
|
|
1294
1144
|
|
1295
1145
|
Parameters
|
1296
1146
|
----------
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1147
|
+
load_policy : str, default: "fresh"
|
1148
|
+
The policy for loading the checkpoint. The following policies are supported:
|
1149
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
1150
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
1151
|
+
will be loaded at the start of the task.
|
1152
|
+
- "none": Do not load any checkpoint
|
1153
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
1154
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
1155
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
1156
|
+
created within the task will be loaded when the task is retries execution on failure.
|
1157
|
+
|
1158
|
+
temp_dir_root : str, default: None
|
1159
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
1303
1160
|
"""
|
1304
1161
|
...
|
1305
1162
|
|
1306
1163
|
@typing.overload
|
1307
|
-
def
|
1164
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1308
1165
|
...
|
1309
1166
|
|
1310
|
-
|
1167
|
+
@typing.overload
|
1168
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1169
|
+
...
|
1170
|
+
|
1171
|
+
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):
|
1311
1172
|
"""
|
1312
|
-
|
1173
|
+
Enables checkpointing for a step.
|
1313
1174
|
|
1314
|
-
|
1315
|
-
@trigger_on_finish(flow='FooFlow')
|
1316
|
-
```
|
1317
|
-
or
|
1318
|
-
```
|
1319
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1320
|
-
```
|
1321
|
-
This decorator respects the @project decorator and triggers the flow
|
1322
|
-
when upstream runs within the same namespace complete successfully
|
1175
|
+
> Examples
|
1323
1176
|
|
1324
|
-
|
1325
|
-
by specifying the fully qualified project_flow_name.
|
1326
|
-
```
|
1327
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1328
|
-
```
|
1329
|
-
or
|
1330
|
-
```
|
1331
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1332
|
-
```
|
1177
|
+
- Saving Checkpoints
|
1333
1178
|
|
1334
|
-
|
1335
|
-
|
1179
|
+
```python
|
1180
|
+
@checkpoint
|
1181
|
+
@step
|
1182
|
+
def train(self):
|
1183
|
+
model = create_model(self.parameters, checkpoint_path = None)
|
1184
|
+
for i in range(self.epochs):
|
1185
|
+
# some training logic
|
1186
|
+
loss = model.train(self.dataset)
|
1187
|
+
if i % 10 == 0:
|
1188
|
+
model.save(
|
1189
|
+
current.checkpoint.directory,
|
1190
|
+
)
|
1191
|
+
# saves the contents of the `current.checkpoint.directory` as a checkpoint
|
1192
|
+
# and returns a reference dictionary to the checkpoint saved in the datastore
|
1193
|
+
self.latest_checkpoint = current.checkpoint.save(
|
1194
|
+
name="epoch_checkpoint",
|
1195
|
+
metadata={
|
1196
|
+
"epoch": i,
|
1197
|
+
"loss": loss,
|
1198
|
+
}
|
1199
|
+
)
|
1336
1200
|
```
|
1337
|
-
|
1201
|
+
|
1202
|
+
- Using Loaded Checkpoints
|
1203
|
+
|
1204
|
+
```python
|
1205
|
+
@retry(times=3)
|
1206
|
+
@checkpoint
|
1207
|
+
@step
|
1208
|
+
def train(self):
|
1209
|
+
# Assume that the task has restarted and the previous attempt of the task
|
1210
|
+
# saved a checkpoint
|
1211
|
+
checkpoint_path = None
|
1212
|
+
if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
|
1213
|
+
print("Loaded checkpoint from the previous attempt")
|
1214
|
+
checkpoint_path = current.checkpoint.directory
|
1215
|
+
|
1216
|
+
model = create_model(self.parameters, checkpoint_path = checkpoint_path)
|
1217
|
+
for i in range(self.epochs):
|
1218
|
+
...
|
1338
1219
|
```
|
1339
1220
|
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1221
|
+
|
1222
|
+
Parameters
|
1223
|
+
----------
|
1224
|
+
load_policy : str, default: "fresh"
|
1225
|
+
The policy for loading the checkpoint. The following policies are supported:
|
1226
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
1227
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
1228
|
+
will be loaded at the start of the task.
|
1229
|
+
- "none": Do not load any checkpoint
|
1230
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
1231
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
1232
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
1233
|
+
created within the task will be loaded when the task is retries execution on failure.
|
1234
|
+
|
1235
|
+
temp_dir_root : str, default: None
|
1236
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
1237
|
+
"""
|
1238
|
+
...
|
1239
|
+
|
1240
|
+
@typing.overload
|
1241
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1242
|
+
"""
|
1243
|
+
Internal decorator to support Fast bakery
|
1244
|
+
"""
|
1245
|
+
...
|
1246
|
+
|
1247
|
+
@typing.overload
|
1248
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1249
|
+
...
|
1250
|
+
|
1251
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
1252
|
+
"""
|
1253
|
+
Internal decorator to support Fast bakery
|
1254
|
+
"""
|
1255
|
+
...
|
1256
|
+
|
1257
|
+
@typing.overload
|
1258
|
+
def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1259
|
+
"""
|
1260
|
+
Specifies the Conda environment for all steps of the flow.
|
1261
|
+
|
1262
|
+
Use `@conda_base` to set common libraries required by all
|
1263
|
+
steps and use `@conda` to specify step-specific additions.
|
1345
1264
|
|
1346
1265
|
|
1347
1266
|
Parameters
|
1348
1267
|
----------
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1268
|
+
packages : Dict[str, str], default {}
|
1269
|
+
Packages to use for this flow. The key is the name of the package
|
1270
|
+
and the value is the version to use.
|
1271
|
+
libraries : Dict[str, str], default {}
|
1272
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1273
|
+
python : str, optional, default None
|
1274
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1275
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1276
|
+
disabled : bool, default False
|
1277
|
+
If set to True, disables Conda.
|
1355
1278
|
"""
|
1356
1279
|
...
|
1357
1280
|
|
1358
1281
|
@typing.overload
|
1359
|
-
def
|
1282
|
+
def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1283
|
+
...
|
1284
|
+
|
1285
|
+
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):
|
1360
1286
|
"""
|
1361
|
-
Specifies the
|
1362
|
-
|
1287
|
+
Specifies the Conda environment for all steps of the flow.
|
1288
|
+
|
1289
|
+
Use `@conda_base` to set common libraries required by all
|
1290
|
+
steps and use `@conda` to specify step-specific additions.
|
1363
1291
|
|
1364
1292
|
|
1365
1293
|
Parameters
|
1366
1294
|
----------
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1378
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1295
|
+
packages : Dict[str, str], default {}
|
1296
|
+
Packages to use for this flow. The key is the name of the package
|
1297
|
+
and the value is the version to use.
|
1298
|
+
libraries : Dict[str, str], default {}
|
1299
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1300
|
+
python : str, optional, default None
|
1301
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1302
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1303
|
+
disabled : bool, default False
|
1304
|
+
If set to True, disables Conda.
|
1379
1305
|
"""
|
1380
1306
|
...
|
1381
1307
|
|
1382
|
-
|
1383
|
-
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1384
|
-
...
|
1385
|
-
|
1386
|
-
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):
|
1308
|
+
def airflow_external_task_sensor(*, timeout: int, poke_interval: int, mode: str, exponential_backoff: bool, pool: str, soft_fail: bool, name: str, description: str, external_dag_id: str, external_task_ids: typing.List[str], allowed_states: typing.List[str], failed_states: typing.List[str], execution_delta: "datetime.timedelta", check_existence: bool) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1387
1309
|
"""
|
1388
|
-
|
1389
|
-
|
1310
|
+
The `@airflow_external_task_sensor` decorator attaches a Airflow [ExternalTaskSensor](https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/sensors/external_task/index.html#airflow.sensors.external_task.ExternalTaskSensor) before the start step of the flow.
|
1311
|
+
This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
|
1390
1312
|
|
1391
1313
|
|
1392
1314
|
Parameters
|
1393
1315
|
----------
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1316
|
+
timeout : int
|
1317
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1318
|
+
poke_interval : int
|
1319
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1320
|
+
mode : str
|
1321
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1322
|
+
exponential_backoff : bool
|
1323
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1324
|
+
pool : str
|
1325
|
+
the slot pool this task should run in,
|
1326
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1327
|
+
soft_fail : bool
|
1328
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1329
|
+
name : str
|
1330
|
+
Name of the sensor on Airflow
|
1331
|
+
description : str
|
1332
|
+
Description of sensor in the Airflow UI
|
1333
|
+
external_dag_id : str
|
1334
|
+
The dag_id that contains the task you want to wait for.
|
1335
|
+
external_task_ids : List[str]
|
1336
|
+
The list of task_ids that you want to wait for.
|
1337
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
1338
|
+
allowed_states : List[str]
|
1339
|
+
Iterable of allowed states, (Default: ['success'])
|
1340
|
+
failed_states : List[str]
|
1341
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
1342
|
+
execution_delta : datetime.timedelta
|
1343
|
+
time difference with the previous execution to look at,
|
1344
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
1345
|
+
check_existence: bool
|
1346
|
+
Set to True to check if the external task exists or check if
|
1347
|
+
the DAG to wait for exists. (Default: True)
|
1406
1348
|
"""
|
1407
1349
|
...
|
1408
1350
|
|
@@ -1520,6 +1462,57 @@ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None)
|
|
1520
1462
|
"""
|
1521
1463
|
...
|
1522
1464
|
|
1465
|
+
@typing.overload
|
1466
|
+
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]]:
|
1467
|
+
"""
|
1468
|
+
Specifies the times when the flow should be run when running on a
|
1469
|
+
production scheduler.
|
1470
|
+
|
1471
|
+
|
1472
|
+
Parameters
|
1473
|
+
----------
|
1474
|
+
hourly : bool, default False
|
1475
|
+
Run the workflow hourly.
|
1476
|
+
daily : bool, default True
|
1477
|
+
Run the workflow daily.
|
1478
|
+
weekly : bool, default False
|
1479
|
+
Run the workflow weekly.
|
1480
|
+
cron : str, optional, default None
|
1481
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1482
|
+
specified by this expression.
|
1483
|
+
timezone : str, optional, default None
|
1484
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1485
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1486
|
+
"""
|
1487
|
+
...
|
1488
|
+
|
1489
|
+
@typing.overload
|
1490
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1491
|
+
...
|
1492
|
+
|
1493
|
+
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):
|
1494
|
+
"""
|
1495
|
+
Specifies the times when the flow should be run when running on a
|
1496
|
+
production scheduler.
|
1497
|
+
|
1498
|
+
|
1499
|
+
Parameters
|
1500
|
+
----------
|
1501
|
+
hourly : bool, default False
|
1502
|
+
Run the workflow hourly.
|
1503
|
+
daily : bool, default True
|
1504
|
+
Run the workflow daily.
|
1505
|
+
weekly : bool, default False
|
1506
|
+
Run the workflow weekly.
|
1507
|
+
cron : str, optional, default None
|
1508
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1509
|
+
specified by this expression.
|
1510
|
+
timezone : str, optional, default None
|
1511
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1512
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1513
|
+
"""
|
1514
|
+
...
|
1515
|
+
|
1523
1516
|
@typing.overload
|
1524
1517
|
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1525
1518
|
"""
|
@@ -1561,49 +1554,6 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
|
|
1561
1554
|
"""
|
1562
1555
|
...
|
1563
1556
|
|
1564
|
-
def airflow_external_task_sensor(*, timeout: int, poke_interval: int, mode: str, exponential_backoff: bool, pool: str, soft_fail: bool, name: str, description: str, external_dag_id: str, external_task_ids: typing.List[str], allowed_states: typing.List[str], failed_states: typing.List[str], execution_delta: "datetime.timedelta", check_existence: bool) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1565
|
-
"""
|
1566
|
-
The `@airflow_external_task_sensor` decorator attaches a Airflow [ExternalTaskSensor](https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/sensors/external_task/index.html#airflow.sensors.external_task.ExternalTaskSensor) before the start step of the flow.
|
1567
|
-
This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
|
1568
|
-
|
1569
|
-
|
1570
|
-
Parameters
|
1571
|
-
----------
|
1572
|
-
timeout : int
|
1573
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
1574
|
-
poke_interval : int
|
1575
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
1576
|
-
mode : str
|
1577
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1578
|
-
exponential_backoff : bool
|
1579
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1580
|
-
pool : str
|
1581
|
-
the slot pool this task should run in,
|
1582
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1583
|
-
soft_fail : bool
|
1584
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1585
|
-
name : str
|
1586
|
-
Name of the sensor on Airflow
|
1587
|
-
description : str
|
1588
|
-
Description of sensor in the Airflow UI
|
1589
|
-
external_dag_id : str
|
1590
|
-
The dag_id that contains the task you want to wait for.
|
1591
|
-
external_task_ids : List[str]
|
1592
|
-
The list of task_ids that you want to wait for.
|
1593
|
-
If None (default value) the sensor waits for the DAG. (Default: None)
|
1594
|
-
allowed_states : List[str]
|
1595
|
-
Iterable of allowed states, (Default: ['success'])
|
1596
|
-
failed_states : List[str]
|
1597
|
-
Iterable of failed or dis-allowed states. (Default: None)
|
1598
|
-
execution_delta : datetime.timedelta
|
1599
|
-
time difference with the previous execution to look at,
|
1600
|
-
the default is the same logical date as the current task or DAG. (Default: None)
|
1601
|
-
check_existence: bool
|
1602
|
-
Set to True to check if the external task exists or check if
|
1603
|
-
the DAG to wait for exists. (Default: True)
|
1604
|
-
"""
|
1605
|
-
...
|
1606
|
-
|
1607
1557
|
def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, exponential_backoff: bool, pool: str, soft_fail: bool, name: str, description: str, bucket_key: typing.Union[str, typing.List[str]], bucket_name: str, wildcard_match: bool, aws_conn_id: str, verify: bool) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1608
1558
|
"""
|
1609
1559
|
The `@airflow_s3_key_sensor` decorator attaches a Airflow [S3KeySensor](https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_api/airflow/providers/amazon/aws/sensors/s3/index.html#airflow.providers.amazon.aws.sensors.s3.S3KeySensor)
|
@@ -1648,53 +1598,103 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
|
|
1648
1598
|
...
|
1649
1599
|
|
1650
1600
|
@typing.overload
|
1651
|
-
def
|
1601
|
+
def trigger_on_finish(*, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1652
1602
|
"""
|
1653
|
-
Specifies the
|
1603
|
+
Specifies the flow(s) that this flow depends on.
|
1654
1604
|
|
1655
|
-
|
1656
|
-
|
1605
|
+
```
|
1606
|
+
@trigger_on_finish(flow='FooFlow')
|
1607
|
+
```
|
1608
|
+
or
|
1609
|
+
```
|
1610
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1611
|
+
```
|
1612
|
+
This decorator respects the @project decorator and triggers the flow
|
1613
|
+
when upstream runs within the same namespace complete successfully
|
1614
|
+
|
1615
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1616
|
+
by specifying the fully qualified project_flow_name.
|
1617
|
+
```
|
1618
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1619
|
+
```
|
1620
|
+
or
|
1621
|
+
```
|
1622
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1623
|
+
```
|
1624
|
+
|
1625
|
+
You can also specify just the project or project branch (other values will be
|
1626
|
+
inferred from the current project or project branch):
|
1627
|
+
```
|
1628
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1629
|
+
```
|
1630
|
+
|
1631
|
+
Note that `branch` is typically one of:
|
1632
|
+
- `prod`
|
1633
|
+
- `user.bob`
|
1634
|
+
- `test.my_experiment`
|
1635
|
+
- `prod.staging`
|
1657
1636
|
|
1658
1637
|
|
1659
1638
|
Parameters
|
1660
1639
|
----------
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1668
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1669
|
-
disabled : bool, default False
|
1670
|
-
If set to True, disables Conda.
|
1640
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1641
|
+
Upstream flow dependency for this flow.
|
1642
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1643
|
+
Upstream flow dependencies for this flow.
|
1644
|
+
options : Dict[str, Any], default {}
|
1645
|
+
Backend-specific configuration for tuning eventing behavior.
|
1671
1646
|
"""
|
1672
1647
|
...
|
1673
1648
|
|
1674
1649
|
@typing.overload
|
1675
|
-
def
|
1650
|
+
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1676
1651
|
...
|
1677
1652
|
|
1678
|
-
def
|
1653
|
+
def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
|
1679
1654
|
"""
|
1680
|
-
Specifies the
|
1655
|
+
Specifies the flow(s) that this flow depends on.
|
1681
1656
|
|
1682
|
-
|
1683
|
-
|
1657
|
+
```
|
1658
|
+
@trigger_on_finish(flow='FooFlow')
|
1659
|
+
```
|
1660
|
+
or
|
1661
|
+
```
|
1662
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1663
|
+
```
|
1664
|
+
This decorator respects the @project decorator and triggers the flow
|
1665
|
+
when upstream runs within the same namespace complete successfully
|
1666
|
+
|
1667
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1668
|
+
by specifying the fully qualified project_flow_name.
|
1669
|
+
```
|
1670
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1671
|
+
```
|
1672
|
+
or
|
1673
|
+
```
|
1674
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1675
|
+
```
|
1676
|
+
|
1677
|
+
You can also specify just the project or project branch (other values will be
|
1678
|
+
inferred from the current project or project branch):
|
1679
|
+
```
|
1680
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1681
|
+
```
|
1682
|
+
|
1683
|
+
Note that `branch` is typically one of:
|
1684
|
+
- `prod`
|
1685
|
+
- `user.bob`
|
1686
|
+
- `test.my_experiment`
|
1687
|
+
- `prod.staging`
|
1684
1688
|
|
1685
1689
|
|
1686
1690
|
Parameters
|
1687
1691
|
----------
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1695
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1696
|
-
disabled : bool, default False
|
1697
|
-
If set to True, disables Conda.
|
1692
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1693
|
+
Upstream flow dependency for this flow.
|
1694
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1695
|
+
Upstream flow dependencies for this flow.
|
1696
|
+
options : Dict[str, Any], default {}
|
1697
|
+
Backend-specific configuration for tuning eventing behavior.
|
1698
1698
|
"""
|
1699
1699
|
...
|
1700
1700
|
|