ob-metaflow-stubs 6.0.3.179rc5__py2.py3-none-any.whl → 6.0.3.180rc1__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 (220) hide show
  1. metaflow-stubs/__init__.pyi +803 -765
  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 +5 -5
  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 +5 -5
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +3 -3
  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 +2 -2
  18. metaflow-stubs/metadata_provider/util.pyi +1 -1
  19. metaflow-stubs/metaflow_config.pyi +1 -1
  20. metaflow-stubs/metaflow_current.pyi +53 -53
  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 +4 -4
  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 +2 -2
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +4 -4
  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 +1 -1
  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 +2 -2
  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 +1 -1
  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 +3 -3
  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 +1 -1
  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 +2 -2
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +2 -2
  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/aws/__init__.pyi +1 -1
  67. metaflow-stubs/mf_extensions/outerbounds/plugins/aws/assume_role_decorator.pyi +1 -1
  68. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
  69. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +1 -1
  70. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
  71. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
  72. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
  73. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +1 -1
  75. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +4 -4
  76. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +2 -2
  77. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +1 -1
  78. metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +1 -1
  79. metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +1 -1
  80. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
  81. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +1 -1
  82. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +1 -1
  83. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +1 -1
  84. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +1 -1
  85. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
  86. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
  87. metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
  88. metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
  89. metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
  90. metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
  91. metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
  92. metaflow-stubs/multicore_utils.pyi +1 -1
  93. metaflow-stubs/ob_internal.pyi +1 -1
  94. metaflow-stubs/parameters.pyi +3 -3
  95. metaflow-stubs/plugins/__init__.pyi +12 -12
  96. metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
  97. metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
  98. metaflow-stubs/plugins/airflow/exception.pyi +1 -1
  99. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
  100. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
  101. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
  102. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
  103. metaflow-stubs/plugins/argo/__init__.pyi +1 -1
  104. metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
  105. metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
  106. metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
  107. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +1 -1
  108. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
  109. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +3 -3
  110. metaflow-stubs/plugins/aws/__init__.pyi +1 -1
  111. metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
  112. metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
  113. metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
  114. metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
  115. metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
  116. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
  117. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
  118. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +1 -1
  119. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
  120. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
  121. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
  122. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
  123. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
  124. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +4 -4
  125. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +3 -3
  126. metaflow-stubs/plugins/azure/__init__.pyi +1 -1
  127. metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
  128. metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
  129. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +1 -1
  130. metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
  131. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
  132. metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
  133. metaflow-stubs/plugins/cards/__init__.pyi +1 -1
  134. metaflow-stubs/plugins/cards/card_client.pyi +2 -2
  135. metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
  136. metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
  137. metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
  138. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
  139. metaflow-stubs/plugins/cards/card_modules/basic.pyi +1 -1
  140. metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
  141. metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
  142. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
  143. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
  144. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
  145. metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
  146. metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
  147. metaflow-stubs/plugins/cards/exception.pyi +1 -1
  148. metaflow-stubs/plugins/catch_decorator.pyi +1 -1
  149. metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
  150. metaflow-stubs/plugins/datatools/local.pyi +1 -1
  151. metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
  152. metaflow-stubs/plugins/datatools/s3/s3.pyi +3 -3
  153. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
  154. metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
  155. metaflow-stubs/plugins/debug_logger.pyi +1 -1
  156. metaflow-stubs/plugins/debug_monitor.pyi +1 -1
  157. metaflow-stubs/plugins/environment_decorator.pyi +1 -1
  158. metaflow-stubs/plugins/events_decorator.pyi +1 -1
  159. metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
  160. metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
  161. metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
  162. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +1 -1
  163. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
  164. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
  165. metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
  166. metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
  167. metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
  168. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
  169. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
  170. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
  171. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
  172. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
  173. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
  174. metaflow-stubs/plugins/ollama/__init__.pyi +1 -1
  175. metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
  176. metaflow-stubs/plugins/perimeters.pyi +1 -1
  177. metaflow-stubs/plugins/project_decorator.pyi +1 -1
  178. metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
  179. metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
  180. metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
  181. metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
  182. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
  183. metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
  184. metaflow-stubs/plugins/pypi/utils.pyi +1 -1
  185. metaflow-stubs/plugins/resources_decorator.pyi +1 -1
  186. metaflow-stubs/plugins/retry_decorator.pyi +1 -1
  187. metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
  188. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +1 -1
  189. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
  190. metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
  191. metaflow-stubs/plugins/storage_executor.pyi +1 -1
  192. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
  193. metaflow-stubs/plugins/timeout_decorator.pyi +1 -1
  194. metaflow-stubs/plugins/torchtune/__init__.pyi +1 -1
  195. metaflow-stubs/plugins/uv/__init__.pyi +1 -1
  196. metaflow-stubs/plugins/uv/uv_environment.pyi +2 -2
  197. metaflow-stubs/profilers/__init__.pyi +1 -1
  198. metaflow-stubs/pylint_wrapper.pyi +1 -1
  199. metaflow-stubs/runner/__init__.pyi +1 -1
  200. metaflow-stubs/runner/deployer.pyi +29 -29
  201. metaflow-stubs/runner/deployer_impl.pyi +2 -2
  202. metaflow-stubs/runner/metaflow_runner.pyi +2 -2
  203. metaflow-stubs/runner/nbdeploy.pyi +1 -1
  204. metaflow-stubs/runner/nbrun.pyi +1 -1
  205. metaflow-stubs/runner/subprocess_manager.pyi +1 -1
  206. metaflow-stubs/runner/utils.pyi +2 -2
  207. metaflow-stubs/system/__init__.pyi +1 -1
  208. metaflow-stubs/system/system_logger.pyi +2 -2
  209. metaflow-stubs/system/system_monitor.pyi +1 -1
  210. metaflow-stubs/tagging_util.pyi +1 -1
  211. metaflow-stubs/tuple_util.pyi +1 -1
  212. metaflow-stubs/user_configs/__init__.pyi +1 -1
  213. metaflow-stubs/user_configs/config_decorators.pyi +4 -4
  214. metaflow-stubs/user_configs/config_options.pyi +2 -2
  215. metaflow-stubs/user_configs/config_parameters.pyi +5 -5
  216. {ob_metaflow_stubs-6.0.3.179rc5.dist-info → ob_metaflow_stubs-6.0.3.180rc1.dist-info}/METADATA +1 -1
  217. ob_metaflow_stubs-6.0.3.180rc1.dist-info/RECORD +220 -0
  218. ob_metaflow_stubs-6.0.3.179rc5.dist-info/RECORD +0 -220
  219. {ob_metaflow_stubs-6.0.3.179rc5.dist-info → ob_metaflow_stubs-6.0.3.180rc1.dist-info}/WHEEL +0 -0
  220. {ob_metaflow_stubs-6.0.3.179rc5.dist-info → ob_metaflow_stubs-6.0.3.180rc1.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.17.1+obcheckpoint(0.2.1);ob(v1) #
4
- # Generated on 2025-06-13T21:29:38.839071 #
4
+ # Generated on 2025-06-17T09:48:39.040005 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
9
  import typing
10
10
  if typing.TYPE_CHECKING:
11
- import typing
12
11
  import datetime
12
+ import typing
13
13
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
14
14
  StepFlag = typing.NewType("StepFlag", bool)
15
15
 
@@ -35,10 +35,10 @@ 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 tuple_util as tuple_util
39
38
  from . import cards as cards
40
39
  from . import metaflow_git as metaflow_git
41
40
  from . import events as events
41
+ from . import tuple_util as tuple_util
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
@@ -155,6 +155,125 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
155
155
  """
156
156
  ...
157
157
 
158
+ @typing.overload
159
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
160
+ """
161
+ Internal decorator to support Fast bakery
162
+ """
163
+ ...
164
+
165
+ @typing.overload
166
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
167
+ ...
168
+
169
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
170
+ """
171
+ Internal decorator to support Fast bakery
172
+ """
173
+ ...
174
+
175
+ def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
176
+ """
177
+ This decorator is used to run Ollama APIs as Metaflow task sidecars.
178
+
179
+ User code call
180
+ --------------
181
+ @ollama(
182
+ models=[...],
183
+ ...
184
+ )
185
+
186
+ Valid backend options
187
+ ---------------------
188
+ - 'local': Run as a separate process on the local task machine.
189
+ - (TODO) 'managed': Outerbounds hosts and selects compute provider.
190
+ - (TODO) 'remote': Spin up separate instance to serve Ollama models.
191
+
192
+ Valid model options
193
+ -------------------
194
+ Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
195
+
196
+
197
+ Parameters
198
+ ----------
199
+ models: list[str]
200
+ List of Ollama containers running models in sidecars.
201
+ backend: str
202
+ Determines where and how to run the Ollama process.
203
+ force_pull: bool
204
+ Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
205
+ cache_update_policy: str
206
+ Cache update policy: "auto", "force", or "never".
207
+ force_cache_update: bool
208
+ Simple override for "force" cache update policy.
209
+ debug: bool
210
+ Whether to turn on verbose debugging logs.
211
+ circuit_breaker_config: dict
212
+ Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
213
+ timeout_config: dict
214
+ Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
215
+ """
216
+ ...
217
+
218
+ @typing.overload
219
+ 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]]]:
220
+ """
221
+ Specifies the Conda environment for the step.
222
+
223
+ Information in this decorator will augment any
224
+ attributes set in the `@conda_base` flow-level decorator. Hence,
225
+ you can use `@conda_base` to set packages required by all
226
+ steps and use `@conda` to specify step-specific overrides.
227
+
228
+
229
+ Parameters
230
+ ----------
231
+ packages : Dict[str, str], default {}
232
+ Packages to use for this step. The key is the name of the package
233
+ and the value is the version to use.
234
+ libraries : Dict[str, str], default {}
235
+ Supported for backward compatibility. When used with packages, packages will take precedence.
236
+ python : str, optional, default None
237
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
238
+ that the version used will correspond to the version of the Python interpreter used to start the run.
239
+ disabled : bool, default False
240
+ If set to True, disables @conda.
241
+ """
242
+ ...
243
+
244
+ @typing.overload
245
+ def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
246
+ ...
247
+
248
+ @typing.overload
249
+ def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
250
+ ...
251
+
252
+ 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):
253
+ """
254
+ Specifies the Conda environment for the step.
255
+
256
+ Information in this decorator will augment any
257
+ attributes set in the `@conda_base` flow-level decorator. Hence,
258
+ you can use `@conda_base` to set packages required by all
259
+ steps and use `@conda` to specify step-specific overrides.
260
+
261
+
262
+ Parameters
263
+ ----------
264
+ packages : Dict[str, str], default {}
265
+ Packages to use for this step. The key is the name of the package
266
+ and the value is the version to use.
267
+ libraries : Dict[str, str], default {}
268
+ Supported for backward compatibility. When used with packages, packages will take precedence.
269
+ python : str, optional, default None
270
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
271
+ that the version used will correspond to the version of the Python interpreter used to start the run.
272
+ disabled : bool, default False
273
+ If set to True, disables @conda.
274
+ """
275
+ ...
276
+
158
277
  @typing.overload
159
278
  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]]]:
160
279
  """
@@ -189,59 +308,116 @@ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], Non
189
308
  ...
