ob-metaflow-stubs 6.0.3.170__py2.py3-none-any.whl → 6.0.3.172__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.
Files changed (209) hide show
  1. metaflow-stubs/__init__.pyi +645 -641
  2. metaflow-stubs/cards.pyi +1 -1
  3. metaflow-stubs/cli.pyi +1 -1
  4. metaflow-stubs/cli_components/__init__.pyi +1 -1
  5. metaflow-stubs/cli_components/utils.pyi +1 -1
  6. metaflow-stubs/client/__init__.pyi +1 -1
  7. metaflow-stubs/client/core.pyi +4 -4
  8. metaflow-stubs/client/filecache.pyi +2 -2
  9. metaflow-stubs/events.pyi +1 -1
  10. metaflow-stubs/exception.pyi +1 -1
  11. metaflow-stubs/flowspec.pyi +3 -3
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +2 -2
  14. metaflow-stubs/info_file.pyi +1 -1
  15. metaflow-stubs/metadata_provider/__init__.pyi +1 -1
  16. metaflow-stubs/metadata_provider/heartbeat.pyi +1 -1
  17. metaflow-stubs/metadata_provider/metadata.pyi +1 -1
  18. metaflow-stubs/metadata_provider/util.pyi +1 -1
  19. metaflow-stubs/metaflow_config.pyi +1 -1
  20. metaflow-stubs/metaflow_current.pyi +125 -125
  21. metaflow-stubs/metaflow_git.pyi +1 -1
  22. metaflow-stubs/mf_extensions/__init__.pyi +1 -1
  23. metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
  24. metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
  25. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
  26. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
  27. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
  28. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
  29. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +2 -2
  30. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +1 -1
  31. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
  32. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +3 -3
  33. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
  34. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +3 -3
  35. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
  36. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +2 -2
  38. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
  39. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +1 -1
  40. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +1 -1
  41. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +1 -1
  42. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +3 -3
  43. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +2 -2
  44. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +1 -1
  45. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +1 -1
  46. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +2 -2
  47. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
  48. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +1 -1
  49. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
  50. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
  51. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +2 -2
  52. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +1 -1
  53. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +2 -2
  54. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +1 -1
  55. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +2 -2
  56. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +1 -1
  57. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +1 -1
  58. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +1 -1
  59. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +2 -2
  60. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
  61. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
  62. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +1 -1
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +1 -1
  64. metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +1 -1
  65. metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
  66. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
  67. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
  68. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
  69. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
  70. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
  71. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
  72. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +12 -0
  73. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +30 -0
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +15 -7
  75. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
  76. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
  77. metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
  78. metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
  79. metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
  80. metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
  81. metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
  82. metaflow-stubs/multicore_utils.pyi +1 -1
  83. metaflow-stubs/parameters.pyi +2 -2
  84. metaflow-stubs/plugins/__init__.pyi +12 -11
  85. metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
  86. metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
  87. metaflow-stubs/plugins/airflow/exception.pyi +1 -1
  88. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
  89. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
  90. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
  91. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
  92. metaflow-stubs/plugins/argo/__init__.pyi +1 -1
  93. metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
  94. metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
  95. metaflow-stubs/plugins/argo/argo_workflows.pyi +1 -1
  96. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +2 -2
  97. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +1 -1
  98. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +1 -1
  99. metaflow-stubs/plugins/aws/__init__.pyi +1 -1
  100. metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
  101. metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
  102. metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
  103. metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
  104. metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
  105. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
  106. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
  107. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +1 -1
  108. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
  109. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
  110. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
  111. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
  112. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
  113. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +1 -1
  114. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +1 -1
  115. metaflow-stubs/plugins/azure/__init__.pyi +1 -1
  116. metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
  117. metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
  118. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +1 -1
  119. metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
  120. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
  121. metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
  122. metaflow-stubs/plugins/cards/__init__.pyi +1 -1
  123. metaflow-stubs/plugins/cards/card_client.pyi +2 -2
  124. metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
  125. metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
  126. metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
  127. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
  128. metaflow-stubs/plugins/cards/card_modules/basic.pyi +1 -1
  129. metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
  130. metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
  131. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
  132. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
  133. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
  134. metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
  135. metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
  136. metaflow-stubs/plugins/cards/exception.pyi +1 -1
  137. metaflow-stubs/plugins/catch_decorator.pyi +1 -1
  138. metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
  139. metaflow-stubs/plugins/datatools/local.pyi +1 -1
  140. metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
  141. metaflow-stubs/plugins/datatools/s3/s3.pyi +2 -2
  142. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
  143. metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
  144. metaflow-stubs/plugins/debug_logger.pyi +1 -1
  145. metaflow-stubs/plugins/debug_monitor.pyi +1 -1
  146. metaflow-stubs/plugins/environment_decorator.pyi +1 -1
  147. metaflow-stubs/plugins/events_decorator.pyi +1 -1
  148. metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
  149. metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
  150. metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
  151. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +1 -1
  152. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
  153. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
  154. metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
  155. metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
  156. metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
  157. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +1 -1
  158. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
  159. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
  160. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
  161. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
  162. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
  163. metaflow-stubs/plugins/ollama/__init__.pyi +18 -10
  164. metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
  165. metaflow-stubs/plugins/perimeters.pyi +1 -1
  166. metaflow-stubs/plugins/project_decorator.pyi +1 -1
  167. metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
  168. metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
  169. metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
  170. metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
  171. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
  172. metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
  173. metaflow-stubs/plugins/pypi/utils.pyi +1 -1
  174. metaflow-stubs/plugins/resources_decorator.pyi +1 -1
  175. metaflow-stubs/plugins/retry_decorator.pyi +1 -1
  176. metaflow-stubs/plugins/secrets/__init__.pyi +1 -1
  177. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +1 -1
  178. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
  179. metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
  180. metaflow-stubs/plugins/storage_executor.pyi +1 -1
  181. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +2 -2
  182. metaflow-stubs/plugins/timeout_decorator.pyi +1 -1
  183. metaflow-stubs/plugins/torchtune/__init__.pyi +39 -0
  184. metaflow-stubs/plugins/uv/__init__.pyi +1 -1
  185. metaflow-stubs/plugins/uv/uv_environment.pyi +2 -2
  186. metaflow-stubs/profilers/__init__.pyi +1 -1
  187. metaflow-stubs/pylint_wrapper.pyi +1 -1
  188. metaflow-stubs/runner/__init__.pyi +1 -1
  189. metaflow-stubs/runner/deployer.pyi +5 -5
  190. metaflow-stubs/runner/deployer_impl.pyi +2 -2
  191. metaflow-stubs/runner/metaflow_runner.pyi +1 -1
  192. metaflow-stubs/runner/nbdeploy.pyi +1 -1
  193. metaflow-stubs/runner/nbrun.pyi +1 -1
  194. metaflow-stubs/runner/subprocess_manager.pyi +1 -1
  195. metaflow-stubs/runner/utils.pyi +1 -1
  196. metaflow-stubs/system/__init__.pyi +1 -1
  197. metaflow-stubs/system/system_logger.pyi +2 -2
  198. metaflow-stubs/system/system_monitor.pyi +1 -1
  199. metaflow-stubs/tagging_util.pyi +1 -1
  200. metaflow-stubs/tuple_util.pyi +1 -1
  201. metaflow-stubs/user_configs/__init__.pyi +1 -1
  202. metaflow-stubs/user_configs/config_decorators.pyi +6 -6
  203. metaflow-stubs/user_configs/config_options.pyi +1 -1
  204. metaflow-stubs/user_configs/config_parameters.pyi +4 -4
  205. {ob_metaflow_stubs-6.0.3.170.dist-info → ob_metaflow_stubs-6.0.3.172.dist-info}/METADATA +1 -1
  206. ob_metaflow_stubs-6.0.3.172.dist-info/RECORD +209 -0
  207. ob_metaflow_stubs-6.0.3.170.dist-info/RECORD +0 -206
  208. {ob_metaflow_stubs-6.0.3.170.dist-info → ob_metaflow_stubs-6.0.3.172.dist-info}/WHEEL +0 -0
  209. {ob_metaflow_stubs-6.0.3.170.dist-info → ob_metaflow_stubs-6.0.3.172.dist-info}/top_level.txt +0 -0
