ob-metaflow-stubs 6.0.4.8__py2.py3-none-any.whl → 6.0.4.9__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 (249) hide show
  1. metaflow-stubs/__init__.pyi +948 -948
  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 +3 -3
  8. metaflow-stubs/client/filecache.pyi +2 -2
  9. metaflow-stubs/events.pyi +2 -2
  10. metaflow-stubs/exception.pyi +1 -1
  11. metaflow-stubs/flowspec.pyi +4 -4
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +2 -2
  14. metaflow-stubs/info_file.pyi +1 -1
  15. metaflow-stubs/metadata_provider/__init__.pyi +1 -1
  16. metaflow-stubs/metadata_provider/heartbeat.pyi +1 -1
  17. metaflow-stubs/metadata_provider/metadata.pyi +1 -1
  18. metaflow-stubs/metadata_provider/util.pyi +1 -1
  19. metaflow-stubs/metaflow_config.pyi +1 -1
  20. metaflow-stubs/metaflow_current.pyi +51 -51
  21. metaflow-stubs/metaflow_git.pyi +1 -1
  22. metaflow-stubs/mf_extensions/__init__.pyi +1 -1
  23. metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
  24. metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
  25. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
  26. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
  27. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
  28. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
  29. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +2 -2
  30. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +1 -1
  31. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
  32. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +2 -2
  33. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
  34. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +3 -3
  35. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
  36. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +2 -2
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +2 -2
  38. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
  39. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +1 -1
  40. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +1 -1
  41. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +1 -1
  42. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +3 -3
  43. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +2 -2
  44. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +1 -1
  45. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +1 -1
  46. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +2 -2
  47. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
  48. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +1 -1
  49. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
  50. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
  51. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +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 +2 -2
  60. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
  61. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
  62. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +1 -1
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +1 -1
  64. metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +1 -1
  65. metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
  66. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/__init__.pyi +1 -1
  67. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/__init__.pyi +1 -1
  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 +1 -1
  73. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/app_config.pyi +1 -1
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/capsule.pyi +4 -4
  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 +1 -1
  78. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/__init__.pyi +1 -1
  79. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/cli_generator.pyi +1 -1
  80. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/config_utils.pyi +2 -2
  81. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/schema_export.pyi +1 -1
  82. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/typed_configs.pyi +2 -2
  83. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/unified_config.pyi +2 -2
  84. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/dependencies.pyi +2 -2
  85. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/deployer.pyi +4 -4
  86. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/experimental/__init__.pyi +1 -1
  87. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/perimeters.pyi +1 -1
  88. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/utils.pyi +2 -2
  89. metaflow-stubs/mf_extensions/outerbounds/plugins/aws/__init__.pyi +1 -1
  90. metaflow-stubs/mf_extensions/outerbounds/plugins/aws/assume_role_decorator.pyi +1 -1
  91. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
  92. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +1 -1
  93. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
  94. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
  95. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
  96. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
  97. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +1 -1
  98. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +2 -2
  99. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +1 -1
  100. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +1 -1
  101. metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +1 -1
  102. metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +1 -1
  103. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
  104. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +1 -1
  105. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +1 -1
  106. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +1 -1
  107. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +1 -1
  108. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
  109. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
  110. metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
  111. metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
  112. metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
  113. metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
  114. metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
  115. metaflow-stubs/multicore_utils.pyi +1 -1
  116. metaflow-stubs/ob_internal.pyi +1 -1
  117. metaflow-stubs/parameters.pyi +2 -2
  118. metaflow-stubs/plugins/__init__.pyi +11 -11
  119. metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
  120. metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
  121. metaflow-stubs/plugins/airflow/exception.pyi +1 -1
  122. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
  123. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
  124. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
  125. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
  126. metaflow-stubs/plugins/argo/__init__.pyi +1 -1
  127. metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
  128. metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
  129. metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
  130. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +2 -2
  131. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +2 -2
  132. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +2 -2
  133. metaflow-stubs/plugins/argo/exit_hooks.pyi +1 -1
  134. metaflow-stubs/plugins/aws/__init__.pyi +1 -1
  135. metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
  136. metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
  137. metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
  138. metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
  139. metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
  140. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
  141. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
  142. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +4 -4
  143. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
  144. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
  145. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
  146. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
  147. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
  148. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +2 -2
  149. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
  150. metaflow-stubs/plugins/azure/__init__.pyi +1 -1
  151. metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
  152. metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
  153. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +4 -4
  154. metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
  155. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
  156. metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
  157. metaflow-stubs/plugins/cards/__init__.pyi +1 -1
  158. metaflow-stubs/plugins/cards/card_client.pyi +1 -1
  159. metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
  160. metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
  161. metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
  162. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
  163. metaflow-stubs/plugins/cards/card_modules/basic.pyi +1 -1
  164. metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
  165. metaflow-stubs/plugins/cards/card_modules/components.pyi +2 -2
  166. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
  167. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
  168. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
  169. metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
  170. metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
  171. metaflow-stubs/plugins/cards/exception.pyi +1 -1
  172. metaflow-stubs/plugins/catch_decorator.pyi +2 -2
  173. metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
  174. metaflow-stubs/plugins/datatools/local.pyi +1 -1
  175. metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
  176. metaflow-stubs/plugins/datatools/s3/s3.pyi +1 -1
  177. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
  178. metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
  179. metaflow-stubs/plugins/debug_logger.pyi +1 -1
  180. metaflow-stubs/plugins/debug_monitor.pyi +1 -1
  181. metaflow-stubs/plugins/environment_decorator.pyi +1 -1
  182. metaflow-stubs/plugins/events_decorator.pyi +1 -1
  183. metaflow-stubs/plugins/exit_hook/__init__.pyi +1 -1
  184. metaflow-stubs/plugins/exit_hook/exit_hook_decorator.pyi +1 -1
  185. metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
  186. metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
  187. metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
  188. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +4 -4
  189. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
  190. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
  191. metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
  192. metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
  193. metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
  194. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +1 -1
  195. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
  196. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
  197. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
  198. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
  199. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
  200. metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
  201. metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
  202. metaflow-stubs/plugins/perimeters.pyi +1 -1
  203. metaflow-stubs/plugins/project_decorator.pyi +1 -1
  204. metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
  205. metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
  206. metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
  207. metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
  208. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
  209. metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
  210. metaflow-stubs/plugins/pypi/utils.pyi +1 -1
  211. metaflow-stubs/plugins/resources_decorator.pyi +1 -1
  212. metaflow-stubs/plugins/retry_decorator.pyi +1 -1
  213. metaflow-stubs/plugins/secrets/__init__.pyi +1 -1
  214. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +2 -2
  215. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
  216. metaflow-stubs/plugins/secrets/secrets_func.pyi +1 -1
  217. metaflow-stubs/plugins/secrets/secrets_spec.pyi +1 -1
  218. metaflow-stubs/plugins/secrets/utils.pyi +1 -1
  219. metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
  220. metaflow-stubs/plugins/storage_executor.pyi +1 -1
  221. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
  222. metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
  223. metaflow-stubs/plugins/torchtune/__init__.pyi +1 -1
  224. metaflow-stubs/plugins/uv/__init__.pyi +1 -1
  225. metaflow-stubs/plugins/uv/uv_environment.pyi +1 -1
  226. metaflow-stubs/profilers/__init__.pyi +1 -1
  227. metaflow-stubs/pylint_wrapper.pyi +1 -1
  228. metaflow-stubs/runner/__init__.pyi +1 -1
  229. metaflow-stubs/runner/deployer.pyi +4 -4
  230. metaflow-stubs/runner/deployer_impl.pyi +2 -2
  231. metaflow-stubs/runner/metaflow_runner.pyi +3 -3
  232. metaflow-stubs/runner/nbdeploy.pyi +1 -1
  233. metaflow-stubs/runner/nbrun.pyi +1 -1
  234. metaflow-stubs/runner/subprocess_manager.pyi +1 -1
  235. metaflow-stubs/runner/utils.pyi +2 -2
  236. metaflow-stubs/system/__init__.pyi +1 -1
  237. metaflow-stubs/system/system_logger.pyi +2 -2
  238. metaflow-stubs/system/system_monitor.pyi +1 -1
  239. metaflow-stubs/tagging_util.pyi +1 -1
  240. metaflow-stubs/tuple_util.pyi +1 -1
  241. metaflow-stubs/user_configs/__init__.pyi +1 -1
  242. metaflow-stubs/user_configs/config_decorators.pyi +5 -5
  243. metaflow-stubs/user_configs/config_options.pyi +2 -2
  244. metaflow-stubs/user_configs/config_parameters.pyi +6 -6
  245. {ob_metaflow_stubs-6.0.4.8.dist-info → ob_metaflow_stubs-6.0.4.9.dist-info}/METADATA +1 -1
  246. ob_metaflow_stubs-6.0.4.9.dist-info/RECORD +249 -0
  247. ob_metaflow_stubs-6.0.4.8.dist-info/RECORD +0 -249
  248. {ob_metaflow_stubs-6.0.4.8.dist-info → ob_metaflow_stubs-6.0.4.9.dist-info}/WHEEL +0 -0
  249. {ob_metaflow_stubs-6.0.4.8.dist-info → ob_metaflow_stubs-6.0.4.9.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
3
  # MF version: 2.15.21.5+obcheckpoint(0.2.4);ob(v1) #
4
- # Generated on 2025-07-29T18:33:44.107085 #
4
+ # Generated on 2025-07-30T20:52:28.447575 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
@@ -35,8 +35,8 @@ from .user_configs.config_parameters import ConfigValue as ConfigValue
35
35
  from .user_configs.config_parameters import config_expr as config_expr
36
36
  from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
37
37
  from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
38
- from . import tuple_util as tuple_util
39
38
  from . import cards as cards
39
+ from . import tuple_util as tuple_util
40
40
  from . import metaflow_git as metaflow_git
41
41
  from . import events as events
42
42
  from . import runner as runner
@@ -157,484 +157,382 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
157
157
  ...
158
158
 
159
159
  @typing.overload
160
- 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
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
161
161
  """
162
- Specifies the resources needed when executing this step.
163
-
164
- Use `@resources` to specify the resource requirements
165
- independently of the specific compute layer (`@batch`, `@kubernetes`).
166
-
167
- You can choose the compute layer on the command line by executing e.g.
168
- ```
169
- python myflow.py run --with batch
170
- ```
171
- or
172
- ```
173
- python myflow.py run --with kubernetes
174
- ```
175
- which executes the flow on the desired system using the
176
- requirements specified in `@resources`.
177
-
178
-
179
- Parameters
180
- ----------
181
- cpu : int, default 1
182
- Number of CPUs required for this step.
183
- gpu : int, optional, default None
184
- Number of GPUs required for this step.
185
- disk : int, optional, default None
186
- Disk size (in MB) required for this step. Only applies on Kubernetes.
187
- memory : int, default 4096
188
- Memory size (in MB) required for this step.
189
- shared_memory : int, optional, default None
190
- The value for the size (in MiB) of the /dev/shm volume for this step.
191
- This parameter maps to the `--shm-size` option in Docker.
162
+ Decorator prototype for all step decorators. This function gets specialized
163
+ and imported for all decorators types by _import_plugin_decorators().
192
164
  """
193
165
  ...
194
166
 
195
167
  @typing.overload
196
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
168
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
197
169
  ...
198
170
 
199
- @typing.overload
200
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
171
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
172
+ """
173
+ Decorator prototype for all step decorators. This function gets specialized
174
+ and imported for all decorators types by _import_plugin_decorators().
175
+ """
201
176
  ...
202
177
 
203
- 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):
178
+ 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]]]:
204
179
  """
205
- Specifies the resources needed when executing this step.
180
+ This decorator is used to run Ollama APIs as Metaflow task sidecars.
206
181
 
207
- Use `@resources` to specify the resource requirements
208
- independently of the specific compute layer (`@batch`, `@kubernetes`).
182
+ User code call
183
+ --------------
184
+ @ollama(
185
+ models=[...],
186
+ ...
187
+ )
209
188
 
210
- You can choose the compute layer on the command line by executing e.g.
211
- ```
212
- python myflow.py run --with batch
213
- ```
214
- or
215
- ```
216
- python myflow.py run --with kubernetes
217
- ```
218
- which executes the flow on the desired system using the
219
- requirements specified in `@resources`.
189
+ Valid backend options
190
+ ---------------------
191
+ - 'local': Run as a separate process on the local task machine.
192
+ - (TODO) 'managed': Outerbounds hosts and selects compute provider.
193
+ - (TODO) 'remote': Spin up separate instance to serve Ollama models.
194
+
195
+ Valid model options
196
+ -------------------
197
+ Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
220
198
 
221
199
 
222
200
  Parameters
223
201
  ----------
224
- cpu : int, default 1
225
- Number of CPUs required for this step.
226
- gpu : int, optional, default None
227
- Number of GPUs required for this step.
228
- disk : int, optional, default None
229
- Disk size (in MB) required for this step. Only applies on Kubernetes.
230
- memory : int, default 4096
231
- Memory size (in MB) required for this step.
232
- shared_memory : int, optional, default None
233
- The value for the size (in MiB) of the /dev/shm volume for this step.
234
- This parameter maps to the `--shm-size` option in Docker.
235
- """
236
- ...
237
-
238
- @typing.overload
239
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
240
- """
241
- Internal decorator to support Fast bakery
202
+ models: list[str]
203
+ List of Ollama containers running models in sidecars.
204
+ backend: str
205
+ Determines where and how to run the Ollama process.
206
+ force_pull: bool
207
+ Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
208
+ cache_update_policy: str
209
+ Cache update policy: "auto", "force", or "never".
210
+ force_cache_update: bool
211
+ Simple override for "force" cache update policy.
212
+ debug: bool
213
+ Whether to turn on verbose debugging logs.
214
+ circuit_breaker_config: dict
215
+ Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
216
+ timeout_config: dict
217
+ Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
242
218
  """