190
309
 
191
310
  @typing.overload
192
- 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]]]:
311
+ 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]]]:
193
312
  """
194
- Enables checkpointing for a step.
313
+ Specifies secrets to be retrieved and injected as environment variables prior to
314
+ the execution of a step.
195
315
 
196
316
 
317
+ Parameters
318
+ ----------
319
+ sources : List[Union[str, Dict[str, Any]]], default: []
320
+ List of secret specs, defining how the secrets are to be retrieved
321
+ """
322
+ ...
323
+
324
+ @typing.overload
325
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
326
+ ...
327
+
328
+ @typing.overload
329
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
330
+ ...
331
+
332
+ 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]]] = []):
333
+ """
334
+ Specifies secrets to be retrieved and injected as environment variables prior to
335
+ the execution of a step.
336
+
197
337
 
198
338
  Parameters
199
339
  ----------
200
- load_policy : str, default: "fresh"
201
- The policy for loading the checkpoint. The following policies are supported:
202
- - "eager": Loads the the latest available checkpoint within the namespace.
203
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
204
- will be loaded at the start of the task.
205
- - "none": Do not load any checkpoint
206
- - "fresh": Loads the lastest checkpoint created within the running Task.
207
- This mode helps loading checkpoints across various retry attempts of the same task.
208
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
209
- created within the task will be loaded when the task is retries execution on failure.
340
+ sources : List[Union[str, Dict[str, Any]]], default: []
341
+ List of secret specs, defining how the secrets are to be retrieved
342
+ """
343
+ ...
344
+
345
+ @typing.overload
346
+ 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]]]:
347
+ """
348
+ Specifies the resources needed when executing this step.
210
349
 
211
- temp_dir_root : str, default: None
212
- The root directory under which `current.checkpoint.directory` will be created.
350
+ Use `@resources` to specify the resource requirements
351
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
352
+
353
+ You can choose the compute layer on the command line by executing e.g.
354
+ ```
355
+ python myflow.py run --with batch
356
+ ```
357
+ or
358
+ ```
359
+ python myflow.py run --with kubernetes
360
+ ```
361
+ which executes the flow on the desired system using the
362
+ requirements specified in `@resources`.
363
+
364
+
365
+ Parameters
366
+ ----------
367
+ cpu : int, default 1
368
+ Number of CPUs required for this step.
369
+ gpu : int, optional, default None
370
+ Number of GPUs required for this step.
371
+ disk : int, optional, default None
372
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
373
+ memory : int, default 4096
374
+ Memory size (in MB) required for this step.
375
+ shared_memory : int, optional, default None
376
+ The value for the size (in MiB) of the /dev/shm volume for this step.
377
+ This parameter maps to the `--shm-size` option in Docker.
213
378
  """
214
379
  ...
215
380
 
216
381
  @typing.overload
217
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
382
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
218
383
  ...
219
384
 
220
385
  @typing.overload
221
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
386
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
222
387
  ...
223
388
 
224
- 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):
389
+ 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):
225
390
  """
226
- Enables checkpointing for a step.
391
+ Specifies the resources needed when executing this step.
392
+
393
+ Use `@resources` to specify the resource requirements
394
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
227
395
 
396
+ You can choose the compute layer on the command line by executing e.g.
397
+ ```
398
+ python myflow.py run --with batch
399
+ ```
400
+ or
401
+ ```
402
+ python myflow.py run --with kubernetes
403
+ ```
404
+ which executes the flow on the desired system using the
405
+ requirements specified in `@resources`.
228
406
 
229
407
 
230
408
  Parameters
231
409
  ----------
232
- load_policy : str, default: "fresh"
233
- The policy for loading the checkpoint. The following policies are supported:
234
- - "eager": Loads the the latest available checkpoint within the namespace.
235
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
236
- will be loaded at the start of the task.
237
- - "none": Do not load any checkpoint
238
- - "fresh": Loads the lastest checkpoint created within the running Task.
239
- This mode helps loading checkpoints across various retry attempts of the same task.
240
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
241
- created within the task will be loaded when the task is retries execution on failure.
242
-
243
- temp_dir_root : str, default: None
244
- The root directory under which `current.checkpoint.directory` will be created.
410
+ cpu : int, default 1
411
+ Number of CPUs required for this step.
412
+ gpu : int, optional, default None
413
+ Number of GPUs required for this step.
414
+ disk : int, optional, default None
415
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
416
+ memory : int, default 4096
417
+ Memory size (in MB) required for this step.
418
+ shared_memory : int, optional, default None
419
+ The value for the size (in MiB) of the /dev/shm volume for this step.
420
+ This parameter maps to the `--shm-size` option in Docker.
245
421
  """
246
422
  ...
247
423
 
@@ -296,171 +472,96 @@ def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
296
472
  """
297
473
  ...
298
474
 
299
- def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', image_pull_secrets: typing.List[str] = [], service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
475
+ @typing.overload
476
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
300
477
  """