@@ -1,15 +1,15 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
3
  # MF version: 2.15.14.1+obcheckpoint(0.2.1);ob(v1) #
4
- # Generated on 2025-05-22T07:40:40.319392 #
4
+ # Generated on 2025-05-27T03:43:23.657123 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
9
  import typing
10
10
  if typing.TYPE_CHECKING:
11
- import datetime
12
11
  import typing
12
+ import datetime
13
13
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
14
14
  StepFlag = typing.NewType("StepFlag", bool)
15
15
 
@@ -35,18 +35,18 @@ from .user_configs.config_parameters import ConfigValue as ConfigValue
35
35
  from .user_configs.config_parameters import config_expr as config_expr
36
36
  from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
37
37
  from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
38
+ from . import metaflow_git as metaflow_git
38
39
  from . import tuple_util as tuple_util
39
40
  from . import cards as cards
40
41
  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 requirements_txt_parser as requirements_txt_parser
48
47
  from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
49
48
  from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
49
+ from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_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
@@ -153,126 +153,141 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
153
153
  """
154
154
  ...
155
155
 
156
- 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]]]:
157
- """
158
- Decorator that helps cache, version and store models/datasets from huggingface hub.
159
-
160
-
161
- Parameters
162
- ----------
163
- temp_dir_root : str, optional
164
- The root directory that will hold the temporary directory where objects will be downloaded.
165
-
166
- load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
167
- The list of repos (models/datasets) to load.
168
-
169
- Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
170
-
171
- - If repo (model/dataset) is not found in the datastore:
172
- - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
173
- - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
174
- - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
175
-
176
- - If repo is found in the datastore:
177
- - Loads it directly from datastore to local path (can be temporary directory or specified path)
178
- """
179
- ...
180
-
181
156
  @typing.overload
182
- 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]]]:
157
+ 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]]]:
183
158
  """
184
- Specifies environment variables to be set prior to the execution of a step.
159
+ Specifies the Conda environment for the step.
160
+
161
+ Information in this decorator will augment any
162
+ attributes set in the `@conda_base` flow-level decorator. Hence,
163
+ you can use `@conda_base` to set packages required by all
164
+ steps and use `@conda` to specify step-specific overrides.
185
165
 
186
166
 
187
167
  Parameters
188
168
  ----------
189
- vars : Dict[str, str], default {}
190
- Dictionary of environment variables to set.
169
+ packages : Dict[str, str], default {}
170
+ Packages to use for this step. The key is the name of the package
171
+ and the value is the version to use.
172
+ libraries : Dict[str, str], default {}
173
+ Supported for backward compatibility. When used with packages, packages will take precedence.
174
+ python : str, optional, default None
175
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
176
+ that the version used will correspond to the version of the Python interpreter used to start the run.
177
+ disabled : bool, default False
178
+ If set to True, disables @conda.
191
179
  """
192
180
  ...
193
181
 
194
182
  @typing.overload
195
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
183
+ def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
196
184
  ...
197
185
 
198
186
  @typing.overload
199
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
187
+ def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
200
188
  ...
201
189
 
202
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
190
+ 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):
203
191
  """
204
- Specifies environment variables to be set prior to the execution of a step.
192
+ Specifies the Conda environment for the step.
193
+
194
+ Information in this decorator will augment any
195
+ attributes set in the `@conda_base` flow-level decorator. Hence,
196
+ you can use `@conda_base` to set packages required by all
197
+ steps and use `@conda` to specify step-specific overrides.
205
198
 
206
199
 
207
200
  Parameters
208
201
  ----------
209
- vars : Dict[str, str], default {}
210
- Dictionary of environment variables to set.
202
+ packages : Dict[str, str], default {}
203
+ Packages to use for this step. The key is the name of the package
204
+ and the value is the version to use.
205
+ libraries : Dict[str, str], default {}
206
+ Supported for backward compatibility. When used with packages, packages will take precedence.
207
+ python : str, optional, default None
208
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
209
+ that the version used will correspond to the version of the Python interpreter used to start the run.
210
+ disabled : bool, default False
211
+ If set to True, disables @conda.
211
212
  """
212
213
  ...
213
214
 
214
215
  @typing.overload
215
- def card(*, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
216
+ 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]]]:
216
217
  """
217
- Creates a human-readable report, a Metaflow Card, after this step completes.
218
+ Specifies the resources needed when executing this step.
218
219
 
219
- Note that you may add multiple `@card` decorators in a step with different parameters.
220
+ Use `@resources` to specify the resource requirements
221
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
222
+
223
+ You can choose the compute layer on the command line by executing e.g.
224
+ ```
225
+ python myflow.py run --with batch
226
+ ```
227
+ or
228
+ ```
229
+ python myflow.py run --with kubernetes
230
+ ```
231
+ which executes the flow on the desired system using the
232
+ requirements specified in `@resources`.
220
233
 
221
234
 
222
235
  Parameters
223
236
  ----------
224
- type : str, default 'default'
225
- Card type.
226
- id : str, optional, default None
227
- If multiple cards are present, use this id to identify this card.
228
- options : Dict[str, Any], default {}
229
- Options passed to the card. The contents depend on the card type.
230
- timeout : int, default 45
231
- Interrupt reporting if it takes more than this many seconds.
237
+ cpu : int, default 1
238
+ Number of CPUs required for this step.
239
+ gpu : int, optional, default None
240
+ Number of GPUs required for this step.
241
+ disk : int, optional, default None
242
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
243
+ memory : int, default 4096
244
+ Memory size (in MB) required for this step.
245
+ shared_memory : int, optional, default None
246
+ The value for the size (in MiB) of the /dev/shm volume for this step.
247
+ This parameter maps to the `--shm-size` option in Docker.
232
248
  """
233
249
  ...
234
250
 
235
251
  @typing.overload
236
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
252
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
237
253
  ...
238
254
 
239
255
  @typing.overload
240
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
256
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
241
257
  ...
242
258
 
243
- def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45):
259
+ 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):
244
260
  """
245
- Creates a human-readable report, a Metaflow Card, after this step completes.
246
-
247
- Note that you may add multiple `@card` decorators in a step with different parameters.
261
+ Specifies the resources needed when executing this step.
248
262
 
263
+ Use `@resources` to specify the resource requirements
264
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
249
265
 