243
219
  ...
244
220
 
245
- @typing.overload
246
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
247
- ...
248
-
249
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
221
+ 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]]]:
250
222
  """
251
- Internal decorator to support Fast bakery
223
+ Specifies that this step should execute on Kubernetes.
224
+
225
+
226
+ Parameters
227
+ ----------
228
+ cpu : int, default 1
229
+ Number of CPUs required for this step. If `@resources` is
230
+ also present, the maximum value from all decorators is used.
231
+ memory : int, default 4096
232
+ Memory size (in MB) required for this step. If
233
+ `@resources` is also present, the maximum value from all decorators is
234
+ used.
235
+ disk : int, default 10240
236
+ Disk size (in MB) required for this step. If
237
+ `@resources` is also present, the maximum value from all decorators is
238
+ used.
239
+ image : str, optional, default None
240
+ Docker image to use when launching on Kubernetes. If not specified, and
241
+ METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
242
+ not, a default Docker image mapping to the current version of Python is used.
243
+ image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
244
+ If given, the imagePullPolicy to be applied to the Docker image of the step.
245
+ image_pull_secrets: List[str], default []
246
+ The default is extracted from METAFLOW_KUBERNETES_IMAGE_PULL_SECRETS.
247
+ Kubernetes image pull secrets to use when pulling container images
248
+ in Kubernetes.
249
+ service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
250
+ Kubernetes service account to use when launching pod in Kubernetes.
251
+ secrets : List[str], optional, default None
252
+ Kubernetes secrets to use when launching pod in Kubernetes. These
253
+ secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
254
+ in Metaflow configuration.
255
+ node_selector: Union[Dict[str,str], str], optional, default None
256
+ Kubernetes node selector(s) to apply to the pod running the task.
257
+ Can be passed in as a comma separated string of values e.g.
258
+ 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
259
+ {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
260
+ namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
261
+ Kubernetes namespace to use when launching pod in Kubernetes.
262
+ gpu : int, optional, default None
263
+ Number of GPUs required for this step. A value of zero implies that
264
+ the scheduled node should not have GPUs.
265
+ gpu_vendor : str, default KUBERNETES_GPU_VENDOR
266
+ The vendor of the GPUs to be used for this step.
267
+ tolerations : List[str], default []
268
+ The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
269
+ Kubernetes tolerations to use when launching pod in Kubernetes.
270
+ labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
271
+ Kubernetes labels to use when launching pod in Kubernetes.
272
+ annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
273
+ Kubernetes annotations to use when launching pod in Kubernetes.
274
+ use_tmpfs : bool, default False
275
+ This enables an explicit tmpfs mount for this step.
276
+ tmpfs_tempdir : bool, default True
277
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
278
+ tmpfs_size : int, optional, default: None
279
+ The value for the size (in MiB) of the tmpfs mount for this step.
280
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
281
+ memory allocated for this step.
282
+ tmpfs_path : str, optional, default /metaflow_temp
283
+ Path to tmpfs mount for this step.
284
+ persistent_volume_claims : Dict[str, str], optional, default None
285
+ A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
286
+ volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
287
+ shared_memory: int, optional
288
+ Shared memory size (in MiB) required for this step
289
+ port: int, optional
290
+ Port number to specify in the Kubernetes job object
291
+ compute_pool : str, optional, default None
292
+ Compute pool to be used for for this step.
293
+ If not specified, any accessible compute pool within the perimeter is used.
294
+ hostname_resolution_timeout: int, default 10 * 60
295
+ Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
296
+ Only applicable when @parallel is used.
297
+ qos: str, default: Burstable
298
+ Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
299
+
300
+ security_context: Dict[str, Any], optional, default None
301
+ Container security context. Applies to the task container. Allows the following keys:
302
+ - privileged: bool, optional, default None
303
+ - allow_privilege_escalation: bool, optional, default None
304
+ - run_as_user: int, optional, default None
305
+ - run_as_group: int, optional, default None
306
+ - run_as_non_root: bool, optional, default None
252
307
  """
253
308
  ...
254
309
 
255
310
  @typing.overload
256
- def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
311
+ 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]]]:
257
312
  """
258
- Specifies secrets to be retrieved and injected as environment variables prior to
259
- the execution of a step.
313
+ Specifies that the step will success under all circumstances.
314
+
315
+ The decorator will create an optional artifact, specified by `var`, which
316
+ contains the exception raised. You can use it to detect the presence
317
+ of errors, indicating that all happy-path artifacts produced by the step
318
+ are missing.
260
319
 
261
320
 
262
321
  Parameters
263
322
  ----------
264
- sources : List[Union[str, Dict[str, Any]]], default: []
265
- List of secret specs, defining how the secrets are to be retrieved
266
- role : str, optional, default: None
267
- Role to use for fetching secrets
323
+ var : str, optional, default None
324
+ Name of the artifact in which to store the caught exception.
325
+ If not specified, the exception is not stored.
326
+ print_exception : bool, default True
327
+ Determines whether or not the exception is printed to
328
+ stdout when caught.
268
329
  """
269
330
  ...
270
331
 
271
332
  @typing.overload
272
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
333
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
273
334
  ...
274
335
 
275
336
  @typing.overload
276
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
337
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
277
338
  ...
278
339
 
279
- def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None):
340
+ 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):
280
341
  """
281
- Specifies secrets to be retrieved and injected as environment variables prior to
282
- the execution of a step.
342
+ Specifies that the step will success under all circumstances.
343
+
344
+ The decorator will create an optional artifact, specified by `var`, which
345
+ contains the exception raised. You can use it to detect the presence
346
+ of errors, indicating that all happy-path artifacts produced by the step
347
+ are missing.
283
348
 
284
349
 
285
350
  Parameters
286
351
  ----------
287
- sources : List[Union[str, Dict[str, Any]]], default: []
288
- List of secret specs, defining how the secrets are to be retrieved
289
- role : str, optional, default: None
290
- Role to use for fetching secrets
352
+ var : str, optional, default None
353
+ Name of the artifact in which to store the caught exception.
354
+ If not specified, the exception is not stored.
355
+ print_exception : bool, default True
356
+ Determines whether or not the exception is printed to
357
+ stdout when caught.
291
358
  """
292
359
  ...
293
360
 
294
361
  @typing.overload