301
- Specifies that this step should execute on Kubernetes.
302
-
303
-
304
- Parameters
305
- ----------
306
- cpu : int, default 1
307
- Number of CPUs required for this step. If `@resources` is
308
- also present, the maximum value from all decorators is used.
309
- memory : int, default 4096
310
- Memory size (in MB) required for this step. If
311
- `@resources` is also present, the maximum value from all decorators is
312
- used.
313
- disk : int, default 10240
314
- Disk size (in MB) required for this step. If
315
- `@resources` is also present, the maximum value from all decorators is
316
- used.
317
- image : str, optional, default None
318
- Docker image to use when launching on Kubernetes. If not specified, and
319
- METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
320
- not, a default Docker image mapping to the current version of Python is used.
321
- image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
322
- If given, the imagePullPolicy to be applied to the Docker image of the step.
323
- image_pull_secrets: List[str], default []
324
- The default is extracted from METAFLOW_KUBERNETES_IMAGE_PULL_SECRETS.
325
- Kubernetes image pull secrets to use when pulling container images
326
- in Kubernetes.
327
- service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
328
- Kubernetes service account to use when launching pod in Kubernetes.
329
- secrets : List[str], optional, default None
330
- Kubernetes secrets to use when launching pod in Kubernetes. These
331
- secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
332
- in Metaflow configuration.
333
- node_selector: Union[Dict[str,str], str], optional, default None
334
- Kubernetes node selector(s) to apply to the pod running the task.
335
- Can be passed in as a comma separated string of values e.g.
336
- 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
337
- {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
338
- namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
339
- Kubernetes namespace to use when launching pod in Kubernetes.
340
- gpu : int, optional, default None
341
- Number of GPUs required for this step. A value of zero implies that
342
- the scheduled node should not have GPUs.
343
- gpu_vendor : str, default KUBERNETES_GPU_VENDOR
344
- The vendor of the GPUs to be used for this step.
345
- tolerations : List[str], default []
346
- The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
347
- Kubernetes tolerations to use when launching pod in Kubernetes.
348
- labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
349
- Kubernetes labels to use when launching pod in Kubernetes.
350
- annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
351
- Kubernetes annotations to use when launching pod in Kubernetes.
352
- use_tmpfs : bool, default False
353
- This enables an explicit tmpfs mount for this step.
354
- tmpfs_tempdir : bool, default True
355
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
356
- tmpfs_size : int, optional, default: None
357
- The value for the size (in MiB) of the tmpfs mount for this step.
358
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
359
- memory allocated for this step.
360
- tmpfs_path : str, optional, default /metaflow_temp
361
- Path to tmpfs mount for this step.
362
- persistent_volume_claims : Dict[str, str], optional, default None
363
- A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
364
- volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
365
- shared_memory: int, optional
366
- Shared memory size (in MiB) required for this step
367
- port: int, optional
368
- Port number to specify in the Kubernetes job object
369
- compute_pool : str, optional, default None
370
- Compute pool to be used for for this step.
371
- If not specified, any accessible compute pool within the perimeter is used.
372
- hostname_resolution_timeout: int, default 10 * 60
373
- Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
374
- Only applicable when @parallel is used.
375
- qos: str, default: Burstable
376
- Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
377
-
378
- security_context: Dict[str, Any], optional, default None
379
- Container security context. Applies to the task container. Allows the following keys:
380
- - privileged: bool, optional, default None
381
- - allow_privilege_escalation: bool, optional, default None
382
- - run_as_user: int, optional, default None
383
- - run_as_group: int, optional, default None
384
- - run_as_non_root: bool, optional, default None
478
+ Decorator prototype for all step decorators. This function gets specialized
479
+ and imported for all decorators types by _import_plugin_decorators().
385
480
  """
386
481
  ...
387
482
 
388
483
  @typing.overload
389
- 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]]]:
484
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
485
+ ...
486
+
487
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
390
488
  """
391
- Specifies the resources needed when executing this step.
489
+ Decorator prototype for all step decorators. This function gets specialized
490
+ and imported for all decorators types by _import_plugin_decorators().
491
+ """
492
+ ...
493
+
494
+ @typing.overload
495
+ 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]]]:
496
+ """
497
+ Specifies a timeout for your step.
392
498
 
393
- Use `@resources` to specify the resource requirements
394
- independently of the specific compute layer (`@batch`, `@kubernetes`).
499
+ This decorator is useful if this step may hang indefinitely.
395
500
 
396
- You can choose the compute layer on the command line by executing e.g.
397
- ```
398
- python myflow.py run --with batch
399
- ```
400
- or
401
- ```
402
- python myflow.py run --with kubernetes
403
- ```
404
- which executes the flow on the desired system using the
405
- requirements specified in `@resources`.
501
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
502
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
503
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
504
+
505
+ Note that all the values specified in parameters are added together so if you specify
506
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
406
507
 
407
508
 
408
509
  Parameters
409
510
  ----------
410
- cpu : int, default 1
411
- Number of CPUs required for this step.
412
- gpu : int, optional, default None
413
- Number of GPUs required for this step.
414
- disk : int, optional, default None
415
- Disk size (in MB) required for this step. Only applies on Kubernetes.
416
- memory : int, default 4096
417
- Memory size (in MB) required for this step.
418
- shared_memory : int, optional, default None
419
- The value for the size (in MiB) of the /dev/shm volume for this step.
420
- This parameter maps to the `--shm-size` option in Docker.
511
+ seconds : int, default 0
512
+ Number of seconds to wait prior to timing out.
513
+ minutes : int, default 0
514
+ Number of minutes to wait prior to timing out.
515
+ hours : int, default 0
516
+ Number of hours to wait prior to timing out.
421
517
  """
422
518
  ...
423
519
 
424
520
  @typing.overload
425
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
521
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
426
522
  ...
427
523
 
428
524
  @typing.overload
429
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
525
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
430
526
  ...
431
527
 
432
- 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):
528
+ 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):
433
529
  """
434
- Specifies the resources needed when executing this step.
530
+ Specifies a timeout for your step.
435
531
 
436
- Use `@resources` to specify the resource requirements
437
- independently of the specific compute layer (`@batch`, `@kubernetes`).
532
+ This decorator is useful if this step may hang indefinitely.
438
533
 
439
- You can choose the compute layer on the command line by executing e.g.
440
- ```
441
- python myflow.py run --with batch
442
- ```
443
- or
444
- ```
445
- python myflow.py run --with kubernetes
446
- ```
447
- which executes the flow on the desired system using the
448
- requirements specified in `@resources`.
534
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
535
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
536
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
537
+
538
+ Note that all the values specified in parameters are added together so if you specify
539
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
449
540
 
450
541
 
451
542
  Parameters
452
543
  ----------
453
- cpu : int, default 1
454
- Number of CPUs required for this step.
455
- gpu : int, optional, default None
456
- Number of GPUs required for this step.
457
- disk : int, optional, default None
458
- Disk size (in MB) required for this step. Only applies on Kubernetes.
459
- memory : int, default 4096
460
- Memory size (in MB) required for this step.
461
- shared_memory : int, optional, default None
462
- The value for the size (in MiB) of the /dev/shm volume for this step.
463
- This parameter maps to the `--shm-size` option in Docker.
544
+ seconds : int, default 0
545
+ Number of seconds to wait prior to timing out.
546
+ minutes : int, default 0
547
+ Number of minutes to wait prior to timing out.
548
+ hours : int, default 0
549
+ Number of hours to wait prior to timing out.
550
+ """
551
+ ...
552
+
553
+ 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]]]:
554
+ """
555
+ Specifies that this step is used to deploy an instance of the app.
556
+ Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
557
+
558
+
559
+ Parameters
560
+ ----------
561
+ app_port : int
562
+ Number of GPUs to use.
563
+ app_name : str
564
+ Name of the app to deploy.
464
565
  """
465
566
  ...
466
567
 
@@ -513,62 +614,17 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
513
614
  """
514
615
  ...
515
616
 
516
- 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]]]:
617
+ 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]]]:
517
618
  """
518
- Specifies that this step is used to deploy an instance of the app.
519
- Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
619
+ Specifies that this step should execute on DGX cloud.
520
620
 
521
621
 
522
622
  Parameters
523
623
  ----------
524
- app_port : int
624
+ gpu : int
525
625
  Number of GPUs to use.
526
- app_name : str
527
- Name of the app to deploy.
528
- """
529
- ...
530
-
531
- 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]]]:
532
- """
533
- Decorator that helps cache, version and store models/datasets from huggingface hub.
534
-
535
-
536
- Parameters
537
- ----------
538
- temp_dir_root : str, optional
539
- The root directory that will hold the temporary directory where objects will be downloaded.
540
-
541
- load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
542
- The list of repos (models/datasets) to load.
543
-
544
- Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
545
-
546
- - If repo (model/dataset) is not found in the datastore:
547
- - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
548
- - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
549
- - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
550
-
551
- - If repo is found in the datastore:
552
- - Loads it directly from datastore to local path (can be temporary directory or specified path)
553
- """
554
- ...
555
-
556
- @typing.overload
557
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
558
- """
559
- Decorator prototype for all step decorators. This function gets specialized
560
- and imported for all decorators types by _import_plugin_decorators().
561
- """
562
- ...
563
-
564
- @typing.overload
565
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
566
- ...
567
-
568
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
569
- """
570
- Decorator prototype for all step decorators. This function gets specialized
571
- and imported for all decorators types by _import_plugin_decorators().
626
+ gpu_type : str
627
+ Type of Nvidia GPU to use.
572
628
  """