250
- Parameters
251
- ----------
252
- type : str, default 'default'
253
- Card type.
254
- id : str, optional, default None
255
- If multiple cards are present, use this id to identify this card.
256
- options : Dict[str, Any], default {}
257
- Options passed to the card. The contents depend on the card type.
258
- timeout : int, default 45
259
- Interrupt reporting if it takes more than this many seconds.
260
- """
261
- ...
262
-
263
- 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]]]:
264
- """
265
- Specifies that this step should execute on DGX cloud.
266
+ You can choose the compute layer on the command line by executing e.g.
267
+ ```
268
+ python myflow.py run --with batch
269
+ ```
270
+ or
271
+ ```
272
+ python myflow.py run --with kubernetes
273
+ ```
274
+ which executes the flow on the desired system using the
275
+ requirements specified in `@resources`.
266
276
 
267
277
 
268
278
  Parameters
269
279
  ----------
270
- gpu : int
271
- Number of GPUs to use.
272
- gpu_type : str
273
- Type of Nvidia GPU to use.
274
- queue_timeout : int
275
- Time to keep the job in NVCF's queue.
280
+ cpu : int, default 1
281
+ Number of CPUs required for this step.
282
+ gpu : int, optional, default None
283
+ Number of GPUs required for this step.
284
+ disk : int, optional, default None
285
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
286
+ memory : int, default 4096
287
+ Memory size (in MB) required for this step.
288
+ shared_memory : int, optional, default None
289
+ The value for the size (in MiB) of the /dev/shm volume for this step.
290
+ This parameter maps to the `--shm-size` option in Docker.
276
291
  """
277
292
  ...
278
293
 
@@ -334,172 +349,142 @@ def model(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
334
349
  ...
335
350
 
336
351
  @typing.overload
337
- def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> 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]]]:
352
+ 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]]]:
338
353
  """
339
- Specifies secrets to be retrieved and injected as environment variables prior to
340
- the execution of a step.
354
+ Specifies the number of times the task corresponding
355
+ to a step needs to be retried.
356
+
357
+ This decorator is useful for handling transient errors, such as networking issues.
358
+ If your task contains operations that can't be retried safely, e.g. database updates,
359
+ it is advisable to annotate it with `@retry(times=0)`.
360
+
361
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
362
+ decorator will execute a no-op task after all retries have been exhausted,
363
+ ensuring that the flow execution can continue.
341
364
 
342
365
 
343
366
  Parameters
344
367
  ----------
345
- sources : List[Union[str, Dict[str, Any]]], default: []
346
- List of secret specs, defining how the secrets are to be retrieved
368
+ times : int, default 3
369
+ Number of times to retry this task.
370
+ minutes_between_retries : int, default 2
371
+ Number of minutes between retries.
347
372
  """
348
373
  ...
349
374
 
350
375
  @typing.overload
351
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
376
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
352
377
  ...
353
378
 
354
379
  @typing.overload
355
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
356
- ...
357
-
358
- 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]]] = []):
359
- """
360
- Specifies secrets to be retrieved and injected as environment variables prior to
361
- the execution of a step.
362
-
363
-
364
- Parameters
365
- ----------
366
- sources : List[Union[str, Dict[str, Any]]], default: []
367
- List of secret specs, defining how the secrets are to be retrieved
368
- """
380
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
369
381
  ...
370
382
 
371
- @typing.overload
372
- 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]]]:
383
+ 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):
373
384
  """
374
- Specifies a timeout for your step.
375
-
376
- This decorator is useful if this step may hang indefinitely.
385
+ Specifies the number of times the task corresponding
386
+ to a step needs to be retried.
377
387
 
378
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
379
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
380
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
388
+ This decorator is useful for handling transient errors, such as networking issues.
389
+ If your task contains operations that can't be retried safely, e.g. database updates,
390
+ it is advisable to annotate it with `@retry(times=0)`.
381
391
 
382
- Note that all the values specified in parameters are added together so if you specify
383
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
392
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
393
+ decorator will execute a no-op task after all retries have been exhausted,
394
+ ensuring that the flow execution can continue.
384
395
 
385
396
 
386
397
  Parameters
387
398
  ----------
388
- seconds : int, default 0
389
- Number of seconds to wait prior to timing out.
390
- minutes : int, default 0
391
- Number of minutes to wait prior to timing out.
392
- hours : int, default 0
393
- Number of hours to wait prior to timing out.
399
+ times : int, default 3
400
+ Number of times to retry this task.
401
+ minutes_between_retries : int, default 2
402
+ Number of minutes between retries.
394
403
  """
395
404
  ...
396
405
 
397
- @typing.overload
398
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
399
- ...
400
-
401
- @typing.overload
402
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
403
- ...
404
-
405
- 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):
406
+ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
406
407
  """
407
- Specifies a timeout for your step.
408
-
409
- This decorator is useful if this step may hang indefinitely.
410
-
411
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
412
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
413
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
414
-
415
- Note that all the values specified in parameters are added together so if you specify
416
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
408
+ Specifies that this step should execute on Kubernetes.
417
409
 
418
410
 
419
411
  Parameters
420
412
  ----------