295
- def checkpoint(*, load_policy: str = 'fresh', temp_dir_root: str = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
362
+ 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]]]:
296
363
  """
297
- Enables checkpointing for a step.
364
+ Enables loading / saving of models within a step.
298
365
 
299
366
  > Examples
300
-
301
- - Saving Checkpoints
302
-
367
+ - Saving Models
303
368
  ```python
304
- @checkpoint
369
+ @model
305
370
  @step
306
371
  def train(self):
307
- model = create_model(self.parameters, checkpoint_path = None)
308
- for i in range(self.epochs):
309
- # some training logic
310
- loss = model.train(self.dataset)
311
- if i % 10 == 0:
312
- model.save(
313
- current.checkpoint.directory,
314
- )
315
- # saves the contents of the `current.checkpoint.directory` as a checkpoint
316
- # and returns a reference dictionary to the checkpoint saved in the datastore
317
- self.latest_checkpoint = current.checkpoint.save(
318
- name="epoch_checkpoint",
319
- metadata={
320
- "epoch": i,
321
- "loss": loss,
322
- }
323
- )
324
- ```
372
+ # current.model.save returns a dictionary reference to the model saved
373
+ self.my_model = current.model.save(
374
+ path_to_my_model,
375
+ label="my_model",
376
+ metadata={
377
+ "epochs": 10,
378
+ "batch-size": 32,
379
+ "learning-rate": 0.001,
380
+ }
381
+ )
382
+ self.next(self.test)
325
383
 
326
- - Using Loaded Checkpoints
384
+ @model(load="my_model")
385
+ @step
386
+ def test(self):
387
+ # `current.model.loaded` returns a dictionary of the loaded models
388
+ # where the key is the name of the artifact and the value is the path to the model
389
+ print(os.listdir(current.model.loaded["my_model"]))
390
+ self.next(self.end)
391
+ ```
327
392
 
393
+ - Loading models
328
394
  ```python
329
- @retry(times=3)
330
- @checkpoint
331
395
  @step
332
396
  def train(self):
333
- # Assume that the task has restarted and the previous attempt of the task
334
- # saved a checkpoint
335
- checkpoint_path = None
336
- if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
337
- print("Loaded checkpoint from the previous attempt")
338
- checkpoint_path = current.checkpoint.directory
339
-
340
- model = create_model(self.parameters, checkpoint_path = checkpoint_path)
341
- for i in range(self.epochs):
342
- ...
397
+ # current.model.load returns the path to the model loaded
398
+ checkpoint_path = current.model.load(
399
+ self.checkpoint_key,
400
+ )
401
+ model_path = current.model.load(
402
+ self.model,
403
+ )
404
+ self.next(self.test)
343
405
  ```
344
406
 
345
407
 
346
408
  Parameters
347
409
  ----------
348
- load_policy : str, default: "fresh"
349
- The policy for loading the checkpoint. The following policies are supported:
350
- - "eager": Loads the the latest available checkpoint within the namespace.
351
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
352
- will be loaded at the start of the task.
353
- - "none": Do not load any checkpoint
354
- - "fresh": Loads the lastest checkpoint created within the running Task.
355
- This mode helps loading checkpoints across various retry attempts of the same task.
356
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
357
- created within the task will be loaded when the task is retries execution on failure.
410
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
411
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
412
+ 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`.
413
+ 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
414
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
415
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
358
416
 
359
417
  temp_dir_root : str, default: None
360
- The root directory under which `current.checkpoint.directory` will be created.
418
+ The root directory under which `current.model.loaded` will store loaded models
361
419
  """
362
420
  ...
363
421
 
364
422
  @typing.overload
365
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
423
+ def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
366
424
  ...
367
425
 
368
426
  @typing.overload
369
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
427
+ def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
370
428
  ...
371
429
 
372
- def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load_policy: str = 'fresh', temp_dir_root: str = None):
430
+ 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):
373
431
  """
374
- Enables checkpointing for a step.
432
+ Enables loading / saving of models within a step.
375
433
 
376
434
  > Examples
377
-
378
- - Saving Checkpoints
379
-
435
+ - Saving Models
380
436
  ```python
381
- @checkpoint
437
+ @model
382
438
  @step
383
439
  def train(self):
384
- model = create_model(self.parameters, checkpoint_path = None)
385
- for i in range(self.epochs):
386
- # some training logic
387
- loss = model.train(self.dataset)
388
- if i % 10 == 0:
389
- model.save(
390
- current.checkpoint.directory,
391
- )
392
- # saves the contents of the `current.checkpoint.directory` as a checkpoint
393
- # and returns a reference dictionary to the checkpoint saved in the datastore
394
- self.latest_checkpoint = current.checkpoint.save(
395
- name="epoch_checkpoint",
396
- metadata={
397
- "epoch": i,
398
- "loss": loss,
399
- }
400
- )
401
- ```
440
+ # current.model.save returns a dictionary reference to the model saved
441
+ self.my_model = current.model.save(
442
+ path_to_my_model,
443
+ label="my_model",
444
+ metadata={
445
+ "epochs": 10,
446
+ "batch-size": 32,
447
+ "learning-rate": 0.001,
448
+ }
449
+ )
450
+ self.next(self.test)
402
451
 
403
- - Using Loaded Checkpoints
452
+ @model(load="my_model")
453
+ @step
454
+ def test(self):
455
+ # `current.model.loaded` returns a dictionary of the loaded models
456
+ # where the key is the name of the artifact and the value is the path to the model
457
+ print(os.listdir(current.model.loaded["my_model"]))
458
+ self.next(self.end)
459
+ ```
404
460
 
461
+ - Loading models
405
462
  ```python
406
- @retry(times=3)
407
- @checkpoint
408
463
  @step
409
464
  def train(self):
410
- # Assume that the task has restarted and the previous attempt of the task
411
- # saved a checkpoint
412
- checkpoint_path = None
413
- if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
414
- print("Loaded checkpoint from the previous attempt")
415
- checkpoint_path = current.checkpoint.directory
416
-
417
- model = create_model(self.parameters, checkpoint_path = checkpoint_path)
418
- for i in range(self.epochs):
419
- ...
465
+ # current.model.load returns the path to the model loaded
466
+ checkpoint_path = current.model.load(
467
+ self.checkpoint_key,
468
+ )
469
+ model_path = current.model.load(
470
+ self.model,
471
+ )
472
+ self.next(self.test)
420
473
  ```
421
474
 
422
475
 
423
476
  Parameters
424
477
  ----------
425
- load_policy : str, default: "fresh"
426
- The policy for loading the checkpoint. The following policies are supported:
427
- - "eager": Loads the the latest available checkpoint within the namespace.
428
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
429
- will be loaded at the start of the task.
430
- - "none": Do not load any checkpoint
431
- - "fresh": Loads the lastest checkpoint created within the running Task.
432
- This mode helps loading checkpoints across various retry attempts of the same task.
433
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
434
- created within the task will be loaded when the task is retries execution on failure.
478
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
479
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
480
+ 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`.
481
+ 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
482
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
483
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
435
484
 
436
485
  temp_dir_root : str, default: None
437
- The root directory under which `current.checkpoint.directory` will be created.
438
- """
439
- ...
440
-
441
- @typing.overload
442
- 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]]]:
443
- """
444
- Specifies environment variables to be set prior to the execution of a step.
445
-
446
-
447
- Parameters
448
- ----------
449
- vars : Dict[str, str], default {}
450
- Dictionary of environment variables to set.
451
- """
452
- ...
453
-
454
- @typing.overload
455
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
456
- ...
457
-
458
- @typing.overload
459
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
460
- ...
461
-
462
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
463
- """
464
- Specifies environment variables to be set prior to the execution of a step.
465
-
466
-
467
- Parameters
468
- ----------
469
- vars : Dict[str, str], default {}
470
- Dictionary of environment variables to set.
486
+ The root directory under which `current.model.loaded` will store loaded models
471
487
  """
472
488
  ...
473
489
 
474
490
  @typing.overload
475
- def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
491
+ 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]]]:
476
492
  """
477
- Specifies the Conda environment for the step.
493
+ Creates a human-readable report, a Metaflow Card, after this step completes.
478
494
 
479
- Information in this decorator will augment any
480
- attributes set in the `@conda_base` flow-level decorator. Hence,
481
- you can use `@conda_base` to set packages required by all
482
- steps and use `@conda` to specify step-specific overrides.
495
+ Note that you may add multiple `@card` decorators in a step with different parameters.
483
496
 
484
497
 
485
498
  Parameters
486
499
  ----------
487
- packages : Dict[str, str], default {}
488
- Packages to use for this step. The key is the name of the package
489
- and the value is the version to use.
490
- libraries : Dict[str, str], default {}
491
- Supported for backward compatibility. When used with packages, packages will take precedence.
492
- python : str, optional, default None
493
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
494
- that the version used will correspond to the version of the Python interpreter used to start the run.
495
- disabled : bool, default False
496
- If set to True, disables @conda.
500
+ type : str, default 'default'
501
+ Card type.
502
+ id : str, optional, default None
503
+ If multiple cards are present, use this id to identify this card.
504
+ options : Dict[str, Any], default {}
505
+ Options passed to the card. The contents depend on the card type.
506
+ timeout : int, default 45
507
+ Interrupt reporting if it takes more than this many seconds.
497
508
  """
498
509
  ...
499
510
 
500
511
  @typing.overload
501
- def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
512
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
502
513
  ...
503
514
 
504
515
  @typing.overload
505
- def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
516
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
506
517
  ...
507
518
 