573
629
  ...
574
630
 
@@ -623,160 +679,212 @@ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
623
679
  """
624
680
  ...
625
681
 
626
- def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
682
+ @typing.overload
683
+ 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]]]:
627
684
  """
628
- This decorator is used to run Ollama APIs as Metaflow task sidecars.
685
+ Enables checkpointing for a step.
629
686
 
630
- User code call
631
- --------------
632
- @ollama(
633
- models=[...],
634
- ...
635
- )
636
-
637
- Valid backend options
638
- ---------------------
639
- - 'local': Run as a separate process on the local task machine.
640
- - (TODO) 'managed': Outerbounds hosts and selects compute provider.
641
- - (TODO) 'remote': Spin up separate instance to serve Ollama models.
642
-
643
- Valid model options
644
- -------------------
645
- Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
646
687
 
647
688
 
648
689
  Parameters
649
690
  ----------
650
- models: list[str]
651
- List of Ollama containers running models in sidecars.
652
- backend: str
653
- Determines where and how to run the Ollama process.
654
- force_pull: bool
655
- Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
656
- cache_update_policy: str
657
- Cache update policy: "auto", "force", or "never".
658
- force_cache_update: bool
659
- Simple override for "force" cache update policy.
660
- debug: bool
661
- Whether to turn on verbose debugging logs.
662
- circuit_breaker_config: dict
663
- Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
664
- timeout_config: dict
665
- Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
691
+ load_policy : str, default: "fresh"
692
+ The policy for loading the checkpoint. The following policies are supported:
693
+ - "eager": Loads the the latest available checkpoint within the namespace.
694
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
695
+ will be loaded at the start of the task.
696
+ - "none": Do not load any checkpoint
697
+ - "fresh": Loads the lastest checkpoint created within the running Task.
698
+ This mode helps loading checkpoints across various retry attempts of the same task.
699
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
700
+ created within the task will be loaded when the task is retries execution on failure.
701
+
702
+ temp_dir_root : str, default: None
703
+ The root directory under which `current.checkpoint.directory` will be created.
666
704
  """
667
705
  ...
668
706
 
669
707
  @typing.overload
670
- 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]]]:
708
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
709
+ ...
710
+
711
+ @typing.overload
712
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
713
+ ...
714
+
715
+ 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):
671
716
  """
672
- Specifies a timeout for your step.
673
-
674
- This decorator is useful if this step may hang indefinitely.
675
-
676
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
677
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
678
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
717
+ Enables checkpointing for a step.
679
718
 
680
- Note that all the values specified in parameters are added together so if you specify
681
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
682
719
 
683
720
 
684
721
  Parameters
685
722
  ----------
686
- seconds : int, default 0
687
- Number of seconds to wait prior to timing out.
688
- minutes : int, default 0
689
- Number of minutes to wait prior to timing out.
690
- hours : int, default 0
691
- Number of hours to wait prior to timing out.
723
+ load_policy : str, default: "fresh"
724
+ The policy for loading the checkpoint. The following policies are supported:
725
+ - "eager": Loads the the latest available checkpoint within the namespace.
726
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
727
+ will be loaded at the start of the task.
728
+ - "none": Do not load any checkpoint
729
+ - "fresh": Loads the lastest checkpoint created within the running Task.
730
+ This mode helps loading checkpoints across various retry attempts of the same task.
731
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
732
+ created within the task will be loaded when the task is retries execution on failure.
733
+
734
+ temp_dir_root : str, default: None
735
+ The root directory under which `current.checkpoint.directory` will be created.
692
736
  """
693
737
  ...
694
738
 
695
- @typing.overload
696
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
697
- ...
698
-
699
- @typing.overload
700
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
701
- ...
702
-
703
- 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):
739
+ def vllm(*, model: str, backend: str, debug: bool, kwargs: 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]]]:
704
740
  """
705
- Specifies a timeout for your step.
741
+ This decorator is used to run vllm APIs as Metaflow task sidecars.
706
742
 
707
- This decorator is useful if this step may hang indefinitely.
743
+ User code call
744
+ --------------
745
+ @vllm(
746
+ model="...",
747
+ ...
748
+ )
708
749
 
709
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
710
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
711
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
750
+ Valid backend options
751
+ ---------------------
752
+ - 'local': Run as a separate process on the local task machine.
712
753
 
713
- Note that all the values specified in parameters are added together so if you specify
714
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
754
+ Valid model options
755
+ -------------------
756
+ Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
757
+
758
+ NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
759
+ If you need multiple models, you must create multiple @vllm decorators.
715
760
 
716
761
 
717
762
  Parameters
718
763
  ----------
719
- seconds : int, default 0
720
- Number of seconds to wait prior to timing out.
721
- minutes : int, default 0
722
- Number of minutes to wait prior to timing out.
723
- hours : int, default 0
724
- Number of hours to wait prior to timing out.
764
+ model: str
765
+ HuggingFace model identifier to be served by vLLM.
766
+ backend: str
767
+ Determines where and how to run the vLLM process.
768
+ debug: bool
769
+ Whether to turn on verbose debugging logs.
770
+ kwargs : Any
771
+ Any other keyword arguments are passed directly to the vLLM engine.
772
+ This allows for flexible configuration of vLLM server settings.
773
+ For example, `tensor_parallel_size=2`.
725
774
  """
726
775
  ...
727
776
 
728
- @typing.overload
729
- 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]]]:
777
+ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', image_pull_secrets: typing.List[str] = [], service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
730
778
  """
731
- Specifies the number of times the task corresponding
732
- to a step needs to be retried.
733
-
734
- This decorator is useful for handling transient errors, such as networking issues.
735
- If your task contains operations that can't be retried safely, e.g. database updates,
736
- it is advisable to annotate it with `@retry(times=0)`.
737
-
738
- This can be used in conjunction with the `@catch` decorator. The `@catch`
739
- decorator will execute a no-op task after all retries have been exhausted,
740
- ensuring that the flow execution can continue.
779
+ Specifies that this step should execute on Kubernetes.
741
780
 
742
781
 
743
782
  Parameters
744
783
  ----------