421
- seconds : int, default 0
422
- Number of seconds to wait prior to timing out.
423
- minutes : int, default 0
424
- Number of minutes to wait prior to timing out.
425
- hours : int, default 0
426
- Number of hours to wait prior to timing out.
427
- """
428
- ...
429
-
430
- @typing.overload
431
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
432
- """
433
- Internal decorator to support Fast bakery
434
- """
435
- ...
436
-
437
- @typing.overload
438
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
439
- ...
440
-
441
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
442
- """
443
- Internal decorator to support Fast bakery
444
- """
445
- ...
446
-
447
- @typing.overload
448
- 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]]]:
449
- """
450
- Specifies the Conda environment for the step.
451
-
452
- Information in this decorator will augment any
453
- attributes set in the `@conda_base` flow-level decorator. Hence,
454
- you can use `@conda_base` to set packages required by all
455
- steps and use `@conda` to specify step-specific overrides.
456
-
457
-
458
- Parameters
459
- ----------
460
- packages : Dict[str, str], default {}
461
- Packages to use for this step. The key is the name of the package
462
- and the value is the version to use.
463
- libraries : Dict[str, str], default {}
464
- Supported for backward compatibility. When used with packages, packages will take precedence.
465
- python : str, optional, default None
466
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
467
- that the version used will correspond to the version of the Python interpreter used to start the run.
468
- disabled : bool, default False
469
- If set to True, disables @conda.
470
- """
471
- ...
472
-
473
- @typing.overload
474
- def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
475
- ...
476
-
477
- @typing.overload
478
- def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
479
- ...
480
-
481
- 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):
482
- """
483
- Specifies the Conda environment for the step.
484
-
485
- Information in this decorator will augment any
486
- attributes set in the `@conda_base` flow-level decorator. Hence,
487
- you can use `@conda_base` to set packages required by all
488
- steps and use `@conda` to specify step-specific overrides.
489
-
413
+ cpu : int, default 1
414
+ Number of CPUs required for this step. If `@resources` is
415
+ also present, the maximum value from all decorators is used.
416
+ memory : int, default 4096
417
+ Memory size (in MB) required for this step. If
418
+ `@resources` is also present, the maximum value from all decorators is
419
+ used.
420
+ disk : int, default 10240
421
+ Disk size (in MB) required for this step. If
422
+ `@resources` is also present, the maximum value from all decorators is
423
+ used.
424
+ image : str, optional, default None
425
+ Docker image to use when launching on Kubernetes. If not specified, and
426
+ METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
427
+ not, a default Docker image mapping to the current version of Python is used.
428
+ image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
429
+ If given, the imagePullPolicy to be applied to the Docker image of the step.
430
+ service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
431
+ Kubernetes service account to use when launching pod in Kubernetes.
432
+ secrets : List[str], optional, default None
433
+ Kubernetes secrets to use when launching pod in Kubernetes. These
434
+ secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
435
+ in Metaflow configuration.
436
+ node_selector: Union[Dict[str,str], str], optional, default None
437
+ Kubernetes node selector(s) to apply to the pod running the task.
438
+ Can be passed in as a comma separated string of values e.g.
439
+ 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
440
+ {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
441
+ namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
442
+ Kubernetes namespace to use when launching pod in Kubernetes.
443
+ gpu : int, optional, default None
444
+ Number of GPUs required for this step. A value of zero implies that
445
+ the scheduled node should not have GPUs.
446
+ gpu_vendor : str, default KUBERNETES_GPU_VENDOR
447
+ The vendor of the GPUs to be used for this step.
448
+ tolerations : List[str], default []
449
+ The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
450
+ Kubernetes tolerations to use when launching pod in Kubernetes.
451
+ labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
452
+ Kubernetes labels to use when launching pod in Kubernetes.
453
+ annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
454
+ Kubernetes annotations to use when launching pod in Kubernetes.
455
+ use_tmpfs : bool, default False
456
+ This enables an explicit tmpfs mount for this step.
457
+ tmpfs_tempdir : bool, default True
458
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
459
+ tmpfs_size : int, optional, default: None
460
+ The value for the size (in MiB) of the tmpfs mount for this step.
461
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
462
+ memory allocated for this step.
463
+ tmpfs_path : str, optional, default /metaflow_temp
464
+ Path to tmpfs mount for this step.
465
+ persistent_volume_claims : Dict[str, str], optional, default None
466
+ A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
467
+ volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
468
+ shared_memory: int, optional
469
+ Shared memory size (in MiB) required for this step
470
+ port: int, optional
471
+ Port number to specify in the Kubernetes job object
472
+ compute_pool : str, optional, default None
473
+ Compute pool to be used for for this step.
474
+ If not specified, any accessible compute pool within the perimeter is used.
475
+ hostname_resolution_timeout: int, default 10 * 60
476
+ Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
477
+ Only applicable when @parallel is used.
478
+ qos: str, default: Burstable
479
+ Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
490
480
 
491
- Parameters
492
- ----------
493
- packages : Dict[str, str], default {}
494
- Packages to use for this step. The key is the name of the package
495
- and the value is the version to use.
496
- libraries : Dict[str, str], default {}
497
- Supported for backward compatibility. When used with packages, packages will take precedence.
498
- python : str, optional, default None
499
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
500
- that the version used will correspond to the version of the Python interpreter used to start the run.
501
- disabled : bool, default False
502
- If set to True, disables @conda.
481
+ security_context: Dict[str, Any], optional, default None
482
+ Container security context. Applies to the task container. Allows the following keys:
483
+ - privileged: bool, optional, default None
484
+ - allow_privilege_escalation: bool, optional, default None
485
+ - run_as_user: int, optional, default None
486
+ - run_as_group: int, optional, default None
487
+ - run_as_non_root: bool, optional, default None
503
488
  """
504
489
  ...
505
490
 
@@ -555,57 +540,132 @@ def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
555
540
  ...
556
541
 
557
542
  @typing.overload
558
- 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]]]:
543
+ 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]]]:
559
544
  """
560
- Specifies the number of times the task corresponding
561
- to a step needs to be retried.
545
+ Enables checkpointing for a step.
562
546
 
563
- This decorator is useful for handling transient errors, such as networking issues.
564
- If your task contains operations that can't be retried safely, e.g. database updates,
565
- it is advisable to annotate it with `@retry(times=0)`.
566
547
 
567
- This can be used in conjunction with the `@catch` decorator. The `@catch`
568
- decorator will execute a no-op task after all retries have been exhausted,
569
- ensuring that the flow execution can continue.
548
+
549
+ Parameters
550
+ ----------
551
+ load_policy : str, default: "fresh"
552
+ The policy for loading the checkpoint. The following policies are supported:
553
+ - "eager": Loads the the latest available checkpoint within the namespace.
554
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
555
+ will be loaded at the start of the task.
556
+ - "none": Do not load any checkpoint
557
+ - "fresh": Loads the lastest checkpoint created within the running Task.
558
+ This mode helps loading checkpoints across various retry attempts of the same task.
559
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
560
+ created within the task will be loaded when the task is retries execution on failure.
561
+
562
+ temp_dir_root : str, default: None
563
+ The root directory under which `current.checkpoint.directory` will be created.
564
+ """
565
+ ...
566
+
567
+ @typing.overload
568
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
569
+ ...
570
+
571
+ @typing.overload
572
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
573
+ ...
574
+
575
+ 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):
576
+ """
577
+ Enables checkpointing for a step.
578
+
570
579
 
571
580
 
572
581
  Parameters
573
582
  ----------
574
- times : int, default 3
575
- Number of times to retry this task.
576
- minutes_between_retries : int, default 2
577
- Number of minutes between retries.
583
+ load_policy : str, default: "fresh"
584
+ The policy for loading the checkpoint. The following policies are supported:
585
+ - "eager": Loads the the latest available checkpoint within the namespace.
586
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
587
+ will be loaded at the start of the task.
588
+ - "none": Do not load any checkpoint
589
+ - "fresh": Loads the lastest checkpoint created within the running Task.
590
+ This mode helps loading checkpoints across various retry attempts of the same task.
591
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
592
+ created within the task will be loaded when the task is retries execution on failure.
593
+
594
+ temp_dir_root : str, default: None
595
+ The root directory under which `current.checkpoint.directory` will be created.
596
+ """
597
+ ...
598
+
599
+ def app_deploy(*, app_port: int, app_name: 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]]]:
600
+ """
601
+ Specifies that this step is used to deploy an instance of the app.
602
+ Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
603
+
604
+
605
+ Parameters
606
+ ----------
607
+ app_port : int
608
+ Number of GPUs to use.
609
+ app_name : str
610
+ Name of the app to deploy.
578
611
  """
579
612
  ...
580
613
 
581
614
  @typing.overload
582
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
615
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
616
+ """
617
+ Internal decorator to support Fast bakery
618
+ """
583
619
  ...
584
620
 
585
621
  @typing.overload
586
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
622
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
587
623
  ...
588
624
 
589
- def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, times: int = 3, minutes_between_retries: int = 2):
625
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
590
626
  """
591
- Specifies the number of times the task corresponding
592
- to a step needs to be retried.
627
+ Internal decorator to support Fast bakery
628
+ """
629
+ ...
630
+
631
+ 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]]]:
632
+ """
633
+ Specifies that this step should execute on DGX cloud.
593
634
 
594
- This decorator is useful for handling transient errors, such as networking issues.
595
- If your task contains operations that can't be retried safely, e.g. database updates,
596
- it is advisable to annotate it with `@retry(times=0)`.
597
635
 
598
- This can be used in conjunction with the `@catch` decorator. The `@catch`
599
- decorator will execute a no-op task after all retries have been exhausted,
600
- ensuring that the flow execution can continue.
636
+ Parameters
637
+ ----------
638
+ gpu : int
639
+ Number of GPUs to use.
640
+ gpu_type : str
641
+ Type of Nvidia GPU to use.
642
+ queue_timeout : int
643
+ Time to keep the job in NVCF's queue.
644
+ """
645
+ ...
646
+
647
+ 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]]]:
648
+ """
649
+ Decorator that helps cache, version and store models/datasets from huggingface hub.
601
650
 
602
651
 
603
652
  Parameters
604
653
  ----------
605
- times : int, default 3
606
- Number of times to retry this task.
607
- minutes_between_retries : int, default 2
608
- Number of minutes between retries.
654
+ temp_dir_root : str, optional
655
+ The root directory that will hold the temporary directory where objects will be downloaded.
656
+
657
+ load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
658
+ The list of repos (models/datasets) to load.
659
+
660
+ Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
661
+
662
+ - If repo (model/dataset) is not found in the datastore:
663
+ - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
664
+ - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
665
+ - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
666
+
667
+ - If repo is found in the datastore:
668
+ - Loads it directly from datastore to local path (can be temporary directory or specified path)
609
669
  """
610
670
  ...
611
671
 
@@ -660,29 +720,15 @@ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
660
720
  """
661
721
  ...
662
722
 
663
- 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]]]:
664
- """
665
- Specifies that this step should execute on DGX cloud.
666
-
667
-
668
- Parameters
669
- ----------
670
- gpu : int
671
- Number of GPUs to use.
672
- gpu_type : str
673
- Type of Nvidia GPU to use.
674
- """
675
- ...
676
-
677
- def ollama(*, models: "list[Ollama]", backend: 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]]]:
723
+ def ollama(*, models: list, backend: str, force_pull: bool, skip_push_check: bool, debug: bool) -> 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]]]:
678
724
  """
679
725
  This decorator is used to run Ollama APIs as Metaflow task sidecars.
680
726
 
681
727
  User code call
682
- -----------
728
+ --------------
683
729
  @ollama(
684
- models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
685
- backend='local'
730
+ models=[...],
731
+ ...
686
732
  )
687
733
 
688
734
  Valid backend options
@@ -692,97 +738,71 @@ def ollama(*, models: "list[Ollama]", backend: str) -> typing.Callable[[typing.U
692
738
  - (TODO) 'remote': Spin up separate instance to serve Ollama models.
693
739
 
694
740
  Valid model options
695
- ----------------
696
- - 'llama3.2'
697
- - 'llama3.3'
698
- - any model here https://ollama.com/search
741
+ -------------------
742
+ Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
699
743
 
700
744
 
701
745
  Parameters
702
746
  ----------
703
- models: list[Ollama]
747
+ models: list[str]
704
748
  List of Ollama containers running models in sidecars.
705
749
  backend: str
706
750
  Determines where and how to run the Ollama process.
751
+ force_pull: bool
752
+ Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
753
+ skip_push_check: bool
754
+ Whether to skip the check that populates/overwrites remote cache on terminating an ollama model.
755
+ debug: bool
756
+ Whether to turn on verbose debugging logs.
707
757
  """