508
- def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
519
+ 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):
509
520
  """
510
- Specifies the Conda environment for the step.
511
-
512
- Information in this decorator will augment any
513
- attributes set in the `@conda_base` flow-level decorator. Hence,
514
- you can use `@conda_base` to set packages required by all
515
- steps and use `@conda` to specify step-specific overrides.
516
-
521
+ Creates a human-readable report, a Metaflow Card, after this step completes.
517
522
 
518
- Parameters
519
- ----------
520
- packages : Dict[str, str], default {}
521
- Packages to use for this step. The key is the name of the package
522
- and the value is the version to use.
523
- libraries : Dict[str, str], default {}
524
- Supported for backward compatibility. When used with packages, packages will take precedence.
525
- python : str, optional, default None
526
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
527
- that the version used will correspond to the version of the Python interpreter used to start the run.
528
- disabled : bool, default False
529
- If set to True, disables @conda.
530
- """
531
- ...
532
-
533
- 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]]]:
534
- """
535
- Specifies that this step should execute on Kubernetes.
523
+ Note that you may add multiple `@card` decorators in a step with different parameters.
536
524
 
537
525
 
538
526
  Parameters
539
527
  ----------
540
- cpu : int, default 1
541
- Number of CPUs required for this step. If `@resources` is
542
- also present, the maximum value from all decorators is used.
543
- memory : int, default 4096
544
- Memory size (in MB) required for this step. If
545
- `@resources` is also present, the maximum value from all decorators is
546
- used.
547
- disk : int, default 10240
548
- Disk size (in MB) required for this step. If
549
- `@resources` is also present, the maximum value from all decorators is
550
- used.
551
- image : str, optional, default None
552
- Docker image to use when launching on Kubernetes. If not specified, and
553
- METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
554
- not, a default Docker image mapping to the current version of Python is used.
555
- image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
556
- If given, the imagePullPolicy to be applied to the Docker image of the step.
557
- image_pull_secrets: List[str], default []
558
- The default is extracted from METAFLOW_KUBERNETES_IMAGE_PULL_SECRETS.
559
- Kubernetes image pull secrets to use when pulling container images
560
- in Kubernetes.
561
- service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
562
- Kubernetes service account to use when launching pod in Kubernetes.
563
- secrets : List[str], optional, default None
564
- Kubernetes secrets to use when launching pod in Kubernetes. These
565
- secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
566
- in Metaflow configuration.
567
- node_selector: Union[Dict[str,str], str], optional, default None
568
- Kubernetes node selector(s) to apply to the pod running the task.
569
- Can be passed in as a comma separated string of values e.g.
570
- 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
571
- {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
572
- namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
573
- Kubernetes namespace to use when launching pod in Kubernetes.
574
- gpu : int, optional, default None
575
- Number of GPUs required for this step. A value of zero implies that
576
- the scheduled node should not have GPUs.
577
- gpu_vendor : str, default KUBERNETES_GPU_VENDOR
578
- The vendor of the GPUs to be used for this step.
579
- tolerations : List[str], default []
580
- The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
581
- Kubernetes tolerations to use when launching pod in Kubernetes.
582
- labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
583
- Kubernetes labels to use when launching pod in Kubernetes.
584
- annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
585
- Kubernetes annotations to use when launching pod in Kubernetes.
586
- use_tmpfs : bool, default False
587
- This enables an explicit tmpfs mount for this step.
588
- tmpfs_tempdir : bool, default True
589
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
590
- tmpfs_size : int, optional, default: None
591
- The value for the size (in MiB) of the tmpfs mount for this step.
592
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
593
- memory allocated for this step.
594
- tmpfs_path : str, optional, default /metaflow_temp
595
- Path to tmpfs mount for this step.
596
- persistent_volume_claims : Dict[str, str], optional, default None
597
- A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
598
- volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
599
- shared_memory: int, optional
600
- Shared memory size (in MiB) required for this step
601
- port: int, optional
602
- Port number to specify in the Kubernetes job object
603
- compute_pool : str, optional, default None
604
- Compute pool to be used for for this step.
605
- If not specified, any accessible compute pool within the perimeter is used.
606
- hostname_resolution_timeout: int, default 10 * 60
607
- Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
608
- Only applicable when @parallel is used.
609
- qos: str, default: Burstable
610
- Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
611
-
612
- security_context: Dict[str, Any], optional, default None
613
- Container security context. Applies to the task container. Allows the following keys:
614
- - privileged: bool, optional, default None
615
- - allow_privilege_escalation: bool, optional, default None
616
- - run_as_user: int, optional, default None
617
- - run_as_group: int, optional, default None
618
- - run_as_non_root: bool, optional, default None
619
- """
620
- ...
621
-
622
- @typing.overload
623
- def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
624
- """
625
- Decorator prototype for all step decorators. This function gets specialized
626
- and imported for all decorators types by _import_plugin_decorators().
627
- """
628
- ...
629
-
630
- @typing.overload
631
- def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
632
- ...
633
-
634
- def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
635
- """
636
- Decorator prototype for all step decorators. This function gets specialized
637
- and imported for all decorators types by _import_plugin_decorators().
528
+ type : str, default 'default'
529
+ Card type.
530
+ id : str, optional, default None
531
+ If multiple cards are present, use this id to identify this card.
532
+ options : Dict[str, Any], default {}
533
+ Options passed to the card. The contents depend on the card type.
534
+ timeout : int, default 45
535
+ Interrupt reporting if it takes more than this many seconds.
638
536
  """
639
537
  ...
640
538
 
@@ -689,219 +587,271 @@ def vllm(*, model: str, backend: str, openai_api_server: bool, debug: bool, card
689
587
  ...
690
588
 
691
589
  @typing.overload
692
- 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]]]:
590
+ 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]]]:
693
591
  """
694
- Enables loading / saving of models within a step.
592
+ Specifies a timeout for your step.
695
593
 
696
- > Examples
697
- - Saving Models
698
- ```python
699
- @model
700
- @step
701
- def train(self):
702
- # current.model.save returns a dictionary reference to the model saved
703
- self.my_model = current.model.save(
704
- path_to_my_model,
705
- label="my_model",
706
- metadata={
707
- "epochs": 10,
708
- "batch-size": 32,
709
- "learning-rate": 0.001,
710
- }
711
- )
712
- self.next(self.test)
594
+ This decorator is useful if this step may hang indefinitely.
713
595
 
714
- @model(load="my_model")
715
- @step
716
- def test(self):
717
- # `current.model.loaded` returns a dictionary of the loaded models
718
- # where the key is the name of the artifact and the value is the path to the model
719
- print(os.listdir(current.model.loaded["my_model"]))
720
- self.next(self.end)
721
- ```
596
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
597
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
598
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
722
599
 
723
- - Loading models
724
- ```python
725
- @step
726
- def train(self):
727
- # current.model.load returns the path to the model loaded
728
- checkpoint_path = current.model.load(
729
- self.checkpoint_key,
730
- )
731
- model_path = current.model.load(
732
- self.model,
733
- )
734
- self.next(self.test)
735
- ```
600
+ Note that all the values specified in parameters are added together so if you specify
601
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
736
602
 
737
603
 
738
604
  Parameters
739
605
  ----------
740
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
741
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
742
- 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`.
743
- 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
744
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
745
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
606
+ seconds : int, default 0
607
+ Number of seconds to wait prior to timing out.
608
+ minutes : int, default 0
609
+ Number of minutes to wait prior to timing out.
610
+ hours : int, default 0
611
+ Number of hours to wait prior to timing out.
612
+ """
613
+ ...
614
+
615
+ @typing.overload
616
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
617
+ ...
618
+
619
+ @typing.overload
620
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
621
+ ...
622
+
623
+ 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):
624
+ """
625
+ Specifies a timeout for your step.
746
626
 
747
- temp_dir_root : str, default: None
748
- The root directory under which `current.model.loaded` will store loaded models
627
+ This decorator is useful if this step may hang indefinitely.
628
+
629
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
630
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
631
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
632
+
633
+ Note that all the values specified in parameters are added together so if you specify
634
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
635
+
636
+
637
+ Parameters
638
+ ----------
639
+ seconds : int, default 0
640
+ Number of seconds to wait prior to timing out.
641
+ minutes : int, default 0
642
+ Number of minutes to wait prior to timing out.
643
+ hours : int, default 0
644
+ Number of hours to wait prior to timing out.
749
645
  """
750
646
  ...
751
647
 
752
648
  @typing.overload
753
- def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
649
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
650
+ """
651
+ Internal decorator to support Fast bakery
652
+ """
754
653
  ...
755
654
 
756
655
  @typing.overload
757
- def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
656
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
758
657
  ...
759
658
 
760
- 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):
659
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
761
660
  """
762
- Enables loading / saving of models within a step.
661
+ Internal decorator to support Fast bakery
662
+ """
663
+ ...
664
+
665
+ @typing.overload
666
+ 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]]]:
667
+ """
668
+ Specifies the resources needed when executing this step.
763
669
 
764
- > Examples
765
- - Saving Models
766
- ```python
767
- @model
768
- @step
769
- def train(self):
770
- # current.model.save returns a dictionary reference to the model saved
771
- self.my_model = current.model.save(
772
- path_to_my_model,
773
- label="my_model",
774
- metadata={
775
- "epochs": 10,
776
- "batch-size": 32,
777
- "learning-rate": 0.001,
778
- }
779
- )
780
- self.next(self.test)
670
+ Use `@resources` to specify the resource requirements
671
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
781
672
 
782
- @model(load="my_model")
783
- @step
784
- def test(self):
785
- # `current.model.loaded` returns a dictionary of the loaded models
786
- # where the key is the name of the artifact and the value is the path to the model
787
- print(os.listdir(current.model.loaded["my_model"]))
788
- self.next(self.end)
673
+ You can choose the compute layer on the command line by executing e.g.
789
674
  ```
790
-
791
- - Loading models
792
- ```python
793
- @step
794
- def train(self):
795
- # current.model.load returns the path to the model loaded
796
- checkpoint_path = current.model.load(
797
- self.checkpoint_key,
798
- )
799
- model_path = current.model.load(
800
- self.model,
801
- )
802
- self.next(self.test)
675
+ python myflow.py run --with batch
676
+ ```
677
+ or
678
+ ```
679
+ python myflow.py run --with kubernetes
803
680
  ```
681
+ which executes the flow on the desired system using the
682
+ requirements specified in `@resources`.
804
683
 
805
684
 
806
685
  Parameters
807
686
  ----------
808
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
809
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
810
- 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`.
811
- 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
812
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
813
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
687
+ cpu : int, default 1
688
+ Number of CPUs required for this step.
689
+ gpu : int, optional, default None
690
+ Number of GPUs required for this step.
691
+ disk : int, optional, default None
692
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
693
+ memory : int, default 4096
694
+ Memory size (in MB) required for this step.
695
+ shared_memory : int, optional, default None
696
+ The value for the size (in MiB) of the /dev/shm volume for this step.
697
+ This parameter maps to the `--shm-size` option in Docker.
698
+ """
699
+ ...
700
+
701
+ @typing.overload
702
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
703
+ ...
704
+
705
+ @typing.overload
706
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
707
+ ...
708
+
709
+ 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):
710
+ """
711
+ Specifies the resources needed when executing this step.
814
712
 
815
- temp_dir_root : str, default: None
816
- The root directory under which `current.model.loaded` will store loaded models
713
+ Use `@resources` to specify the resource requirements
714
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
715
+
716
+ You can choose the compute layer on the command line by executing e.g.
717
+ ```
718
+ python myflow.py run --with batch
719
+ ```
720
+ or
721
+ ```
722
+ python myflow.py run --with kubernetes
723
+ ```
724
+ which executes the flow on the desired system using the
725
+ requirements specified in `@resources`.
726
+
727
+
728
+ Parameters
729
+ ----------
730
+ cpu : int, default 1
731
+ Number of CPUs required for this step.
732
+ gpu : int, optional, default None
733
+ Number of GPUs required for this step.
734
+ disk : int, optional, default None
735
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
736
+ memory : int, default 4096
737
+ Memory size (in MB) required for this step.
738
+ shared_memory : int, optional, default None
739
+ The value for the size (in MiB) of the /dev/shm volume for this step.
740
+ This parameter maps to the `--shm-size` option in Docker.
817
741
  """