745
- times : int, default 3
746
- Number of times to retry this task.
747
- minutes_between_retries : int, default 2
748
- Number of minutes between retries.
784
+ cpu : int, default 1
785
+ Number of CPUs required for this step. If `@resources` is
786
+ also present, the maximum value from all decorators is used.
787
+ memory : int, default 4096
788
+ Memory size (in MB) required for this step. If
789
+ `@resources` is also present, the maximum value from all decorators is
790
+ used.
791
+ disk : int, default 10240
792
+ Disk size (in MB) required for this step. If
793
+ `@resources` is also present, the maximum value from all decorators is
794
+ used.
795
+ image : str, optional, default None
796
+ Docker image to use when launching on Kubernetes. If not specified, and
797
+ METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
798
+ not, a default Docker image mapping to the current version of Python is used.
799
+ image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
800
+ If given, the imagePullPolicy to be applied to the Docker image of the step.
801
+ image_pull_secrets: List[str], default []
802
+ The default is extracted from METAFLOW_KUBERNETES_IMAGE_PULL_SECRETS.
803
+ Kubernetes image pull secrets to use when pulling container images
804
+ in Kubernetes.
805
+ service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
806
+ Kubernetes service account to use when launching pod in Kubernetes.
807
+ secrets : List[str], optional, default None
808
+ Kubernetes secrets to use when launching pod in Kubernetes. These
809
+ secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
810
+ in Metaflow configuration.
811
+ node_selector: Union[Dict[str,str], str], optional, default None
812
+ Kubernetes node selector(s) to apply to the pod running the task.
813
+ Can be passed in as a comma separated string of values e.g.
814
+ 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
815
+ {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
816
+ namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
817
+ Kubernetes namespace to use when launching pod in Kubernetes.
818
+ gpu : int, optional, default None
819
+ Number of GPUs required for this step. A value of zero implies that
820
+ the scheduled node should not have GPUs.
821
+ gpu_vendor : str, default KUBERNETES_GPU_VENDOR
822
+ The vendor of the GPUs to be used for this step.
823
+ tolerations : List[str], default []
824
+ The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
825
+ Kubernetes tolerations to use when launching pod in Kubernetes.
826
+ labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
827
+ Kubernetes labels to use when launching pod in Kubernetes.
828
+ annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
829
+ Kubernetes annotations to use when launching pod in Kubernetes.
830
+ use_tmpfs : bool, default False
831
+ This enables an explicit tmpfs mount for this step.
832
+ tmpfs_tempdir : bool, default True
833
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
834
+ tmpfs_size : int, optional, default: None
835
+ The value for the size (in MiB) of the tmpfs mount for this step.
836
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
837
+ memory allocated for this step.
838
+ tmpfs_path : str, optional, default /metaflow_temp
839
+ Path to tmpfs mount for this step.
840
+ persistent_volume_claims : Dict[str, str], optional, default None
841
+ A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
842
+ volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
843
+ shared_memory: int, optional
844
+ Shared memory size (in MiB) required for this step
845
+ port: int, optional
846
+ Port number to specify in the Kubernetes job object
847
+ compute_pool : str, optional, default None
848
+ Compute pool to be used for for this step.
849
+ If not specified, any accessible compute pool within the perimeter is used.
850
+ hostname_resolution_timeout: int, default 10 * 60
851
+ Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
852
+ Only applicable when @parallel is used.
853
+ qos: str, default: Burstable
854
+ Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
855
+
856
+ security_context: Dict[str, Any], optional, default None
857
+ Container security context. Applies to the task container. Allows the following keys:
858
+ - privileged: bool, optional, default None
859
+ - allow_privilege_escalation: bool, optional, default None
860
+ - run_as_user: int, optional, default None
861
+ - run_as_group: int, optional, default None
862
+ - run_as_non_root: bool, optional, default None
749
863
  """
750
864
  ...
751
865
 
752
- @typing.overload
753
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
754
- ...
755
-
756
- @typing.overload
757
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
758
- ...
759
-
760
- 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):
866
+ 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]]]:
761
867
  """
762
- Specifies the number of times the task corresponding
763
- to a step needs to be retried.
764
-
765
- This decorator is useful for handling transient errors, such as networking issues.
766
- If your task contains operations that can't be retried safely, e.g. database updates,
767
- it is advisable to annotate it with `@retry(times=0)`.
768
-
769
- This can be used in conjunction with the `@catch` decorator. The `@catch`
770
- decorator will execute a no-op task after all retries have been exhausted,
771
- ensuring that the flow execution can continue.
868
+ Decorator that helps cache, version and store models/datasets from huggingface hub.
772
869
 
773
870
 
774
871
  Parameters
775
872
  ----------
776
- times : int, default 3
777
- Number of times to retry this task.
778
- minutes_between_retries : int, default 2
779
- Number of minutes between retries.
873
+ temp_dir_root : str, optional
874
+ The root directory that will hold the temporary directory where objects will be downloaded.
875
+
876
+ load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
877
+ The list of repos (models/datasets) to load.
878
+
879
+ Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
880
+
881
+ - If repo (model/dataset) is not found in the datastore:
882
+ - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
883
+ - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
884
+ - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
885
+
886
+ - If repo is found in the datastore:
887
+ - Loads it directly from datastore to local path (can be temporary directory or specified path)
780
888
  """
781
889
  ...
782
890
 
@@ -837,291 +945,362 @@ def model(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
837
945
  """
838
946
  ...
839
947
 
840
- @typing.overload
841
- 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]]]:
948
+ 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]]]:
842
949
  """
843
- Specifies secrets to be retrieved and injected as environment variables prior to
844
- the execution of a step.
950
+ Specifies that this step should execute on DGX cloud.
845
951
 
846
952
 
847
953
  Parameters
848
954
  ----------
849
- sources : List[Union[str, Dict[str, Any]]], default: []
850
- List of secret specs, defining how the secrets are to be retrieved
851
- """
852
- ...
853
-
854
- @typing.overload
855
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
856
- ...
857
-
858
- @typing.overload
859
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
860
- ...
861
-
862
- 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]]] = []):
863
- """
864
- Specifies secrets to be retrieved and injected as environment variables prior to
865
- the execution of a step.
866
-
867
-
868
- Parameters
869
- ----------
870
- sources : List[Union[str, Dict[str, Any]]], default: []
871
- List of secret specs, defining how the secrets are to be retrieved
872
- """
873
- ...
874
-
875
- @typing.overload
876
- 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]]]:
877
- """
878
- Specifies the Conda environment for the step.
879
-
880
- Information in this decorator will augment any
881
- attributes set in the `@conda_base` flow-level decorator. Hence,
882
- you can use `@conda_base` to set packages required by all
883
- steps and use `@conda` to specify step-specific overrides.
884
-
885
-
886
- Parameters
887
- ----------
888
- packages : Dict[str, str], default {}
889
- Packages to use for this step. The key is the name of the package
890
- and the value is the version to use.
891
- libraries : Dict[str, str], default {}
892
- Supported for backward compatibility. When used with packages, packages will take precedence.
893
- python : str, optional, default None
894
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
895
- that the version used will correspond to the version of the Python interpreter used to start the run.
896
- disabled : bool, default False
897
- If set to True, disables @conda.
955
+ gpu : int
956
+ Number of GPUs to use.
957
+ gpu_type : str
958
+ Type of Nvidia GPU to use.
959
+ queue_timeout : int
960
+ Time to keep the job in NVCF's queue.
898
961
  """
899
962
  ...
900
963
 
901
964
  @typing.overload
902
- def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
903
- ...
904
-
905
- @typing.overload
906
- def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
907
- ...
908
-
909
- 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):
965
+ 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]]]:
910
966
  """
911
- Specifies the Conda environment for the step.
912
-
913
- Information in this decorator will augment any
914
- attributes set in the `@conda_base` flow-level decorator. Hence,
915
- you can use `@conda_base` to set packages required by all
916
- steps and use `@conda` to specify step-specific overrides.
967
+ Specifies the number of times the task corresponding
968
+ to a step needs to be retried.
917
969
 
970
+ This decorator is useful for handling transient errors, such as networking issues.
971
+ If your task contains operations that can't be retried safely, e.g. database updates,
972
+ it is advisable to annotate it with `@retry(times=0)`.
918
973
 
919
- Parameters
920
- ----------
921
- packages : Dict[str, str], default {}
922
- Packages to use for this step. The key is the name of the package
923
- and the value is the version to use.
924
- libraries : Dict[str, str], default {}
925
- Supported for backward compatibility. When used with packages, packages will take precedence.
926
- python : str, optional, default None
927
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
928
- that the version used will correspond to the version of the Python interpreter used to start the run.
929
- disabled : bool, default False
930
- If set to True, disables @conda.
931
- """
932
- ...
933
-
934
- 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]]]:
935
- """
936
- Specifies that this step should execute on DGX cloud.
974
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
975
+ decorator will execute a no-op task after all retries have been exhausted,
976
+ ensuring that the flow execution can continue.
937
977
 
938
978
 
939
979
  Parameters
940
980
  ----------
941
- gpu : int
942
- Number of GPUs to use.
943
- gpu_type : str
944
- Type of Nvidia GPU to use.
981
+ times : int, default 3
982
+ Number of times to retry this task.
983
+ minutes_between_retries : int, default 2
984
+ Number of minutes between retries.
945
985
  """
946
986
  ...
947
987
 
948
988
  @typing.overload
949
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
950
- """
951
- Internal decorator to support Fast bakery
952
- """
989
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
953
990
  ...
954
991
 
955
992
  @typing.overload
956
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
957
- ...
958
-
959
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
960
- """
961
- Internal decorator to support Fast bakery
962
- """
993
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
963
994
  ...
964
995
 