708
758
  ...
709
759
 
710
- @typing.overload
711
- 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]]]:
760
+ 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]]]:
712
761
  """
713
- Specifies the resources needed when executing this step.
762
+ Specifies that this step should execute on DGX cloud.
714
763
 
715
- Use `@resources` to specify the resource requirements
716
- independently of the specific compute layer (`@batch`, `@kubernetes`).
717
764
 
718
- You can choose the compute layer on the command line by executing e.g.
719
- ```
720
- python myflow.py run --with batch
721
- ```
722
- or
723
- ```
724
- python myflow.py run --with kubernetes
725
- ```
726
- which executes the flow on the desired system using the
727
- requirements specified in `@resources`.
765
+ Parameters
766
+ ----------
767
+ gpu : int
768
+ Number of GPUs to use.
769
+ gpu_type : str
770
+ Type of Nvidia GPU to use.
771
+ """
772
+ ...
773
+
774
+ @typing.overload
775
+ def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> 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]]]:
776
+ """
777
+ Specifies secrets to be retrieved and injected as environment variables prior to
778
+ the execution of a step.
728
779
 
729
780
 
730
781
  Parameters
731
782
  ----------
732
- cpu : int, default 1
733
- Number of CPUs required for this step.
734
- gpu : int, optional, default None
735
- Number of GPUs required for this step.
736
- disk : int, optional, default None
737
- Disk size (in MB) required for this step. Only applies on Kubernetes.
738
- memory : int, default 4096
739
- Memory size (in MB) required for this step.
740
- shared_memory : int, optional, default None
741
- The value for the size (in MiB) of the /dev/shm volume for this step.
742
- This parameter maps to the `--shm-size` option in Docker.
783
+ sources : List[Union[str, Dict[str, Any]]], default: []
784
+ List of secret specs, defining how the secrets are to be retrieved
743
785
  """
744
786
  ...
745
787
 
746
788
  @typing.overload
747
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
789
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
748
790
  ...
749
791
 
750
792
  @typing.overload
751
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
793
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
752
794
  ...
753
795
 
754
- 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):
796
+ 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]]] = []):
755
797
  """
756
- Specifies the resources needed when executing this step.
757
-
758
- Use `@resources` to specify the resource requirements
759
- independently of the specific compute layer (`@batch`, `@kubernetes`).
760
-
761
- You can choose the compute layer on the command line by executing e.g.
762
- ```
763
- python myflow.py run --with batch
764
- ```
765
- or
766
- ```
767
- python myflow.py run --with kubernetes
768
- ```
769
- which executes the flow on the desired system using the
770
- requirements specified in `@resources`.
798
+ Specifies secrets to be retrieved and injected as environment variables prior to
799
+ the execution of a step.
771
800
 
772
801
 
773
802
  Parameters
774
803
  ----------
775
- cpu : int, default 1
776
- Number of CPUs required for this step.
777
- gpu : int, optional, default None
778
- Number of GPUs required for this step.
779
- disk : int, optional, default None
780
- Disk size (in MB) required for this step. Only applies on Kubernetes.
781
- memory : int, default 4096
782
- Memory size (in MB) required for this step.
783
- shared_memory : int, optional, default None
784
- The value for the size (in MiB) of the /dev/shm volume for this step.
785
- This parameter maps to the `--shm-size` option in Docker.
804
+ sources : List[Union[str, Dict[str, Any]]], default: []
805
+ List of secret specs, defining how the secrets are to be retrieved
786
806
  """
787
807
  ...
788
808
 
@@ -805,253 +825,195 @@ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
805
825
  """
806
826
  ...
807
827
 
808
- def app_deploy(*, app_port: int, app_name: 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]]]:
828
+ @typing.overload
829
+ def card(*, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
809
830
  """
810
- Specifies that this step is used to deploy an instance of the app.
811
- Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
831
+ Creates a human-readable report, a Metaflow Card, after this step completes.
832
+
833
+ Note that you may add multiple `@card` decorators in a step with different parameters.
812
834
 