818
742
  ...
819
743
 
820
- 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]]]:
744
+ @typing.overload
745
+ def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
821
746
  """
822
- Specifies that this step should execute on DGX cloud.
747
+ Specifies the Conda environment for the step.
748
+
749
+ Information in this decorator will augment any
750
+ attributes set in the `@conda_base` flow-level decorator. Hence,
751
+ you can use `@conda_base` to set packages required by all
752
+ steps and use `@conda` to specify step-specific overrides.
823
753
 
824
754
 
825
755
  Parameters
826
756
  ----------
827
- gpu : int
828
- Number of GPUs to use.
829
- gpu_type : str
830
- Type of Nvidia GPU to use.
757
+ packages : Dict[str, str], default {}
758
+ Packages to use for this step. The key is the name of the package
759
+ and the value is the version to use.
760
+ libraries : Dict[str, str], default {}
761
+ Supported for backward compatibility. When used with packages, packages will take precedence.
762
+ python : str, optional, default None
763
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
764
+ that the version used will correspond to the version of the Python interpreter used to start the run.
765
+ disabled : bool, default False
766
+ If set to True, disables @conda.
831
767
  """
832
768
  ...
833
769
 
834
770
  @typing.overload
835
- 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]]]:
771
+ def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
772
+ ...
773
+
774
+ @typing.overload
775
+ def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
776
+ ...
777
+
778
+ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
836
779
  """
837
- Specifies that the step will success under all circumstances.
780
+ Specifies the Conda environment for the step.
838
781
 
839
- The decorator will create an optional artifact, specified by `var`, which
840
- contains the exception raised. You can use it to detect the presence
841
- of errors, indicating that all happy-path artifacts produced by the step
842
- are missing.
782
+ Information in this decorator will augment any
783
+ attributes set in the `@conda_base` flow-level decorator. Hence,
784
+ you can use `@conda_base` to set packages required by all
785
+ steps and use `@conda` to specify step-specific overrides.
843
786
 
844
787
 
845
788
  Parameters
846
789
  ----------
847
- var : str, optional, default None
848
- Name of the artifact in which to store the caught exception.
849
- If not specified, the exception is not stored.
850
- print_exception : bool, default True
851
- Determines whether or not the exception is printed to
852
- stdout when caught.
790
+ packages : Dict[str, str], default {}
791
+ Packages to use for this step. The key is the name of the package
792
+ and the value is the version to use.
793
+ libraries : Dict[str, str], default {}
794
+ Supported for backward compatibility. When used with packages, packages will take precedence.
795
+ python : str, optional, default None
796
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
797
+ that the version used will correspond to the version of the Python interpreter used to start the run.
798
+ disabled : bool, default False
799
+ If set to True, disables @conda.
853
800
  """
854
801
  ...
855
802
 
856
803
  @typing.overload
857
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
858
- ...
859
-
860
- @typing.overload
861
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
862
- ...
863
-
864
- 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):
804
+ def pypi(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
865
805
  """
866
- Specifies that the step will success under all circumstances.
806
+ Specifies the PyPI packages for the step.
867
807
 
868
- The decorator will create an optional artifact, specified by `var`, which
869
- contains the exception raised. You can use it to detect the presence
870
- of errors, indicating that all happy-path artifacts produced by the step
871
- are missing.
808
+ Information in this decorator will augment any
809
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
810
+ you can use `@pypi_base` to set packages required by all
811
+ steps and use `@pypi` to specify step-specific overrides.
872
812
 
873
813
 
874
814
  Parameters
875
815
  ----------
876
- var : str, optional, default None
877
- Name of the artifact in which to store the caught exception.
878
- If not specified, the exception is not stored.
879
- print_exception : bool, default True
880
- Determines whether or not the exception is printed to
881
- stdout when caught.
816
+ packages : Dict[str, str], default: {}
817
+ Packages to use for this step. The key is the name of the package
818
+ and the value is the version to use.
819
+ python : str, optional, default: None
820
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
821
+ that the version used will correspond to the version of the Python interpreter used to start the run.
882
822
  """
883
823
  ...
884
824
 
885
825
  @typing.overload
886
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
887
- """
888
- Decorator prototype for all step decorators. This function gets specialized
889
- and imported for all decorators types by _import_plugin_decorators().
890
- """
826
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
891
827
  ...
892
828
 
893
829
  @typing.overload
894
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
830
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
895
831
  ...
896
832
 
897
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
833
+ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
898
834
  """
899
- Decorator prototype for all step decorators. This function gets specialized
900
- and imported for all decorators types by _import_plugin_decorators().
835
+ Specifies the PyPI packages for the step.
836
+
837
+ Information in this decorator will augment any
838
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
839
+ you can use `@pypi_base` to set packages required by all
840
+ steps and use `@pypi` to specify step-specific overrides.
841
+
842
+
843
+ Parameters
844
+ ----------
845
+ packages : Dict[str, str], default: {}
846
+ Packages to use for this step. The key is the name of the package
847
+ and the value is the version to use.
848
+ python : str, optional, default: None
849
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
850
+ that the version used will correspond to the version of the Python interpreter used to start the run.
901
851
  """
902
852
  ...
903
853
 
904
- 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]]]:
854
+ 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]]]:
905
855
  """
906
856
  Specifies that this step should execute on DGX cloud.
907
857
 
@@ -912,100 +862,44 @@ def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[t
912
862
  Number of GPUs to use.
913
863
  gpu_type : str
914
864
  Type of Nvidia GPU to use.
915
- queue_timeout : int
916
- Time to keep the job in NVCF's queue.
917
865
  """
918
866
  ...
919
867
 
920
- 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]]]:
868
+ @typing.overload
869
+ def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
921
870
  """
922
- This decorator is used to run Ollama APIs as Metaflow task sidecars.
923
-
924
- User code call
925
- --------------
926
- @ollama(
927
- models=[...],
928
- ...
929
- )
930
-
931
- Valid backend options
932
- ---------------------
933
- - 'local': Run as a separate process on the local task machine.
934
- - (TODO) 'managed': Outerbounds hosts and selects compute provider.
935
- - (TODO) 'remote': Spin up separate instance to serve Ollama models.
936
-
937
- Valid model options
938
- -------------------
939
- Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
940
-
941
-
942
- Parameters
943
- ----------
944
- models: list[str]
945
- List of Ollama containers running models in sidecars.
946
- backend: str
947
- Determines where and how to run the Ollama process.
948
- force_pull: bool
949
- Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
950
- cache_update_policy: str
951
- Cache update policy: "auto", "force", or "never".
952
- force_cache_update: bool
953
- Simple override for "force" cache update policy.
954
- debug: bool
955
- Whether to turn on verbose debugging logs.
956
- circuit_breaker_config: dict
957
- Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
958
- timeout_config: dict
959
- Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
871
+ A simple decorator that demonstrates using CardDecoratorInjector
872
+ to inject a card and render simple markdown content.
960
873
  """
961
874
  ...
962
875
 
963
876
  @typing.overload
964
- 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]]]:
877
+ def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
878
+ ...
879
+
880
+ def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
965
881
  """
966
- Creates a human-readable report, a Metaflow Card, after this step completes.
967
-
968
- Note that you may add multiple `@card` decorators in a step with different parameters.
969
-
970
-
971
- Parameters
972
- ----------
973
- type : str, default 'default'
974
- Card type.
975
- id : str, optional, default None
976
- If multiple cards are present, use this id to identify this card.
977
- options : Dict[str, Any], default {}
978
- Options passed to the card. The contents depend on the card type.
979
- timeout : int, default 45
980
- Interrupt reporting if it takes more than this many seconds.
882
+ A simple decorator that demonstrates using CardDecoratorInjector
883
+ to inject a card and render simple markdown content.
981
884
  """
982
885
  ...
983
886
 
984
887
  @typing.overload
985
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
888
+ def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
889
+ """
890
+ Decorator prototype for all step decorators. This function gets specialized
891
+ and imported for all decorators types by _import_plugin_decorators().
892
+ """
986
893
  ...
987
894
 
988
895
  @typing.overload
989
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
896
+ def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
990
897
  ...
991
898
 
992
- 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):
899
+ def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
993
900
  """
994
- Creates a human-readable report, a Metaflow Card, after this step completes.
995
-
996
- Note that you may add multiple `@card` decorators in a step with different parameters.
997
-
998
-
999
- Parameters
1000
- ----------
1001
- type : str, default 'default'
1002
- Card type.
1003
- id : str, optional, default None
1004
- If multiple cards are present, use this id to identify this card.
1005
- options : Dict[str, Any], default {}
1006
- Options passed to the card. The contents depend on the card type.
1007
- timeout : int, default 45
1008
- Interrupt reporting if it takes more than this many seconds.
901
+ Decorator prototype for all step decorators. This function gets specialized
902
+ and imported for all decorators types by _import_plugin_decorators().
1009
903
  """
1010
904
  ...
1011
905
 
@@ -1065,131 +959,198 @@ def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
1065
959
  ...
1066
960
 
1067
961
  @typing.overload
1068
- def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
962
+ 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]]]:
1069
963
  """
1070
- A simple decorator that demonstrates using CardDecoratorInjector
1071
- to inject a card and render simple markdown content.
964
+ Specifies environment variables to be set prior to the execution of a step.
965
+
966
+
967
+ Parameters
968
+ ----------
969
+ vars : Dict[str, str], default {}
970
+ Dictionary of environment variables to set.
1072
971
  """
1073
972
  ...
1074
973
 