965
- 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]]]:
996
+ 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):
966
997
  """
967
- Specifies that this step should execute on DGX cloud.
998
+ Specifies the number of times the task corresponding
999
+ to a step needs to be retried.
968
1000
 
1001
+ This decorator is useful for handling transient errors, such as networking issues.
1002
+ If your task contains operations that can't be retried safely, e.g. database updates,
1003
+ it is advisable to annotate it with `@retry(times=0)`.
969
1004
 
970
- Parameters
971
- ----------
972
- gpu : int
973
- Number of GPUs to use.
974
- gpu_type : str
975
- Type of Nvidia GPU to use.
976
- queue_timeout : int
977
- Time to keep the job in NVCF's queue.
978
- """
979
- ...
980
-
981
- 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]]:
982
- """
983
- 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.
984
- This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
1005
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
1006
+ decorator will execute a no-op task after all retries have been exhausted,
1007
+ ensuring that the flow execution can continue.
985
1008
 
986
1009
 
987
1010
  Parameters
988
1011
  ----------
989
- timeout : int
990
- Time, in seconds before the task times out and fails. (Default: 3600)
991
- poke_interval : int
992
- Time in seconds that the job should wait in between each try. (Default: 60)
993
- mode : str
994
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
995
- exponential_backoff : bool
996
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
997
- pool : str
998
- the slot pool this task should run in,
999
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1000
- soft_fail : bool
1001
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1002
- name : str
1003
- Name of the sensor on Airflow
1004
- description : str
1005
- Description of sensor in the Airflow UI
1006
- external_dag_id : str
1007
- The dag_id that contains the task you want to wait for.
1008
- external_task_ids : List[str]
1009
- The list of task_ids that you want to wait for.
1010
- If None (default value) the sensor waits for the DAG. (Default: None)
1011
- allowed_states : List[str]
1012
- Iterable of allowed states, (Default: ['success'])
1013
- failed_states : List[str]
1014
- Iterable of failed or dis-allowed states. (Default: None)
1015
- execution_delta : datetime.timedelta
1016
- time difference with the previous execution to look at,
1017
- the default is the same logical date as the current task or DAG. (Default: None)
1018
- check_existence: bool
1019
- Set to True to check if the external task exists or check if
1020
- the DAG to wait for exists. (Default: True)
1012
+ times : int, default 3
1013
+ Number of times to retry this task.
1014
+ minutes_between_retries : int, default 2
1015
+ Number of minutes between retries.
1021
1016
  """
1022
1017
  ...
1023
1018
 
1024
1019
  @typing.overload
1025
- 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]]:
1020
+ 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]]:
1026
1021
  """
1027
- Specifies the flow(s) that this flow depends on.
1022
+ Specifies the event(s) that this flow depends on.
1028
1023
 
1029
1024
  ```
1030
- @trigger_on_finish(flow='FooFlow')
1025
+ @trigger(event='foo')
1031
1026
  ```
1032
1027
  or
1033
1028
  ```
1034
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1029
+ @trigger(events=['foo', 'bar'])
1035
1030
  ```
1036
- This decorator respects the @project decorator and triggers the flow
1037
- when upstream runs within the same namespace complete successfully
1038
1031
 
1039
- Additionally, you can specify project aware upstream flow dependencies
1040
- by specifying the fully qualified project_flow_name.
1032
+ Additionally, you can specify the parameter mappings
1033
+ to map event payload to Metaflow parameters for the flow.
1041
1034
  ```
1042
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1035
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1043
1036
  ```
1044
1037
  or
1045
1038
  ```
1046
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1039
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1040
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1047
1041
  ```
1048
1042
 
1049
- You can also specify just the project or project branch (other values will be
1050
- inferred from the current project or project branch):
1043
+ 'parameters' can also be a list of strings and tuples like so:
1051
1044
  ```
1052
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1045
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1046
+ ```
1047
+ This is equivalent to:
1048
+ ```
1049
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1053
1050
  ```
1054
-
1055
- Note that `branch` is typically one of:
1056
- - `prod`
1057
- - `user.bob`
1058
- - `test.my_experiment`
1059
- - `prod.staging`
1060
1051
 
1061
1052
 
1062
1053
  Parameters
1063
1054
  ----------
1064
- flow : Union[str, Dict[str, str]], optional, default None
1065
- Upstream flow dependency for this flow.
1066
- flows : List[Union[str, Dict[str, str]]], default []
1067
- Upstream flow dependencies for this flow.
1055
+ event : Union[str, Dict[str, Any]], optional, default None
1056
+ Event dependency for this flow.
1057
+ events : List[Union[str, Dict[str, Any]]], default []
1058
+ Events dependency for this flow.
1068
1059
  options : Dict[str, Any], default {}
1069
1060
  Backend-specific configuration for tuning eventing behavior.
1070
1061
  """
1071
1062
  ...
1072
1063
 
1073
1064
  @typing.overload
1074
- def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1065
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1075
1066
  ...
1076
1067
 
1077
- def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1068
+ 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] = {}):
1078
1069
  """
1079
- Specifies the flow(s) that this flow depends on.
1070
+ Specifies the event(s) that this flow depends on.
1080
1071
 
1081
1072
  ```
1082
- @trigger_on_finish(flow='FooFlow')
1073
+ @trigger(event='foo')
1083
1074
  ```
1084
1075
  or
1085
1076
  ```
1086
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1077
+ @trigger(events=['foo', 'bar'])
1087
1078
  ```
1088
- This decorator respects the @project decorator and triggers the flow
1089
- when upstream runs within the same namespace complete successfully
1090
1079
 
1091
- Additionally, you can specify project aware upstream flow dependencies
1092
- by specifying the fully qualified project_flow_name.
1080
+ Additionally, you can specify the parameter mappings
1081
+ to map event payload to Metaflow parameters for the flow.
1093
1082
  ```
1094
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1083
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1095
1084
  ```
1096
1085
  or
1097
1086
  ```
1098
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1087
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1088
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1099
1089
  ```
1100
1090
 
1101
- You can also specify just the project or project branch (other values will be
1102
- inferred from the current project or project branch):
1091
+ 'parameters' can also be a list of strings and tuples like so:
1103
1092
  ```
1104
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1093
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1094
+ ```
1095
+ This is equivalent to:
1096
+ ```
1097
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1105
1098
  ```
1106
-
1107
- Note that `branch` is typically one of:
1108
- - `prod`
1109
- - `user.bob`
1110
- - `test.my_experiment`
1111
- - `prod.staging`
1112
1099
 
1113
1100
 
1114
1101
  Parameters
1115
1102
  ----------
1116
- flow : Union[str, Dict[str, str]], optional, default None
1117
- Upstream flow dependency for this flow.
1118
- flows : List[Union[str, Dict[str, str]]], default []
1119
- Upstream flow dependencies for this flow.
1120
- options : Dict[str, Any], default {}
1103
+ event : Union[str, Dict[str, Any]], optional, default None
1104
+ Event dependency for this flow.
1105
+ events : List[Union[str, Dict[str, Any]]], default []
1106
+ Events dependency for this flow.
1107
+ options : Dict[str, Any], default {}
1121
1108
  Backend-specific configuration for tuning eventing behavior.
1122
1109
  """
1123
1110
  ...
1124
1111
 
