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