1075
974
  @typing.overload
1076
- def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
975
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1077
976
  ...
1078
977
 
1079
- def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
978
+ @typing.overload
979
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
980
+ ...
981
+
982
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
1080
983
  """
1081
- A simple decorator that demonstrates using CardDecoratorInjector
1082
- to inject a card and render simple markdown content.
984
+ Specifies environment variables to be set prior to the execution of a step.
985
+
986
+
987
+ Parameters
988
+ ----------
989
+ vars : Dict[str, str], default {}
990
+ Dictionary of environment variables to set.
1083
991
  """
1084
992
  ...
1085
993
 
1086
994
  @typing.overload
1087
- 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]]]:
995
+ def checkpoint(*, load_policy: str = 'fresh', temp_dir_root: str = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
1088
996
  """
1089
- Specifies a timeout for your step.
997
+ Enables checkpointing for a step.
1090
998
 
1091
- This decorator is useful if this step may hang indefinitely.
999
+ > Examples
1092
1000
 
1093
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
1094
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
1095
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
1001
+ - Saving Checkpoints
1002
+
1003
+ ```python
1004
+ @checkpoint
1005
+ @step
1006
+ def train(self):
1007
+ model = create_model(self.parameters, checkpoint_path = None)
1008
+ for i in range(self.epochs):
1009
+ # some training logic
1010
+ loss = model.train(self.dataset)
1011
+ if i % 10 == 0:
1012
+ model.save(
1013
+ current.checkpoint.directory,
1014
+ )
1015
+ # saves the contents of the `current.checkpoint.directory` as a checkpoint
1016
+ # and returns a reference dictionary to the checkpoint saved in the datastore
1017
+ self.latest_checkpoint = current.checkpoint.save(
1018
+ name="epoch_checkpoint",
1019
+ metadata={
1020
+ "epoch": i,
1021
+ "loss": loss,
1022
+ }
1023
+ )
1024
+ ```
1025
+
1026
+ - Using Loaded Checkpoints
1027
+
1028
+ ```python
1029
+ @retry(times=3)
1030
+ @checkpoint
1031
+ @step
1032
+ def train(self):
1033
+ # Assume that the task has restarted and the previous attempt of the task
1034
+ # saved a checkpoint
1035
+ checkpoint_path = None
1036
+ if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1037
+ print("Loaded checkpoint from the previous attempt")
1038
+ checkpoint_path = current.checkpoint.directory
1096
1039
 
1097
- Note that all the values specified in parameters are added together so if you specify
1098
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
1040
+ model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1041
+ for i in range(self.epochs):
1042
+ ...
1043
+ ```
1099
1044
 
1100
1045
 
1101
1046
  Parameters
1102
1047
  ----------
1103
- seconds : int, default 0
1104
- Number of seconds to wait prior to timing out.
1105
- minutes : int, default 0
1106
- Number of minutes to wait prior to timing out.
1107
- hours : int, default 0
1108
- Number of hours to wait prior to timing out.
1048
+ load_policy : str, default: "fresh"
1049
+ The policy for loading the checkpoint. The following policies are supported:
1050
+ - "eager": Loads the the latest available checkpoint within the namespace.
1051
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1052
+ will be loaded at the start of the task.
1053
+ - "none": Do not load any checkpoint
1054
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1055
+ This mode helps loading checkpoints across various retry attempts of the same task.
1056
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1057
+ created within the task will be loaded when the task is retries execution on failure.
1058
+
1059
+ temp_dir_root : str, default: None
1060
+ The root directory under which `current.checkpoint.directory` will be created.
1109
1061
  """
1110
1062
  ...
1111
1063
 
1112
1064
  @typing.overload
1113
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1065
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1114
1066
  ...
1115
1067
 
1116
1068
  @typing.overload
1117
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1069
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1118
1070
  ...
1119
1071
 
1120
- 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):
1072
+ def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load_policy: str = 'fresh', temp_dir_root: str = None):
1121
1073
  """
1122
- Specifies a timeout for your step.
1074
+ Enables checkpointing for a step.
1123
1075
 
1124
- This decorator is useful if this step may hang indefinitely.
1076
+ > Examples
1125
1077
 
1126
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
1127
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
1128
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
1078
+ - Saving Checkpoints
1129
1079
 
1130
- Note that all the values specified in parameters are added together so if you specify
1131
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
1080
+ ```python
1081
+ @checkpoint
1082
+ @step
1083
+ def train(self):
1084
+ model = create_model(self.parameters, checkpoint_path = None)
1085
+ for i in range(self.epochs):
1086
+ # some training logic
1087
+ loss = model.train(self.dataset)
1088
+ if i % 10 == 0:
1089
+ model.save(
1090
+ current.checkpoint.directory,
1091
+ )
1092
+ # saves the contents of the `current.checkpoint.directory` as a checkpoint
1093
+ # and returns a reference dictionary to the checkpoint saved in the datastore
1094
+ self.latest_checkpoint = current.checkpoint.save(
1095
+ name="epoch_checkpoint",
1096
+ metadata={
1097
+ "epoch": i,
1098
+ "loss": loss,
1099
+ }
1100
+ )
1101
+ ```
1132
1102
 
1103
+ - Using Loaded Checkpoints
1133
1104
 
1134
- Parameters
1135
- ----------
1136
- seconds : int, default 0
1137
- Number of seconds to wait prior to timing out.
1138
- minutes : int, default 0
1139
- Number of minutes to wait prior to timing out.
1140
- hours : int, default 0
1141
- Number of hours to wait prior to timing out.
1142
- """
1143
- ...
1144
-
1145
- @typing.overload
1146
- def pypi(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
1147
- """
1148
- Specifies the PyPI packages for the step.
1105
+ ```python
1106
+ @retry(times=3)
1107
+ @checkpoint
1108
+ @step
1109
+ def train(self):
1110
+ # Assume that the task has restarted and the previous attempt of the task
1111
+ # saved a checkpoint
1112
+ checkpoint_path = None
1113
+ if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1114
+ print("Loaded checkpoint from the previous attempt")
1115
+ checkpoint_path = current.checkpoint.directory
1149
1116
 
1150
- Information in this decorator will augment any
1151
- attributes set in the `@pyi_base` flow-level decorator. Hence,
1152
- you can use `@pypi_base` to set packages required by all
1153
- steps and use `@pypi` to specify step-specific overrides.
1117
+ model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1118
+ for i in range(self.epochs):
1119
+ ...
1120
+ ```
1154
1121
 
1155
1122
 
1156
1123
  Parameters
1157
1124
  ----------
1158
- packages : Dict[str, str], default: {}
1159
- Packages to use for this step. The key is the name of the package
1160
- and the value is the version to use.
1161
- python : str, optional, default: None
1162
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1163
- that the version used will correspond to the version of the Python interpreter used to start the run.
1125
+ load_policy : str, default: "fresh"
1126
+ The policy for loading the checkpoint. The following policies are supported:
1127
+ - "eager": Loads the the latest available checkpoint within the namespace.
1128
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1129
+ will be loaded at the start of the task.
1130
+ - "none": Do not load any checkpoint
1131
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1132
+ This mode helps loading checkpoints across various retry attempts of the same task.
1133
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1134
+ created within the task will be loaded when the task is retries execution on failure.
1135
+
1136
+ temp_dir_root : str, default: None
1137
+ The root directory under which `current.checkpoint.directory` will be created.
1164
1138
  """
1165
1139
  ...
1166
1140
 
1167
- @typing.overload
1168
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1169
- ...
1170
-
1171
- @typing.overload
1172
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1173
- ...
1174
-
1175
- def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1141
+ 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]]]:
1176
1142
  """
1177
- Specifies the PyPI packages for the step.
1178
-
1179
- Information in this decorator will augment any
1180
- attributes set in the `@pyi_base` flow-level decorator. Hence,
1181
- you can use `@pypi_base` to set packages required by all
1182
- steps and use `@pypi` to specify step-specific overrides.
1143
+ Specifies that this step should execute on DGX cloud.
1183
1144
 
1184
1145
 
1185
1146
  Parameters
1186
1147
  ----------
1187
- packages : Dict[str, str], default: {}
1188
- Packages to use for this step. The key is the name of the package
1189
- and the value is the version to use.
1190
- python : str, optional, default: None
1191
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1192
- that the version used will correspond to the version of the Python interpreter used to start the run.
1148
+ gpu : int
1149
+ Number of GPUs to use.
1150
+ gpu_type : str
1151
+ Type of Nvidia GPU to use.
1152
+ queue_timeout : int
1153
+ Time to keep the job in NVCF's queue.
1193
1154
  """
1194
1155
  ...
1195
1156
 
@@ -1273,211 +1234,170 @@ def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.
1273
1234
  """
1274
1235
  ...
1275
1236
 
1276
- def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1237
+ @typing.overload
1238
+ def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
1277
1239
  """
1278
- Allows setting external datastores to save data for the
1279
- `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1280
-
1281
- This decorator is useful when users wish to save data to a different datastore
1282
- than what is configured in Metaflow. This can be for variety of reasons:
1283
-
1284
- 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1285
- 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1286
- - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1287
- 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1288
- - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1289
-
1290
- Usage:
1291
- ----------
1292
-
1293
- - Using a custom IAM role to access the datastore.
1294
-
1295
- ```python
1296
- @with_artifact_store(
1297
- type="s3",
1298
- config=lambda: {
1299
- "root": "s3://my-bucket-foo/path/to/root",
1300
- "role_arn": ROLE,
1301
- },
1302
- )
1303
- class MyFlow(FlowSpec):
1304
-
1305
- @checkpoint
1306
- @step
1307
- def start(self):
1308
- with open("my_file.txt", "w") as f:
1309
- f.write("Hello, World!")
1310
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1311
- self.next(self.end)
1312
-
1313
- ```
1314
-
1315
- - Using credentials to access the s3-compatible datastore.
1316
-
1317
- ```python
1318
- @with_artifact_store(
1319
- type="s3",
1320
- config=lambda: {
1321
- "root": "s3://my-bucket-foo/path/to/root",
1322
- "client_params": {
1323
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1324
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1325
- },
1326
- },
1327
- )
1328
- class MyFlow(FlowSpec):
1329
-
1330
- @checkpoint
1331
- @step
1332
- def start(self):
1333
- with open("my_file.txt", "w") as f:
1334
- f.write("Hello, World!")
1335
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1336
- self.next(self.end)
1337
-
1338
- ```
1339
-
1340
- - Accessing objects stored in external datastores after task execution.
1240
+ Specifies secrets to be retrieved and injected as environment variables prior to
1241
+ the execution of a step.
1341
1242
 
1342
- ```python
1343
- run = Run("CheckpointsTestsFlow/8992")
1344
- with artifact_store_from(run=run, config={
1345
- "client_params": {
1346
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1347
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1348
- },
1349
- }):
1350
- with Checkpoint() as cp:
1351
- latest = cp.list(
1352
- task=run["start"].task
1353
- )[0]
1354
- print(latest)
1355
- cp.load(
1356
- latest,
1357
- "test-checkpoints"
1358
- )
1359
1243
 