1112
+ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1113
+ """
1114
+ Allows setting external datastores to save data for the
1115
+ `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1116
+
1117
+ This decorator is useful when users wish to save data to a different datastore
1118
+ than what is configured in Metaflow. This can be for variety of reasons:
1119
+
1120
+ 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1121
+ 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1122
+ - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1123
+ 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1124
+ - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1125
+
1126
+ Usage:
1127
+ ----------
1128
+
1129
+ - Using a custom IAM role to access the datastore.
1130
+
1131
+ ```python
1132
+ @with_artifact_store(
1133
+ type="s3",
1134
+ config=lambda: {
1135
+ "root": "s3://my-bucket-foo/path/to/root",
1136
+ "role_arn": ROLE,
1137
+ },
1138
+ )
1139
+ class MyFlow(FlowSpec):
1140
+
1141
+ @checkpoint
1142
+ @step
1143
+ def start(self):
1144
+ with open("my_file.txt", "w") as f:
1145
+ f.write("Hello, World!")
1146
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1147
+ self.next(self.end)
1148
+
1149
+ ```
1150
+
1151
+ - Using credentials to access the s3-compatible datastore.
1152
+
1153
+ ```python
1154
+ @with_artifact_store(
1155
+ type="s3",
1156
+ config=lambda: {
1157
+ "root": "s3://my-bucket-foo/path/to/root",
1158
+ "client_params": {
1159
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1160
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1161
+ },
1162
+ },
1163
+ )
1164
+ class MyFlow(FlowSpec):
1165
+
1166
+ @checkpoint
1167
+ @step
1168
+ def start(self):
1169
+ with open("my_file.txt", "w") as f:
1170
+ f.write("Hello, World!")
1171
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1172
+ self.next(self.end)
1173
+
1174
+ ```
1175
+
1176
+ - Accessing objects stored in external datastores after task execution.
1177
+
1178
+ ```python
1179
+ run = Run("CheckpointsTestsFlow/8992")
1180
+ with artifact_store_from(run=run, config={
1181
+ "client_params": {
1182
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1183
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1184
+ },
1185
+ }):
1186
+ with Checkpoint() as cp:
1187
+ latest = cp.list(
1188
+ task=run["start"].task
1189
+ )[0]
1190
+ print(latest)
1191
+ cp.load(
1192
+ latest,
1193
+ "test-checkpoints"
1194
+ )
1195
+
1196
+ task = Task("TorchTuneFlow/8484/train/53673")
1197
+ with artifact_store_from(run=run, config={
1198
+ "client_params": {
1199
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1200
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1201
+ },
1202
+ }):
1203
+ load_model(
1204
+ task.data.model_ref,
1205
+ "test-models"
1206
+ )
1207
+ ```
1208
+ Parameters:
1209
+ ----------
1210
+
1211
+ type: str
1212
+ The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1213
+
1214
+ config: dict or Callable
1215
+ Dictionary of configuration options for the datastore. The following keys are required:
1216
+ - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1217
+ - example: 's3://bucket-name/path/to/root'
1218
+ - example: 'gs://bucket-name/path/to/root'
1219
+ - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1220
+ - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1221
+ - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1222
+ - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1223
+ """
1224
+ ...
1225
+
1226
+ 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]]:
1227
+ """
1228
+ 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)
1229
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1230
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1231
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1232
+ starts only after all sensors finish.
1233
+
1234
+
1235
+ Parameters
1236
+ ----------
1237
+ timeout : int
1238
+ Time, in seconds before the task times out and fails. (Default: 3600)
1239
+ poke_interval : int
1240
+ Time in seconds that the job should wait in between each try. (Default: 60)
1241
+ mode : str
1242
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1243
+ exponential_backoff : bool
1244
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1245
+ pool : str
1246
+ the slot pool this task should run in,
1247
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1248
+ soft_fail : bool
1249
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1250
+ name : str
1251
+ Name of the sensor on Airflow
1252
+ description : str
1253
+ Description of sensor in the Airflow UI
1254
+ bucket_key : Union[str, List[str]]
1255
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1256
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1257
+ bucket_name : str
1258
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1259
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1260
+ wildcard_match : bool
1261
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1262
+ aws_conn_id : str
1263
+ a reference to the s3 connection on Airflow. (Default: None)
1264
+ verify : bool
1265
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1266
+ """
1267
+ ...
1268
+
1269
+ def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1270
+ """
1271
+ Specifies what flows belong to the same project.
1272
+
1273
+ A project-specific namespace is created for all flows that
1274
+ use the same `@project(name)`.
1275
+
1276
+
1277
+ Parameters
1278
+ ----------
1279
+ name : str
1280
+ Project name. Make sure that the name is unique amongst all
1281
+ projects that use the same production scheduler. The name may
1282
+ contain only lowercase alphanumeric characters and underscores.
1283
+
1284
+ branch : Optional[str], default None
1285
+ The branch to use. If not specified, the branch is set to
1286
+ `user.<username>` unless `production` is set to `True`. This can
1287
+ also be set on the command line using `--branch` as a top-level option.
1288
+ It is an error to specify `branch` in the decorator and on the command line.
1289
+
1290
+ production : bool, default False
1291
+ Whether or not the branch is the production branch. This can also be set on the
1292
+ command line using `--production` as a top-level option. It is an error to specify
1293
+ `production` in the decorator and on the command line.
1294
+ The project branch name will be:
1295
+ - if `branch` is specified:
1296
+ - if `production` is True: `prod.<branch>`
1297
+ - if `production` is False: `test.<branch>`
1298
+ - if `branch` is not specified:
1299
+ - if `production` is True: `prod`
1300
+ - if `production` is False: `user.<username>`
1301
+ """
1302
+ ...
1303
+
1125
1304
  @typing.overload
1126
1305
  def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1127
1306
  """
@@ -1173,13 +1352,10 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
1173
1352
  """
1174
1353
  ...
1175
1354
 
1176
- 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]]:
1355
+ 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]]:
1177
1356
  """
1178
- 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)
1179
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1180
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1181
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1182
- starts only after all sensors finish.
1357
+ 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.
1358
+ This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
1183
1359
 
1184
1360
 
1185
1361
  Parameters
@@ -1201,18 +1377,21 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
1201
1377
  Name of the sensor on Airflow
1202
1378
  description : str
1203
1379
  Description of sensor in the Airflow UI
1204
- bucket_key : Union[str, List[str]]
1205
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1206
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1207
- bucket_name : str
1208
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1209
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1210
- wildcard_match : bool
1211
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1212
- aws_conn_id : str
1213
- a reference to the s3 connection on Airflow. (Default: None)
1214
- verify : bool
1215
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1380
+ external_dag_id : str
1381
+ The dag_id that contains the task you want to wait for.
1382
+ external_task_ids : List[str]
1383
+ The list of task_ids that you want to wait for.
1384
+ If None (default value) the sensor waits for the DAG. (Default: None)
1385
+ allowed_states : List[str]
1386
+ Iterable of allowed states, (Default: ['success'])
1387
+ failed_states : List[str]
1388
+ Iterable of failed or dis-allowed states. (Default: None)
1389
+ execution_delta : datetime.timedelta
1390
+ time difference with the previous execution to look at,
1391
+ the default is the same logical date as the current task or DAG. (Default: None)
1392
+ check_existence: bool
1393
+ Set to True to check if the external task exists or check if
1394
+ the DAG to wait for exists. (Default: True)
1216
1395
  """
1217
1396
  ...
1218
1397
 
@@ -1268,285 +1447,144 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
1268
1447
  ...
1269
1448
 
1270
1449
  @typing.overload
1271
- def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1450
+ 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]]:
1272
1451
  """
1273
- Specifies the PyPI packages for all steps of the flow.
1452
+ Specifies the flow(s) that this flow depends on.
1274
1453
 
1275
- Use `@pypi_base` to set common packages required by all
1276
- steps and use `@pypi` to specify step-specific overrides.
1277
-
1278
- Parameters
1279
- ----------
1280
- packages : Dict[str, str], default: {}
1281
- Packages to use for this flow. The key is the name of the package
1282
- and the value is the version to use.
1283
- python : str, optional, default: None
1284
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1285
- that the version used will correspond to the version of the Python interpreter used to start the run.
1286
- """
1287
- ...
1288
-
1289
- @typing.overload
1290
- def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1291
- ...
1292
-
1293
- def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1294
- """
1295
- Specifies the PyPI packages for all steps of the flow.
1296
-
1297
- Use `@pypi_base` to set common packages required by all
1298
- steps and use `@pypi` to specify step-specific overrides.
1299
-
1300
- Parameters
1301
- ----------
1302
- packages : Dict[str, str], default: {}
1303
- Packages to use for this flow. The key is the name of the package
1304
- and the value is the version to use.
1305
- python : str, optional, default: None
1306
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1307
- that the version used will correspond to the version of the Python interpreter used to start the run.
1308
- """
1309
- ...
1310
-
1311
- @typing.overload
1312
- 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]]:
1313
- """
1314
- Specifies the event(s) that this flow depends on.
1454
+ ```
1455
+ @trigger_on_finish(flow='FooFlow')
1456
+ ```
1457
+ or
1458
+ ```
1459
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1460
+ ```
1461
+ This decorator respects the @project decorator and triggers the flow
1462
+ when upstream runs within the same namespace complete successfully
1315
1463
 
1464
+ Additionally, you can specify project aware upstream flow dependencies
1465
+ by specifying the fully qualified project_flow_name.
1316
1466
  ```
1317
- @trigger(event='foo')
1467
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1318
1468
  ```
1319
1469
  or
1320
1470
  ```
1321
- @trigger(events=['foo', 'bar'])
1471
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1322
1472
  ```
1323
1473
 
1324
- Additionally, you can specify the parameter mappings
1325
- to map event payload to Metaflow parameters for the flow.
1326
- ```
1327
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1328
- ```
1329
- or
1474
+ You can also specify just the project or project branch (other values will be
1475
+ inferred from the current project or project branch):
1330
1476
  ```
1331
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1332
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1477
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1333
1478
  ```
1334
1479
 
1335
- 'parameters' can also be a list of strings and tuples like so:
1336
- ```
1337
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1338
- ```
1339
- This is equivalent to:
1340
- ```
1341
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1342
- ```
1480
+ Note that `branch` is typically one of:
1481
+ - `prod`
1482
+ - `user.bob`
1483
+ - `test.my_experiment`
1484
+ - `prod.staging`
1343
1485
 
1344
1486
 
1345
1487
  Parameters
1346
1488
  ----------
1347
- event : Union[str, Dict[str, Any]], optional, default None
1348
- Event dependency for this flow.
1349
- events : List[Union[str, Dict[str, Any]]], default []
1350
- Events dependency for this flow.
1489
+ flow : Union[str, Dict[str, str]], optional, default None
1490
+ Upstream flow dependency for this flow.
1491
+ flows : List[Union[str, Dict[str, str]]], default []
1492
+ Upstream flow dependencies for this flow.
1351
1493
  options : Dict[str, Any], default {}
1352
1494
  Backend-specific configuration for tuning eventing behavior.
1353
1495
  """
