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