813
835
 
814
836
  Parameters
815
837
  ----------
816
- app_port : int
817
- Number of GPUs to use.
818
- app_name : str
819
- Name of the app to deploy.
838
+ type : str, default 'default'
839
+ Card type.
840
+ id : str, optional, default None
841
+ If multiple cards are present, use this id to identify this card.
842
+ options : Dict[str, Any], default {}
843
+ Options passed to the card. The contents depend on the card type.
844
+ timeout : int, default 45
845
+ Interrupt reporting if it takes more than this many seconds.
820
846
  """
821
847
  ...
822
848
 
823
849
  @typing.overload
824
- 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]]]:
850
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
851
+ ...
852
+
853
+ @typing.overload
854
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
855
+ ...
856
+
857
+ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45):
825
858
  """
826
- Enables checkpointing for a step.
859
+ Creates a human-readable report, a Metaflow Card, after this step completes.
827
860
 
861
+ Note that you may add multiple `@card` decorators in a step with different parameters.
828
862
 
829
863
 
830
864
  Parameters
831
865
  ----------
832
- load_policy : str, default: "fresh"
833
- The policy for loading the checkpoint. The following policies are supported:
834
- - "eager": Loads the the latest available checkpoint within the namespace.
835
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
836
- will be loaded at the start of the task.
837
- - "none": Do not load any checkpoint
838
- - "fresh": Loads the lastest checkpoint created within the running Task.
839
- This mode helps loading checkpoints across various retry attempts of the same task.
840
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
841
- created within the task will be loaded when the task is retries execution on failure.
866
+ type : str, default 'default'
867
+ Card type.
868
+ id : str, optional, default None
869
+ If multiple cards are present, use this id to identify this card.
870
+ options : Dict[str, Any], default {}
871
+ Options passed to the card. The contents depend on the card type.
872
+ timeout : int, default 45
873
+ Interrupt reporting if it takes more than this many seconds.
874
+ """
875
+ ...
876
+
877
+ @typing.overload
878
+ 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]]]:
879
+ """
880
+ Specifies environment variables to be set prior to the execution of a step.
842
881
 
843
- temp_dir_root : str, default: None
844
- The root directory under which `current.checkpoint.directory` will be created.
882
+
883
+ Parameters
884
+ ----------
885
+ vars : Dict[str, str], default {}
886
+ Dictionary of environment variables to set.
845
887
  """
846
888
  ...
847
889
 
848
890
  @typing.overload
849
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
891
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
850
892
  ...
851
893
 
852
894
  @typing.overload
853
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
895
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
896
+ ...
897
+
898
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
899
+ """
900
+ Specifies environment variables to be set prior to the execution of a step.
901
+
902
+
903
+ Parameters
904
+ ----------
905
+ vars : Dict[str, str], default {}
906
+ Dictionary of environment variables to set.
907
+ """
908
+ ...
909
+
910
+ @typing.overload
911
+ 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]]]:
912
+ """
913
+ Specifies a timeout for your step.
914
+
915
+ This decorator is useful if this step may hang indefinitely.
916
+
917
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
918
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
919
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
920
+
921
+ Note that all the values specified in parameters are added together so if you specify
922
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
923
+
924
+
925
+ Parameters
926
+ ----------
927
+ seconds : int, default 0
928
+ Number of seconds to wait prior to timing out.
929
+ minutes : int, default 0
930
+ Number of minutes to wait prior to timing out.
931
+ hours : int, default 0
932
+ Number of hours to wait prior to timing out.
933
+ """
934
+ ...
935
+
936
+ @typing.overload
937
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
938
+ ...
939
+
940
+ @typing.overload
941
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
854
942
  ...
855
943
 
856
- 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):
944
+ 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):
857
945
  """
858
- Enables checkpointing for a step.
859
-
946
+ Specifies a timeout for your step.
860
947
 
948
+ This decorator is useful if this step may hang indefinitely.
861
949
 
862
- Parameters
863
- ----------
864
- load_policy : str, default: "fresh"
865
- The policy for loading the checkpoint. The following policies are supported:
866
- - "eager": Loads the the latest available checkpoint within the namespace.
867
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
868
- will be loaded at the start of the task.
869
- - "none": Do not load any checkpoint
870
- - "fresh": Loads the lastest checkpoint created within the running Task.
871
- This mode helps loading checkpoints across various retry attempts of the same task.
872
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
873
- created within the task will be loaded when the task is retries execution on failure.
950
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
951
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
952
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
874
953
 
875
- temp_dir_root : str, default: None
876
- The root directory under which `current.checkpoint.directory` will be created.
877
- """
878
- ...
879
-
880
- def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
881
- """
882
- Specifies that this step should execute on Kubernetes.
954
+ Note that all the values specified in parameters are added together so if you specify
955
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
883
956
 
884
957
 
885
958
  Parameters
886
959
  ----------