1354
1496
  ...
1355
1497
 
1356
1498
  @typing.overload
1357
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1499
+ def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1358
1500
  ...
1359
1501
 
1360
- 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] = {}):
1502
+ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1361
1503
  """
1362
- Specifies the event(s) that this flow depends on.
1504
+ Specifies the flow(s) that this flow depends on.
1363
1505
 
1364
1506
  ```
1365
- @trigger(event='foo')
1507
+ @trigger_on_finish(flow='FooFlow')
1366
1508
  ```
1367
1509
  or
1368
1510
  ```
1369
- @trigger(events=['foo', 'bar'])
1511
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1370
1512
  ```
1513
+ This decorator respects the @project decorator and triggers the flow
1514
+ when upstream runs within the same namespace complete successfully
1371
1515
 
1372
- Additionally, you can specify the parameter mappings
1373
- to map event payload to Metaflow parameters for the flow.
1516
+ Additionally, you can specify project aware upstream flow dependencies
1517
+ by specifying the fully qualified project_flow_name.
1374
1518
  ```
1375
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1519
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1376
1520
  ```
1377
1521
  or
1378
1522
  ```
1379
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1380
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1523
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1381
1524
  ```
1382
1525
 
1383
- 'parameters' can also be a list of strings and tuples like so:
1384
- ```
1385
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1386
- ```
1387
- This is equivalent to:
1526
+ You can also specify just the project or project branch (other values will be
1527
+ inferred from the current project or project branch):
1388
1528
  ```
1389
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1529
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1390
1530
  ```
1391
1531
 
1532
+ Note that `branch` is typically one of:
1533
+ - `prod`
1534
+ - `user.bob`
1535
+ - `test.my_experiment`
1536
+ - `prod.staging`
1537
+
1392
1538
 
1393
1539
  Parameters
1394
1540
  ----------
1395
- event : Union[str, Dict[str, Any]], optional, default None
1396
- Event dependency for this flow.
1397
- events : List[Union[str, Dict[str, Any]]], default []
1398
- Events dependency for this flow.
1541
+ flow : Union[str, Dict[str, str]], optional, default None
1542
+ Upstream flow dependency for this flow.
1543
+ flows : List[Union[str, Dict[str, str]]], default []
1544
+ Upstream flow dependencies for this flow.
1399
1545
  options : Dict[str, Any], default {}
1400
1546
  Backend-specific configuration for tuning eventing behavior.
1401
1547
  """
1402
1548
  ...
1403
1549
 
1404
- def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1550
+ @typing.overload
1551
+ def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1405
1552
  """
1406
- Allows setting external datastores to save data for the
1407
- `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1408
-
1409
- This decorator is useful when users wish to save data to a different datastore
1410
- than what is configured in Metaflow. This can be for variety of reasons:
1411
-
1412
- 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1413
- 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1414
- - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1415
- 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1416
- - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1417
-
1418
- Usage:
1419
- ----------
1420
-
1421
- - Using a custom IAM role to access the datastore.
1422
-
1423
- ```python
1424
- @with_artifact_store(
1425
- type="s3",
1426
- config=lambda: {
1427
- "root": "s3://my-bucket-foo/path/to/root",
1428
- "role_arn": ROLE,
1429
- },
1430
- )
1431
- class MyFlow(FlowSpec):
1432
-
1433
- @checkpoint
1434
- @step
1435
- def start(self):
1436
- with open("my_file.txt", "w") as f:
1437
- f.write("Hello, World!")
1438
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1439
- self.next(self.end)
1440
-
1441
- ```
1442
-
1443
- - Using credentials to access the s3-compatible datastore.
1444
-
1445
- ```python
1446
- @with_artifact_store(
1447
- type="s3",
1448
- config=lambda: {
1449
- "root": "s3://my-bucket-foo/path/to/root",
1450
- "client_params": {
1451
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1452
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1453
- },
1454
- },
1455
- )
1456
- class MyFlow(FlowSpec):
1457
-
1458
- @checkpoint
1459
- @step
1460
- def start(self):
1461
- with open("my_file.txt", "w") as f:
1462
- f.write("Hello, World!")
1463
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1464
- self.next(self.end)
1465
-
1466
- ```
1467
-
1468
- - Accessing objects stored in external datastores after task execution.
1553
+ Specifies the PyPI packages for all steps of the flow.
1469
1554
 
1470
- ```python
1471
- run = Run("CheckpointsTestsFlow/8992")
1472
- with artifact_store_from(run=run, config={
1473
- "client_params": {
1474
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1475
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1476
- },
1477
- }):
1478
- with Checkpoint() as cp:
1479
- latest = cp.list(
1480
- task=run["start"].task
1481
- )[0]
1482
- print(latest)
1483
- cp.load(
1484
- latest,
1485
- "test-checkpoints"
1486
- )
1555
+ Use `@pypi_base` to set common packages required by all
1556
+ steps and use `@pypi` to specify step-specific overrides.
1487
1557
 
1488
- task = Task("TorchTuneFlow/8484/train/53673")
1489
- with artifact_store_from(run=run, config={
1490
- "client_params": {
1491
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1492
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1493
- },
1494
- }):
1495
- load_model(
1496
- task.data.model_ref,
1497
- "test-models"
1498
- )
1499
- ```
1500
- Parameters:
1558
+ Parameters
1501
1559
  ----------
1502
-
1503
- type: str
1504
- The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1505
-
1506
- config: dict or Callable
1507
- Dictionary of configuration options for the datastore. The following keys are required:
1508
- - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1509
- - example: 's3://bucket-name/path/to/root'
1510
- - example: 'gs://bucket-name/path/to/root'
1511
- - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1512
- - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1513
- - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1514
- - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1560
+ packages : Dict[str, str], default: {}
1561
+ Packages to use for this flow. The key is the name of the package
1562
+ and the value is the version to use.
1563
+ python : str, optional, default: None
1564
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1565
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1515
1566
  """
1516
1567
  ...
1517
1568
 
1518
- def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1569
+ @typing.overload
1570
+ def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1571
+ ...
1572
+
1573
+ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1519
1574
  """
1520
- Specifies what flows belong to the same project.
1521
-
1522
- A project-specific namespace is created for all flows that
1523
- use the same `@project(name)`.
1575
+ Specifies the PyPI packages for all steps of the flow.
1524
1576
 
1577
+ Use `@pypi_base` to set common packages required by all
1578
+ steps and use `@pypi` to specify step-specific overrides.
1525
1579
 
1526
1580
  Parameters
1527
1581
  ----------
1528
- name : str
1529
- Project name. Make sure that the name is unique amongst all
1530
- projects that use the same production scheduler. The name may
1531
- contain only lowercase alphanumeric characters and underscores.
1532
-
1533
- branch : Optional[str], default None
1534
- The branch to use. If not specified, the branch is set to
1535
- `user.<username>` unless `production` is set to `True`. This can
1536
- also be set on the command line using `--branch` as a top-level option.
1537
- It is an error to specify `branch` in the decorator and on the command line.
1538
-
1539
- production : bool, default False
1540
- Whether or not the branch is the production branch. This can also be set on the
1541
- command line using `--production` as a top-level option. It is an error to specify
1542
- `production` in the decorator and on the command line.
1543
- The project branch name will be:
1544
- - if `branch` is specified:
1545
- - if `production` is True: `prod.<branch>`
1546
- - if `production` is False: `test.<branch>`
1547
- - if `branch` is not specified:
1548
- - if `production` is True: `prod`
1549
- - if `production` is False: `user.<username>`
1582
+ packages : Dict[str, str], default: {}
1583
+ Packages to use for this flow. The key is the name of the package
1584
+ and the value is the version to use.
1585
+ python : str, optional, default: None
1586
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1587
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1550
1588
  """
1551
1589
  ...
1552
1590