1360
- task = Task("TorchTuneFlow/8484/train/53673")
1361
- with artifact_store_from(run=run, config={
1362
- "client_params": {
1363
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1364
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1365
- },
1366
- }):
1367
- load_model(
1368
- task.data.model_ref,
1369
- "test-models"
1370
- )
1371
- ```
1372
- Parameters:
1244
+ Parameters
1373
1245
  ----------
1246
+ sources : List[Union[str, Dict[str, Any]]], default: []
1247
+ List of secret specs, defining how the secrets are to be retrieved
1248
+ role : str, optional, default: None
1249
+ Role to use for fetching secrets
1250
+ """
1251
+ ...
1252
+
1253
+ @typing.overload
1254
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1255
+ ...
1256
+
1257
+ @typing.overload
1258
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1259
+ ...
1260
+
1261
+ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None):
1262
+ """
1263
+ Specifies secrets to be retrieved and injected as environment variables prior to
1264
+ the execution of a step.
1374
1265
 
1375
- type: str
1376
- The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1377
1266
 
1378
- config: dict or Callable
1379
- Dictionary of configuration options for the datastore. The following keys are required:
1380
- - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1381
- - example: 's3://bucket-name/path/to/root'
1382
- - example: 'gs://bucket-name/path/to/root'
1383
- - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1384
- - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1385
- - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1386
- - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1267
+ Parameters
1268
+ ----------
1269
+ sources : List[Union[str, Dict[str, Any]]], default: []
1270
+ List of secret specs, defining how the secrets are to be retrieved
1271
+ role : str, optional, default: None
1272
+ Role to use for fetching secrets
1387
1273
  """
1388
1274
  ...
1389
1275
 
1390
1276
  @typing.overload
1391
- 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]]:
1277
+ 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]]:
1392
1278
  """
1393
- Specifies the times when the flow should be run when running on a
1394
- production scheduler.
1279
+ Specifies the event(s) that this flow depends on.
1280
+
1281
+ ```
1282
+ @trigger(event='foo')
1283
+ ```
1284
+ or
1285
+ ```
1286
+ @trigger(events=['foo', 'bar'])
1287
+ ```
1288
+
1289
+ Additionally, you can specify the parameter mappings
1290
+ to map event payload to Metaflow parameters for the flow.
1291
+ ```
1292
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1293
+ ```
1294
+ or
1295
+ ```
1296
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1297
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1298
+ ```
1299
+
1300
+ 'parameters' can also be a list of strings and tuples like so:
1301
+ ```
1302
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1303
+ ```
1304
+ This is equivalent to:
1305
+ ```
1306
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1307
+ ```
1395
1308
 
1396
1309
 
1397
1310
  Parameters
1398
1311
  ----------
1399
- hourly : bool, default False
1400
- Run the workflow hourly.
1401
- daily : bool, default True
1402
- Run the workflow daily.
1403
- weekly : bool, default False
1404
- Run the workflow weekly.
1405
- cron : str, optional, default None
1406
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1407
- specified by this expression.
1408
- timezone : str, optional, default None
1409
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1410
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1312
+ event : Union[str, Dict[str, Any]], optional, default None
1313
+ Event dependency for this flow.
1314
+ events : List[Union[str, Dict[str, Any]]], default []
1315
+ Events dependency for this flow.
1316
+ options : Dict[str, Any], default {}
1317
+ Backend-specific configuration for tuning eventing behavior.
1411
1318
  """
1412
1319
  ...
1413
1320
 
1414
1321
  @typing.overload
1415
- def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1322
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1416
1323
  ...
1417
1324
 
1418
- 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):
1325
+ 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] = {}):
1419
1326
  """
1420
- Specifies the times when the flow should be run when running on a
1421
- production scheduler.
1327
+ Specifies the event(s) that this flow depends on.
1328
+
1329
+ ```
1330
+ @trigger(event='foo')
1331
+ ```
1332
+ or
1333
+ ```
1334
+ @trigger(events=['foo', 'bar'])
1335
+ ```
1336
+
1337
+ Additionally, you can specify the parameter mappings
1338
+ to map event payload to Metaflow parameters for the flow.
1339
+ ```
1340
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1341
+ ```
1342
+ or
1343
+ ```
1344
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1345
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1346
+ ```
1347
+
1348
+ 'parameters' can also be a list of strings and tuples like so:
1349
+ ```
1350
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1351
+ ```
1352
+ This is equivalent to:
1353
+ ```
1354
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1355
+ ```
1422
1356
 
1423
1357
 
1424
1358
  Parameters
1425
1359
  ----------
1426
- hourly : bool, default False
1427
- Run the workflow hourly.
1428
- daily : bool, default True
1429
- Run the workflow daily.
1430
- weekly : bool, default False
1431
- Run the workflow weekly.
1432
- cron : str, optional, default None
1433
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1434
- specified by this expression.
1435
- timezone : str, optional, default None
1436
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1437
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1360
+ event : Union[str, Dict[str, Any]], optional, default None
1361
+ Event dependency for this flow.
1362
+ events : List[Union[str, Dict[str, Any]]], default []
1363
+ Events dependency for this flow.
1364
+ options : Dict[str, Any], default {}
1365
+ Backend-specific configuration for tuning eventing behavior.
1438
1366
  """
1439
1367
  ...
1440
1368
 
1441
- 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]]:
1369
+ def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1442
1370
  """
1443
- 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.
1444
- 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.
1371
+ Specifies what flows belong to the same project.
1372
+
1373
+ A project-specific namespace is created for all flows that
1374
+ use the same `@project(name)`.
1445
1375
 
1446
1376
 
1447
1377
  Parameters
1448
1378
  ----------
1449
- timeout : int
1450
- Time, in seconds before the task times out and fails. (Default: 3600)
1451
- poke_interval : int
1452
- Time in seconds that the job should wait in between each try. (Default: 60)
1453
- mode : str
1454
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1455
- exponential_backoff : bool
1456
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1457
- pool : str
1458
- the slot pool this task should run in,
1459
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1460
- soft_fail : bool
1461
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1462
1379
  name : str
1463
- Name of the sensor on Airflow
1464
- description : str
1465
- Description of sensor in the Airflow UI
1466
- external_dag_id : str
1467
- The dag_id that contains the task you want to wait for.
1468
- external_task_ids : List[str]
1469
- The list of task_ids that you want to wait for.
1470
- If None (default value) the sensor waits for the DAG. (Default: None)
1471
- allowed_states : List[str]
1472
- Iterable of allowed states, (Default: ['success'])
1473
- failed_states : List[str]
1474
- Iterable of failed or dis-allowed states. (Default: None)
1475
- execution_delta : datetime.timedelta
1476
- time difference with the previous execution to look at,
1477
- the default is the same logical date as the current task or DAG. (Default: None)
1478
- check_existence: bool
1479
- Set to True to check if the external task exists or check if
1480
- the DAG to wait for exists. (Default: True)
1380
+ Project name. Make sure that the name is unique amongst all
1381
+ projects that use the same production scheduler. The name may
1382
+ contain only lowercase alphanumeric characters and underscores.
1383
+
1384
+ branch : Optional[str], default None
1385
+ The branch to use. If not specified, the branch is set to
1386
+ `user.<username>` unless `production` is set to `True`. This can
1387
+ also be set on the command line using `--branch` as a top-level option.
1388
+ It is an error to specify `branch` in the decorator and on the command line.
1389
+
1390
+ production : bool, default False
1391
+ Whether or not the branch is the production branch. This can also be set on the
1392
+ command line using `--production` as a top-level option. It is an error to specify
1393
+ `production` in the decorator and on the command line.
1394
+ The project branch name will be:
1395
+ - if `branch` is specified:
1396
+ - if `production` is True: `prod.<branch>`
1397
+ - if `production` is False: `test.<branch>`
1398
+ - if `branch` is not specified:
1399
+ - if `production` is True: `prod`
1400
+ - if `production` is False: `user.<username>`
1481
1401
  """
1482
1402
  ...
1483
1403
 
@@ -1525,43 +1445,96 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
1525
1445
  ...
1526
1446
 
1527
1447
  @typing.overload
1528
- def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1448
+ 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]]:
1529
1449
  """
1530
- Specifies the PyPI packages for all steps of the flow.
1450
+ Specifies the times when the flow should be run when running on a
1451
+ production scheduler.
1531
1452
 
1532
- Use `@pypi_base` to set common packages required by all
1533
- steps and use `@pypi` to specify step-specific overrides.
1534
1453
 
1535
1454
  Parameters
1536
1455
  ----------
1537
- packages : Dict[str, str], default: {}
1538
- Packages to use for this flow. The key is the name of the package
1539
- and the value is the version to use.
1540
- python : str, optional, default: None
1541
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1542
- that the version used will correspond to the version of the Python interpreter used to start the run.
1456
+ hourly : bool, default False
1457
+ Run the workflow hourly.
1458
+ daily : bool, default True
1459
+ Run the workflow daily.
1460
+ weekly : bool, default False
1461
+ Run the workflow weekly.
1462
+ cron : str, optional, default None
1463
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1464
+ specified by this expression.
1465
+ timezone : str, optional, default None
1466
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1467
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1543
1468
  """
1544
1469
  ...
1545
1470
 
1546
1471
  @typing.overload
1547
- def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1472
+ def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1548
1473
  ...
1549
1474
 
1550
- def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1475
+ 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):
1551
1476
  """
1552
- Specifies the PyPI packages for all steps of the flow.
1477
+ Specifies the times when the flow should be run when running on a
1478
+ production scheduler.
1553
1479
 
1554
- Use `@pypi_base` to set common packages required by all
1555
- steps and use `@pypi` to specify step-specific overrides.
1556
1480
 
1557
1481
  Parameters
1558
1482
  ----------
1559
- packages : Dict[str, str], default: {}
1560
- Packages to use for this flow. The key is the name of the package
1561
- and the value is the version to use.
1562
- python : str, optional, default: None
1563
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1564
- that the version used will correspond to the version of the Python interpreter used to start the run.
1483
+ hourly : bool, default False
1484
+ Run the workflow hourly.
1485
+ daily : bool, default True
1486
+ Run the workflow daily.
1487
+ weekly : bool, default False
1488
+ Run the workflow weekly.
1489
+ cron : str, optional, default None
1490
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1491
+ specified by this expression.
1492
+ timezone : str, optional, default None
1493
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1494
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1495
+ """
1496
+ ...
1497
+
1498
+ 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]]:
1499
+ """
1500
+ 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.
1501
+ 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.
1502
+
1503
+
1504
+ Parameters
1505
+ ----------
1506
+ timeout : int
1507
+ Time, in seconds before the task times out and fails. (Default: 3600)
1508
+ poke_interval : int
1509
+ Time in seconds that the job should wait in between each try. (Default: 60)
1510
+ mode : str
1511
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1512
+ exponential_backoff : bool
1513
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1514
+ pool : str
1515
+ the slot pool this task should run in,
1516
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1517
+ soft_fail : bool
1518
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1519
+ name : str
1520
+ Name of the sensor on Airflow
1521
+ description : str
1522
+ Description of sensor in the Airflow UI
1523
+ external_dag_id : str
1524
+ The dag_id that contains the task you want to wait for.
1525
+ external_task_ids : List[str]
1526
+ The list of task_ids that you want to wait for.
1527
+ If None (default value) the sensor waits for the DAG. (Default: None)
1528
+ allowed_states : List[str]
1529
+ Iterable of allowed states, (Default: ['success'])
1530
+ failed_states : List[str]
1531
+ Iterable of failed or dis-allowed states. (Default: None)
1532
+ execution_delta : datetime.timedelta
1533
+ time difference with the previous execution to look at,
1534
+ the default is the same logical date as the current task or DAG. (Default: None)
1535
+ check_existence: bool
1536
+ Set to True to check if the external task exists or check if
1537
+ the DAG to wait for exists. (Default: True)
1565
1538
  """
1566
1539
  ...
1567
1540
 
@@ -1717,131 +1690,158 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
1717
1690
  """
1718
1691
  ...
1719
1692
 
1720
- def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1693
+ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1721
1694
  """
1722
- Specifies what flows belong to the same project.
1695
+ Allows setting external datastores to save data for the
1696
+ `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1723
1697
 