887
- cpu : int, default 1
888
- Number of CPUs required for this step. If `@resources` is
889
- also present, the maximum value from all decorators is used.
890
- memory : int, default 4096
891
- Memory size (in MB) required for this step. If
892
- `@resources` is also present, the maximum value from all decorators is
893
- used.
894
- disk : int, default 10240
895
- Disk size (in MB) required for this step. If
896
- `@resources` is also present, the maximum value from all decorators is
897
- used.
898
- image : str, optional, default None
899
- Docker image to use when launching on Kubernetes. If not specified, and
900
- METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
901
- not, a default Docker image mapping to the current version of Python is used.
902
- image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
903
- If given, the imagePullPolicy to be applied to the Docker image of the step.
904
- service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
905
- Kubernetes service account to use when launching pod in Kubernetes.
906
- secrets : List[str], optional, default None
907
- Kubernetes secrets to use when launching pod in Kubernetes. These
908
- secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
909
- in Metaflow configuration.
910
- node_selector: Union[Dict[str,str], str], optional, default None
911
- Kubernetes node selector(s) to apply to the pod running the task.
912
- Can be passed in as a comma separated string of values e.g.
913
- 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
914
- {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
915
- namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
916
- Kubernetes namespace to use when launching pod in Kubernetes.
917
- gpu : int, optional, default None
918
- Number of GPUs required for this step. A value of zero implies that
919
- the scheduled node should not have GPUs.
920
- gpu_vendor : str, default KUBERNETES_GPU_VENDOR
921
- The vendor of the GPUs to be used for this step.
922
- tolerations : List[str], default []
923
- The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
924
- Kubernetes tolerations to use when launching pod in Kubernetes.
925
- labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
926
- Kubernetes labels to use when launching pod in Kubernetes.
927
- annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
928
- Kubernetes annotations to use when launching pod in Kubernetes.
929
- use_tmpfs : bool, default False
930
- This enables an explicit tmpfs mount for this step.
931
- tmpfs_tempdir : bool, default True
932
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
933
- tmpfs_size : int, optional, default: None
934
- The value for the size (in MiB) of the tmpfs mount for this step.
935
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
936
- memory allocated for this step.
937
- tmpfs_path : str, optional, default /metaflow_temp
938
- Path to tmpfs mount for this step.
939
- persistent_volume_claims : Dict[str, str], optional, default None
940
- A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
941
- volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
942
- shared_memory: int, optional
943
- Shared memory size (in MiB) required for this step
944
- port: int, optional
945
- Port number to specify in the Kubernetes job object
946
- compute_pool : str, optional, default None
947
- Compute pool to be used for for this step.
948
- If not specified, any accessible compute pool within the perimeter is used.
949
- hostname_resolution_timeout: int, default 10 * 60
950
- Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
951
- Only applicable when @parallel is used.
952
- qos: str, default: Burstable
953
- Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
954
-
955
- security_context: Dict[str, Any], optional, default None
956
- Container security context. Applies to the task container. Allows the following keys:
957
- - privileged: bool, optional, default None
958
- - allow_privilege_escalation: bool, optional, default None
959
- - run_as_user: int, optional, default None
960
- - run_as_group: int, optional, default None
961
- - run_as_non_root: bool, optional, default None
960
+ seconds : int, default 0
961
+ Number of seconds to wait prior to timing out.
962
+ minutes : int, default 0
963
+ Number of minutes to wait prior to timing out.
964
+ hours : int, default 0
965
+ Number of hours to wait prior to timing out.
962
966
  """
963
967
  ...
964
968
 
965
969
  @typing.overload
966
- def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
970
+ 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]]:
967
971
  """
968
- Specifies the event(s) that this flow depends on.
969
-
970
- ```
971
- @trigger(event='foo')
972
- ```
973
- or
974
- ```
975
- @trigger(events=['foo', 'bar'])
976
- ```
977
-
978
- Additionally, you can specify the parameter mappings
979
- to map event payload to Metaflow parameters for the flow.
980
- ```
981
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
982
- ```
983
- or
984
- ```
985
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
986
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
987
- ```
972
+ Specifies the Conda environment for all steps of the flow.
988
973
 
989
- 'parameters' can also be a list of strings and tuples like so:
990
- ```
991
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
992
- ```
993
- This is equivalent to:
994
- ```
995
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
996
- ```
974
+ Use `@conda_base` to set common libraries required by all
975
+ steps and use `@conda` to specify step-specific additions.
997
976
 
998
977
 
999
978
  Parameters
1000
979
  ----------
1001
- event : Union[str, Dict[str, Any]], optional, default None
1002
- Event dependency for this flow.
1003
- events : List[Union[str, Dict[str, Any]]], default []
1004
- Events dependency for this flow.
1005
- options : Dict[str, Any], default {}
1006
- Backend-specific configuration for tuning eventing behavior.
980
+ packages : Dict[str, str], default {}
981
+ Packages to use for this flow. The key is the name of the package
982
+ and the value is the version to use.
983
+ libraries : Dict[str, str], default {}
984
+ Supported for backward compatibility. When used with packages, packages will take precedence.
985
+ python : str, optional, default None
986
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
987
+ that the version used will correspond to the version of the Python interpreter used to start the run.
988
+ disabled : bool, default False
989
+ If set to True, disables Conda.
1007
990
  """
1008
991
  ...
1009
992
 
1010
993
  @typing.overload
1011
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
994
+ def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1012
995
  ...
1013
996
 
1014
- def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
997
+ 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):
1015
998
  """
1016
- Specifies the event(s) that this flow depends on.
1017
-
1018
- ```
1019
- @trigger(event='foo')
1020
- ```
1021
- or
1022
- ```
1023
- @trigger(events=['foo', 'bar'])
1024
- ```
1025
-
1026
- Additionally, you can specify the parameter mappings
1027
- to map event payload to Metaflow parameters for the flow.
1028
- ```
1029
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1030
- ```
1031
- or
1032
- ```
1033
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1034
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1035
- ```
999
+ Specifies the Conda environment for all steps of the flow.
1036
1000
 
1037
- 'parameters' can also be a list of strings and tuples like so:
1038
- ```
1039
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1040
- ```
1041
- This is equivalent to:
1042
- ```
1043
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1044
- ```
1001
+ Use `@conda_base` to set common libraries required by all
1002
+ steps and use `@conda` to specify step-specific additions.
1045
1003
 
1046
1004
 
1047
1005
  Parameters
1048
1006
  ----------
1049
- event : Union[str, Dict[str, Any]], optional, default None
1050
- Event dependency for this flow.
1051
- events : List[Union[str, Dict[str, Any]]], default []
1052
- Events dependency for this flow.
1053
- options : Dict[str, Any], default {}
1054
- Backend-specific configuration for tuning eventing behavior.
1007
+ packages : Dict[str, str], default {}
1008
+ Packages to use for this flow. The key is the name of the package
1009
+ and the value is the version to use.
1010
+ libraries : Dict[str, str], default {}
1011
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1012
+ python : str, optional, default None
1013
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1014
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1015
+ disabled : bool, default False
1016
+ If set to True, disables Conda.
1055
1017
  """
1056
1018
  ...
1057
1019
 
@@ -1169,6 +1131,84 @@ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None)
1169
1131
  """
1170
1132
  ...
1171
1133
 
1134
+ def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1135
+ """
1136
+ Specifies what flows belong to the same project.
1137
+
1138
+ A project-specific namespace is created for all flows that
1139
+ use the same `@project(name)`.
1140
+
1141
+
1142
+ Parameters
1143
+ ----------
1144
+ name : str
1145
+ Project name. Make sure that the name is unique amongst all
1146
+ projects that use the same production scheduler. The name may
1147
+ contain only lowercase alphanumeric characters and underscores.
1148
+
1149
+ branch : Optional[str], default None
1150
+ The branch to use. If not specified, the branch is set to
1151
+ `user.<username>` unless `production` is set to `True`. This can
1152
+ also be set on the command line using `--branch` as a top-level option.
1153
+ It is an error to specify `branch` in the decorator and on the command line.
1154
+
1155
+ production : bool, default False
1156
+ Whether or not the branch is the production branch. This can also be set on the
1157
+ command line using `--production` as a top-level option. It is an error to specify
1158
+ `production` in the decorator and on the command line.
1159
+ The project branch name will be:
1160
+ - if `branch` is specified:
1161
+ - if `production` is True: `prod.<branch>`
1162
+ - if `production` is False: `test.<branch>`
1163
+ - if `branch` is not specified:
1164
+ - if `production` is True: `prod`
1165
+ - if `production` is False: `user.<username>`
1166
+ """
1167
+ ...
1168
+
1169
+ 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]]:
1170
+ """
1171
+ 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)
1172
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1173
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1174
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1175
+ starts only after all sensors finish.
1176
+
1177
+
1178
+ Parameters
1179
+ ----------
1180
+ timeout : int
1181
+ Time, in seconds before the task times out and fails. (Default: 3600)
1182
+ poke_interval : int
1183
+ Time in seconds that the job should wait in between each try. (Default: 60)
1184
+ mode : str
1185
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1186
+ exponential_backoff : bool
1187
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1188
+ pool : str
1189
+ the slot pool this task should run in,
1190
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1191
+ soft_fail : bool
1192
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1193
+ name : str
1194
+ Name of the sensor on Airflow
1195
+ description : str
1196
+ Description of sensor in the Airflow UI
1197
+ bucket_key : Union[str, List[str]]
1198
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1199
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1200
+ bucket_name : str
1201
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1202
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1203
+ wildcard_match : bool
1204
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1205
+ aws_conn_id : str
1206
+ a reference to the s3 connection on Airflow. (Default: None)
1207
+ verify : bool
1208
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1209
+ """
1210
+ ...
1211
+
1172
1212
  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]]:
1173
1213
  """
1174
1214
  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.
@@ -1253,49 +1293,6 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
1253
1293
  """
1254
1294
  ...
1255
1295
 
1256
- 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]]:
1257
- """
1258
- 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)
1259
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1260
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1261
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1262
- starts only after all sensors finish.
1263
-
1264
-
1265
- Parameters
1266
- ----------
1267
- timeout : int
1268
- Time, in seconds before the task times out and fails. (Default: 3600)
1269
- poke_interval : int
1270
- Time in seconds that the job should wait in between each try. (Default: 60)
1271
- mode : str
1272
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1273
- exponential_backoff : bool
1274
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1275
- pool : str
1276
- the slot pool this task should run in,
1277
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1278
- soft_fail : bool
1279
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1280
- name : str
1281
- Name of the sensor on Airflow
1282
- description : str
1283
- Description of sensor in the Airflow UI
1284
- bucket_key : Union[str, List[str]]
1285
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1286
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1287
- bucket_name : str
1288
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1289
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1290
- wildcard_match : bool
1291
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1292
- aws_conn_id : str
1293
- a reference to the s3 connection on Airflow. (Default: None)
1294
- verify : bool
1295
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1296
- """
1297
- ...
1298
-
1299
1296
  @typing.overload
1300
1297
  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]]:
1301
1298
  """
@@ -1397,6 +1394,99 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
1397
1394
  """
1398
1395
  ...
1399
1396
 
1397
+ @typing.overload
1398
+ def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1399
+ """
1400
+ Specifies the event(s) that this flow depends on.
1401
+
1402
+ ```
1403
+ @trigger(event='foo')
1404
+ ```
1405
+ or
1406
+ ```
1407
+ @trigger(events=['foo', 'bar'])
1408
+ ```
1409
+
1410
+ Additionally, you can specify the parameter mappings
1411
+ to map event payload to Metaflow parameters for the flow.
1412
+ ```
1413
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1414
+ ```
1415
+ or
1416
+ ```
1417
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1418
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1419
+ ```
1420
+
1421
+ 'parameters' can also be a list of strings and tuples like so:
1422
+ ```
1423
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1424
+ ```
1425
+ This is equivalent to:
1426
+ ```
1427
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1428
+ ```
1429
+
1430
+
1431
+ Parameters
1432
+ ----------
1433
+ event : Union[str, Dict[str, Any]], optional, default None
1434
+ Event dependency for this flow.
1435
+ events : List[Union[str, Dict[str, Any]]], default []
1436
+ Events dependency for this flow.
1437
+ options : Dict[str, Any], default {}
1438
+ Backend-specific configuration for tuning eventing behavior.
1439
+ """
1440
+ ...
1441
+
1442
+ @typing.overload
1443
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1444
+ ...
1445
+
1446
+ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
1447
+ """
1448
+ Specifies the event(s) that this flow depends on.
1449
+
1450
+ ```
1451
+ @trigger(event='foo')
1452
+ ```
1453
+ or
1454
+ ```
1455
+ @trigger(events=['foo', 'bar'])
1456
+ ```
1457
+
1458
+ Additionally, you can specify the parameter mappings
1459
+ to map event payload to Metaflow parameters for the flow.
1460
+ ```
1461
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1462
+ ```
1463
+ or
1464
+ ```
1465
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1466
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1467
+ ```
1468
+
1469
+ 'parameters' can also be a list of strings and tuples like so:
1470
+ ```
1471
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1472
+ ```
1473
+ This is equivalent to:
1474
+ ```
1475
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1476
+ ```
1477
+
1478
+
1479
+ Parameters
1480
+ ----------
1481
+ event : Union[str, Dict[str, Any]], optional, default None
1482
+ Event dependency for this flow.
1483
+ events : List[Union[str, Dict[str, Any]]], default []
1484
+ Events dependency for this flow.
1485
+ options : Dict[str, Any], default {}
1486
+ Backend-specific configuration for tuning eventing behavior.
1487
+ """
1488
+ ...
1489
+
1400
1490
  @typing.overload
1401
1491
  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]]:
1402
1492
  """
@@ -1448,91 +1538,5 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
1448
1538
  """
1449
1539
  ...
1450
1540
 
1451
- def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1452
- """
1453
- Specifies what flows belong to the same project.
1454
-
1455
- A project-specific namespace is created for all flows that
1456
- use the same `@project(name)`.
1457
-
1458
-
1459
- Parameters
1460
- ----------
1461
- name : str
1462
- Project name. Make sure that the name is unique amongst all
1463
- projects that use the same production scheduler. The name may
1464
- contain only lowercase alphanumeric characters and underscores.
1465
-
1466
- branch : Optional[str], default None
1467
- The branch to use. If not specified, the branch is set to
1468
- `user.<username>` unless `production` is set to `True`. This can
1469
- also be set on the command line using `--branch` as a top-level option.
1470
- It is an error to specify `branch` in the decorator and on the command line.
1471
-
1472
- production : bool, default False
1473
- Whether or not the branch is the production branch. This can also be set on the
1474
- command line using `--production` as a top-level option. It is an error to specify
1475
- `production` in the decorator and on the command line.
1476
- The project branch name will be:
1477
- - if `branch` is specified:
1478
- - if `production` is True: `prod.<branch>`
1479
- - if `production` is False: `test.<branch>`
1480
- - if `branch` is not specified:
1481
- - if `production` is True: `prod`
1482
- - if `production` is False: `user.<username>`
1483
- """
1484
- ...
1485
-
1486
- @typing.overload
1487
- 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]]:
1488
- """
1489
- Specifies the Conda environment for all steps of the flow.
1490
-
1491
- Use `@conda_base` to set common libraries required by all
1492
- steps and use `@conda` to specify step-specific additions.
1493
-
1494
-
1495
- Parameters
1496
- ----------
1497
- packages : Dict[str, str], default {}
1498
- Packages to use for this flow. The key is the name of the package
1499
- and the value is the version to use.
1500
- libraries : Dict[str, str], default {}
1501
- Supported for backward compatibility. When used with packages, packages will take precedence.
1502
- python : str, optional, default None
1503
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1504
- that the version used will correspond to the version of the Python interpreter used to start the run.
1505
- disabled : bool, default False
1506
- If set to True, disables Conda.
1507
- """
1508
- ...
1509
-
1510
- @typing.overload
1511
- def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1512
- ...
1513
-
1514
- 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):
1515
- """
1516
- Specifies the Conda environment for all steps of the flow.
1517
-
1518
- Use `@conda_base` to set common libraries required by all
1519
- steps and use `@conda` to specify step-specific additions.
1520
-
1521
-
1522
- Parameters
1523
- ----------
1524
- packages : Dict[str, str], default {}
1525
- Packages to use for this flow. The key is the name of the package
1526
- and the value is the version to use.
1527
- libraries : Dict[str, str], default {}
1528
- Supported for backward compatibility. When used with packages, packages will take precedence.
1529
- python : str, optional, default None
1530
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1531
- that the version used will correspond to the version of the Python interpreter used to start the run.
1532
- disabled : bool, default False
1533
- If set to True, disables Conda.
1534
- """
1535
- ...
1536
-
1537
1541
  pkg_name: str
1538
1542