1724
- A project-specific namespace is created for all flows that
1725
- use the same `@project(name)`.
1698
+ This decorator is useful when users wish to save data to a different datastore
1699
+ than what is configured in Metaflow. This can be for variety of reasons:
1726
1700
 
1701
+ 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1702
+ 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1703
+ - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1704
+ 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1705
+ - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1727
1706
 
1728
- Parameters
1707
+ Usage:
1729
1708
  ----------
1730
- name : str
1731
- Project name. Make sure that the name is unique amongst all
1732
- projects that use the same production scheduler. The name may
1733
- contain only lowercase alphanumeric characters and underscores.
1734
1709
 
1735
- branch : Optional[str], default None
1736
- The branch to use. If not specified, the branch is set to
1737
- `user.<username>` unless `production` is set to `True`. This can
1738
- also be set on the command line using `--branch` as a top-level option.
1739
- It is an error to specify `branch` in the decorator and on the command line.
1710
+ - Using a custom IAM role to access the datastore.
1740
1711
 
1741
- production : bool, default False
1742
- Whether or not the branch is the production branch. This can also be set on the
1743
- command line using `--production` as a top-level option. It is an error to specify
1744
- `production` in the decorator and on the command line.
1745
- The project branch name will be:
1746
- - if `branch` is specified:
1747
- - if `production` is True: `prod.<branch>`
1748
- - if `production` is False: `test.<branch>`
1749
- - if `branch` is not specified:
1750
- - if `production` is True: `prod`
1751
- - if `production` is False: `user.<username>`
1712
+ ```python
1713
+ @with_artifact_store(
1714
+ type="s3",
1715
+ config=lambda: {
1716
+ "root": "s3://my-bucket-foo/path/to/root",
1717
+ "role_arn": ROLE,
1718
+ },
1719
+ )
1720
+ class MyFlow(FlowSpec):
1721
+
1722
+ @checkpoint
1723
+ @step
1724
+ def start(self):
1725
+ with open("my_file.txt", "w") as f:
1726
+ f.write("Hello, World!")
1727
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1728
+ self.next(self.end)
1729
+
1730
+ ```
1731
+
1732
+ - Using credentials to access the s3-compatible datastore.
1733
+
1734
+ ```python
1735
+ @with_artifact_store(
1736
+ type="s3",
1737
+ config=lambda: {
1738
+ "root": "s3://my-bucket-foo/path/to/root",
1739
+ "client_params": {
1740
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1741
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1742
+ },
1743
+ },
1744
+ )
1745
+ class MyFlow(FlowSpec):
1746
+
1747
+ @checkpoint
1748
+ @step
1749
+ def start(self):
1750
+ with open("my_file.txt", "w") as f:
1751
+ f.write("Hello, World!")
1752
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1753
+ self.next(self.end)
1754
+
1755
+ ```
1756
+
1757
+ - Accessing objects stored in external datastores after task execution.
1758
+
1759
+ ```python
1760
+ run = Run("CheckpointsTestsFlow/8992")
1761
+ with artifact_store_from(run=run, config={
1762
+ "client_params": {
1763
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1764
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1765
+ },
1766
+ }):
1767
+ with Checkpoint() as cp:
1768
+ latest = cp.list(
1769
+ task=run["start"].task
1770
+ )[0]
1771
+ print(latest)
1772
+ cp.load(
1773
+ latest,
1774
+ "test-checkpoints"
1775
+ )
1776
+
1777
+ task = Task("TorchTuneFlow/8484/train/53673")
1778
+ with artifact_store_from(run=run, config={
1779
+ "client_params": {
1780
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1781
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1782
+ },
1783
+ }):
1784
+ load_model(
1785
+ task.data.model_ref,
1786
+ "test-models"
1787
+ )
1788
+ ```
1789
+ Parameters:
1790
+ ----------
1791
+
1792
+ type: str
1793
+ The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1794
+
1795
+ config: dict or Callable
1796
+ Dictionary of configuration options for the datastore. The following keys are required:
1797
+ - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1798
+ - example: 's3://bucket-name/path/to/root'
1799
+ - example: 'gs://bucket-name/path/to/root'
1800
+ - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1801
+ - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1802
+ - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1803
+ - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1752
1804
  """
1753
1805
  ...
1754
1806
 
1755
1807
  @typing.overload
1756
- 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]]:
1808
+ def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1757
1809
  """
1758
- Specifies the event(s) that this flow depends on.
1759
-
1760
- ```
1761
- @trigger(event='foo')
1762
- ```
1763
- or
1764
- ```
1765
- @trigger(events=['foo', 'bar'])
1766
- ```
1767
-
1768
- Additionally, you can specify the parameter mappings
1769
- to map event payload to Metaflow parameters for the flow.
1770
- ```
1771
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1772
- ```
1773
- or
1774
- ```
1775
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1776
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1777
- ```
1778
-
1779
- 'parameters' can also be a list of strings and tuples like so:
1780
- ```
1781
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1782
- ```
1783
- This is equivalent to:
1784
- ```
1785
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1786
- ```
1810
+ Specifies the PyPI packages for all steps of the flow.
1787
1811
 
1812
+ Use `@pypi_base` to set common packages required by all
1813
+ steps and use `@pypi` to specify step-specific overrides.
1788
1814
 
1789
1815
  Parameters
1790
1816
  ----------
1791
- event : Union[str, Dict[str, Any]], optional, default None
1792
- Event dependency for this flow.
1793
- events : List[Union[str, Dict[str, Any]]], default []
1794
- Events dependency for this flow.
1795
- options : Dict[str, Any], default {}
1796
- Backend-specific configuration for tuning eventing behavior.
1817
+ packages : Dict[str, str], default: {}
1818
+ Packages to use for this flow. The key is the name of the package
1819
+ and the value is the version to use.
1820
+ python : str, optional, default: None
1821
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1822
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1797
1823
  """
1798
1824
  ...
1799
1825
 
1800
1826
  @typing.overload
1801
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1827
+ def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1802
1828
  ...
1803
1829
 
1804
- 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] = {}):
1830
+ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1805
1831
  """
1806
- Specifies the event(s) that this flow depends on.
1807
-
1808
- ```
1809
- @trigger(event='foo')
1810
- ```
1811
- or
1812
- ```
1813
- @trigger(events=['foo', 'bar'])
1814
- ```
1815
-
1816
- Additionally, you can specify the parameter mappings
1817
- to map event payload to Metaflow parameters for the flow.
1818
- ```
1819
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1820
- ```
1821
- or
1822
- ```
1823
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1824
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1825
- ```
1826
-
1827
- 'parameters' can also be a list of strings and tuples like so:
1828
- ```
1829
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1830
- ```
1831
- This is equivalent to:
1832
- ```
1833
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1834
- ```
1832
+ Specifies the PyPI packages for all steps of the flow.
1835
1833
 
1834
+ Use `@pypi_base` to set common packages required by all
1835
+ steps and use `@pypi` to specify step-specific overrides.
1836
1836
 
1837
1837
  Parameters
1838
1838
  ----------
1839
- event : Union[str, Dict[str, Any]], optional, default None
1840
- Event dependency for this flow.
1841
- events : List[Union[str, Dict[str, Any]]], default []
1842
- Events dependency for this flow.
1843
- options : Dict[str, Any], default {}
1844
- Backend-specific configuration for tuning eventing behavior.
1839
+ packages : Dict[str, str], default: {}
1840
+ Packages to use for this flow. The key is the name of the package
1841
+ and the value is the version to use.
1842
+ python : str, optional, default: None
1843
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1844
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1845
1845
  """
1846
1846
  ...
1847
1847