ob-metaflow-stubs 6.0.4.0__py2.py3-none-any.whl → 6.0.4.1rc0__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 +920 -914
  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 +7 -8
  8. metaflow-stubs/client/filecache.pyi +2 -2
  9. metaflow-stubs/events.pyi +3 -3
  10. metaflow-stubs/exception.pyi +2 -2
  11. metaflow-stubs/flowspec.pyi +10 -10
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +4 -4
  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 +2 -2
  18. metaflow-stubs/metadata_provider/util.pyi +2 -2
  19. metaflow-stubs/metaflow_config.pyi +6 -2
  20. metaflow-stubs/metaflow_current.pyi +35 -35
  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 +2 -2
  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 +3 -3
  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 +3 -3
  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 +4 -4
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +5 -5
  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 +3 -3
  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 +2 -2
  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 +3 -3
  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 +2 -2
  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 +4 -4
  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 +2 -2
  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 +2 -2
  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 +2 -2
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +2 -2
  64. metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +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 +2 -2
  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 +4 -4
  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 +3 -3
  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 +5 -5
  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 +3 -3
  83. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/unified_config.pyi +4 -4
  84. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/dependencies.pyi +4 -4
  85. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/deployer.pyi +3 -3
  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 +3 -3
  99. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +4 -4
  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 +4 -4
  124. metaflow-stubs/plugins/__init__.pyi +10 -10
  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 +3 -3
  136. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
  137. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +4 -4
  138. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +3 -3
  139. metaflow-stubs/plugins/argo/exit_hooks.pyi +3 -3
  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 +3 -3
  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 +3 -3
  155. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
  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 +3 -3
  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 +2 -2
  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 +3 -5
  168. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
  169. metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
  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 +2 -2
  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 +3 -3
  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 +3 -3
  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 +2 -2
  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 +3 -3
  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 +5 -4
  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 +4 -4
  228. metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
  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 +4 -3
  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 +28 -28
  236. metaflow-stubs/runner/deployer_impl.pyi +3 -3
  237. metaflow-stubs/runner/metaflow_runner.pyi +5 -5
  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 +3 -4
  249. metaflow-stubs/user_configs/config_parameters.pyi +6 -8
  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.1rc0.dist-info}/METADATA +1 -1
  257. ob_metaflow_stubs-6.0.4.1rc0.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.1rc0.dist-info}/WHEEL +0 -0
  261. {ob_metaflow_stubs-6.0.4.0.dist-info → ob_metaflow_stubs-6.0.4.1rc0.dist-info}/top_level.txt +0 -0
@@ -1,19 +1,20 @@
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:03:25.730478 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
9
  import typing
10
10
  if typing.TYPE_CHECKING:
11
- import typing
12
11
  import datetime
12
+ import typing
13
13
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
14
14
  StepFlag = typing.NewType("StepFlag", bool)
15
15
 
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,8 +35,10 @@ 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 .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
38
42
  from . import cards as cards
39
43
  from . import tuple_util as tuple_util
40
44
  from . import events as events
@@ -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,6 +162,57 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
156
162
  """
157
163
  ...
158
164
 
165
+ @typing.overload
166
+ 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]]]:
167
+ """
168
+ Specifies that the step will success under all circumstances.
169
+
170
+ The decorator will create an optional artifact, specified by `var`, which
171
+ contains the exception raised. You can use it to detect the presence
172
+ of errors, indicating that all happy-path artifacts produced by the step
173
+ are missing.
174
+
175
+
176
+ Parameters
177
+ ----------
178
+ var : str, optional, default None
179
+ Name of the artifact in which to store the caught exception.
180
+ If not specified, the exception is not stored.
181
+ print_exception : bool, default True
182
+ Determines whether or not the exception is printed to
183
+ stdout when caught.
184
+ """
185
+ ...
186
+
187
+ @typing.overload
188
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
189
+ ...
190
+
191
+ @typing.overload
192
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
193
+ ...
194
+
195
+ 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):
196
+ """
197
+ Specifies that the step will success under all circumstances.
198
+
199
+ The decorator will create an optional artifact, specified by `var`, which
200
+ contains the exception raised. You can use it to detect the presence
201
+ of errors, indicating that all happy-path artifacts produced by the step
202
+ are missing.
203
+
204
+
205
+ Parameters
206
+ ----------
207
+ var : str, optional, default None
208
+ Name of the artifact in which to store the caught exception.
209
+ If not specified, the exception is not stored.
210
+ print_exception : bool, default True
211
+ Determines whether or not the exception is printed to
212
+ stdout when caught.
213
+ """
214
+ ...
215
+
159
216
  @typing.overload
160
217
  def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
161
218
  """
@@ -175,84 +232,58 @@ def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None
175
232
  """
176
233
  ...
177
234
 
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]]]:
235
+ @typing.overload
236
+ 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]]]:
179
237
  """
180
- Specifies that this step should execute on DGX cloud.
238
+ Specifies the number of times the task corresponding
239
+ to a step needs to be retried.
240
+
241
+ This decorator is useful for handling transient errors, such as networking issues.
242
+ If your task contains operations that can't be retried safely, e.g. database updates,
243
+ it is advisable to annotate it with `@retry(times=0)`.
244
+
245
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
246
+ decorator will execute a no-op task after all retries have been exhausted,
247
+ ensuring that the flow execution can continue.
181
248
 
182
249
 
183
250
  Parameters
184
251
  ----------
185
- gpu : int
186
- Number of GPUs to use.
187
- gpu_type : str
188
- Type of Nvidia GPU to use.
252
+ times : int, default 3
253
+ Number of times to retry this task.
254
+ minutes_between_retries : int, default 2
255
+ Number of minutes between retries.
189
256
  """
190
257
  ...
191
258
 
192
259
  @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
- """
260
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
197
261
  ...
198
262
 
199
263
  @typing.overload
200
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
201
- ...
202
-
203
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
204
- """
205
- Internal decorator to support Fast bakery
206
- """
264
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
207
265
  ...
208
266
 
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]]]:
267
+ 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):
210
268
  """
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.
269
+ Specifies the number of times the task corresponding
270
+ to a step needs to be retried.
223
271
 
224
- Valid model options
225
- -------------------
226
- Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
272
+ This decorator is useful for handling transient errors, such as networking issues.
273
+ If your task contains operations that can't be retried safely, e.g. database updates,
274
+ it is advisable to annotate it with `@retry(times=0)`.
227
275
 
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.
276
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
277
+ decorator will execute a no-op task after all retries have been exhausted,
278
+ ensuring that the flow execution can continue.
230
279
 
231
280
 
232
281
  Parameters
233
282
  ----------
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`.
283
+ times : int, default 3
284
+ Number of times to retry this task.
285
+ minutes_between_retries : int, default 2
286
+ Number of minutes between retries.
256
287
  """
257
288
  ...
258
289
 
@@ -300,448 +331,512 @@ def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy:
300
331
  ...
301
332
 
302
333
  @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]]]:
334
+ def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
304
335
  """
305
- Enables checkpointing for a step.
306
-
307
- > Examples
308
-
309
- - Saving Checkpoints
310
-
311
- ```python
312
- @checkpoint
313
- @step
314
- 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
- ```
333
-
334
- - Using Loaded Checkpoints
335
-
336
- ```python
337
- @retry(times=3)
338
- @checkpoint
339
- @step
340
- 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
- ...
351
- ```
336
+ Specifies secrets to be retrieved and injected as environment variables prior to
337
+ the execution of a step.
352
338
 
353
339
 
354
340
  Parameters
355
341
  ----------
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.
366
-
367
- temp_dir_root : str, default: None
368
- The root directory under which `current.checkpoint.directory` will be created.
342
+ sources : List[Union[str, Dict[str, Any]]], default: []
343
+ List of secret specs, defining how the secrets are to be retrieved
344
+ role : str, optional, default: None
345
+ Role to use for fetching secrets
369
346
  """
370
347
  ...
371
348
 
372
349
  @typing.overload
373
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
350
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
374
351
  ...
375
352
 
376
353
  @typing.overload
377
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
354
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
378
355
  ...
379
356
 
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):
357
+ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None):
381
358
  """
382
- Enables checkpointing for a step.
359
+ Specifies secrets to be retrieved and injected as environment variables prior to
360
+ the execution of a step.
383
361
 
384
- > Examples
385
362
 
386
- - Saving Checkpoints
363
+ Parameters
364
+ ----------
365
+ sources : List[Union[str, Dict[str, Any]]], default: []
366
+ List of secret specs, defining how the secrets are to be retrieved
367
+ role : str, optional, default: None
368
+ Role to use for fetching secrets
369
+ """
370
+ ...
371
+
372
+ 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]]]:
373
+ """
374
+ Specifies that this step should execute on DGX cloud.
375
+
376
+
377
+ Parameters
378
+ ----------
379
+ gpu : int
380
+ Number of GPUs to use.
381
+ gpu_type : str
382
+ Type of Nvidia GPU to use.
383
+ """
384
+ ...
385
+
386
+ @typing.overload
387
+ 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]]]:
388
+ """
389
+ Enables loading / saving of models within a step.
387
390
 
391
+ > Examples
392
+ - Saving Models
388
393
  ```python
389
- @checkpoint
394
+ @model
390
395
  @step
391
396
  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
- ```
397
+ # current.model.save returns a dictionary reference to the model saved
398
+ self.my_model = current.model.save(
399
+ path_to_my_model,
400
+ label="my_model",
401
+ metadata={
402
+ "epochs": 10,
403
+ "batch-size": 32,
404
+ "learning-rate": 0.001,
405
+ }
406
+ )
407
+ self.next(self.test)
410
408
 
411
- - Using Loaded Checkpoints
409
+ @model(load="my_model")
410
+ @step
411
+ def test(self):
412
+ # `current.model.loaded` returns a dictionary of the loaded models
413
+ # where the key is the name of the artifact and the value is the path to the model
414
+ print(os.listdir(current.model.loaded["my_model"]))
415
+ self.next(self.end)
416
+ ```
412
417
 
418
+ - Loading models
413
419
  ```python
414
- @retry(times=3)
415
- @checkpoint
416
420
  @step
417
421
  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
- ...
422
+ # current.model.load returns the path to the model loaded
423
+ checkpoint_path = current.model.load(
424
+ self.checkpoint_key,
425
+ )
426
+ model_path = current.model.load(
427
+ self.model,
428
+ )
429
+ self.next(self.test)
428
430
  ```
429
431
 
430
432
 
431
433
  Parameters
432
434
  ----------
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.
435
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
436
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
437
+ 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`.
438
+ 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
439
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
440
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
443
441
 
444
442
  temp_dir_root : str, default: None
445
- The root directory under which `current.checkpoint.directory` will be created.
446
- """
447
- ...
448
-
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]]]:
451
- """
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`.
467
-
468
-
469
- Parameters
470
- ----------
471
- 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.
477
- 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.
443
+ The root directory under which `current.model.loaded` will store loaded models
482
444
  """
483
445
  ...
484
446
 
485
447
  @typing.overload
486
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
448
+ def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
487
449
  ...
488
450
 
489
451
  @typing.overload
490
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
452
+ def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
491
453
  ...
492
454
 
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):
455
+ 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):
494
456
  """
495
- Specifies the resources needed when executing this step.
457
+ Enables loading / saving of models within a step.
496
458
 
497
- Use `@resources` to specify the resource requirements
498
- independently of the specific compute layer (`@batch`, `@kubernetes`).
459
+ > Examples
460
+ - Saving Models
461
+ ```python
462
+ @model
463
+ @step
464
+ def train(self):
465
+ # current.model.save returns a dictionary reference to the model saved
466
+ self.my_model = current.model.save(
467
+ path_to_my_model,
468
+ label="my_model",
469
+ metadata={
470
+ "epochs": 10,
471
+ "batch-size": 32,
472
+ "learning-rate": 0.001,
473
+ }
474
+ )
475
+ self.next(self.test)
499
476
 
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
477
+ @model(load="my_model")
478
+ @step
479
+ def test(self):
480
+ # `current.model.loaded` returns a dictionary of the loaded models
481
+ # where the key is the name of the artifact and the value is the path to the model
482
+ print(os.listdir(current.model.loaded["my_model"]))
483
+ self.next(self.end)
505
484
  ```
506
- python myflow.py run --with kubernetes
485
+
486
+ - Loading models
487
+ ```python
488
+ @step
489
+ def train(self):
490
+ # current.model.load returns the path to the model loaded
491
+ checkpoint_path = current.model.load(
492
+ self.checkpoint_key,
493
+ )
494
+ model_path = current.model.load(
495
+ self.model,
496
+ )
497
+ self.next(self.test)
507
498
  ```
508
- which executes the flow on the desired system using the
509
- requirements specified in `@resources`.
510
499
 
511
500
 
512
501
  Parameters
513
502
  ----------
514
- cpu : int, default 1
515
- Number of CPUs required for this step.
516
- 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.
503
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
504
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
505
+ 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`.
506
+ 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
507
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
508
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
509
+
510
+ temp_dir_root : str, default: None
511
+ The root directory under which `current.model.loaded` will store loaded models
525
512
  """
526
513
  ...
527
514
 
528
515
  @typing.overload
529
- def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
516
+ 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]]]:
530
517
  """
531
- Specifies secrets to be retrieved and injected as environment variables prior to
532
- the execution of a step.
518
+ Specifies a timeout for your step.
519
+
520
+ This decorator is useful if this step may hang indefinitely.
521
+
522
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
523
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
524
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
525
+
526
+ Note that all the values specified in parameters are added together so if you specify
527
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
533
528
 
534
529
 
535
530
  Parameters
536
531
  ----------
537
- sources : List[Union[str, Dict[str, Any]]], default: []
538
- List of secret specs, defining how the secrets are to be retrieved
539
- role : str, optional, default: None
540
- Role to use for fetching secrets
532
+ seconds : int, default 0
533
+ Number of seconds to wait prior to timing out.
534
+ minutes : int, default 0
535
+ Number of minutes to wait prior to timing out.
536
+ hours : int, default 0
537
+ Number of hours to wait prior to timing out.
541
538
  """
542
539
  ...
543
540
 
544
541
  @typing.overload
545
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
542
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
546
543
  ...
547
544
 
548
545
  @typing.overload
549
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
546
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
550
547
  ...
551
548
 
552
- def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], role: typing.Optional[str] = None):
549
+ 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):
553
550
  """
554
- Specifies secrets to be retrieved and injected as environment variables prior to
555
- the execution of a step.
551
+ Specifies a timeout for your step.
552
+
553
+ This decorator is useful if this step may hang indefinitely.
554
+
555
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
556
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
557
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
558
+
559
+ Note that all the values specified in parameters are added together so if you specify
560
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
556
561
 
557
562
 
558
563
  Parameters
559
564
  ----------
560
- sources : List[Union[str, Dict[str, Any]]], default: []
561
- List of secret specs, defining how the secrets are to be retrieved
562
- role : str, optional, default: None
563
- Role to use for fetching secrets
565
+ seconds : int, default 0
566
+ Number of seconds to wait prior to timing out.
567
+ minutes : int, default 0
568
+ Number of minutes to wait prior to timing out.
569
+ hours : int, default 0
570
+ Number of hours to wait prior to timing out.
564
571
  """
565
572
  ...
566
573
 
567
- @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]]]:
574
+ 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]]]:
569
575
  """
570
- Specifies the PyPI packages for the step.
576
+ Decorator that helps cache, version and store models/datasets from huggingface hub.
571
577
 
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.
578
+ > Examples
579
+
580
+ **Usage: creating references of models from huggingface that may be loaded in downstream steps**
581
+ ```python
582
+ @huggingface_hub
583
+ @step
584
+ def pull_model_from_huggingface(self):
585
+ # `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
586
+ # and saves it in the backend storage based on the model's `repo_id`. If there exists a model
587
+ # with the same `repo_id` in the backend storage, it will not download the model again. The return
588
+ # value of the function is a reference to the model in the backend storage.
589
+ # This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
590
+
591
+ self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
592
+ self.llama_model = current.huggingface_hub.snapshot_download(
593
+ repo_id=self.model_id,
594
+ allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
595
+ )
596
+ self.next(self.train)
597
+ ```
598
+
599
+ **Usage: loading models directly from huggingface hub or from cache (from metaflow's datastore)**
600
+ ```python
601
+ @huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
602
+ @step
603
+ def pull_model_from_huggingface(self):
604
+ path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
605
+ ```
606
+
607
+ ```python
608
+ @huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora, "/my-lora-directory")])
609
+ @step
610
+ def finetune_model(self):
611
+ path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
612
+ # path_to_model will be /my-directory
613
+ ```
614
+
615
+ ```python
616
+ # Takes all the arguments passed to `snapshot_download`
617
+ # except for `local_dir`
618
+ @huggingface_hub(load=[
619
+ {
620
+ "repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
621
+ },
622
+ {
623
+ "repo_id": "myorg/mistral-lora",
624
+ "repo_type": "model",
625
+ },
626
+ ])
627
+ @step
628
+ def finetune_model(self):
629
+ path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
630
+ # path_to_model will be /my-directory
631
+ ```
576
632
 
577
633
 
578
634
  Parameters
579
635
  ----------
580
- packages : Dict[str, str], default: {}
636
+ temp_dir_root : str, optional
637
+ The root directory that will hold the temporary directory where objects will be downloaded.
638
+
639
+ load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
640
+ The list of repos (models/datasets) to load.
641
+
642
+ Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
643
+
644
+ - If repo (model/dataset) is not found in the datastore:
645
+ - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
646
+ - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
647
+ - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
648
+
649
+ - If repo is found in the datastore:
650
+ - Loads it directly from datastore to local path (can be temporary directory or specified path)
651
+ """
652
+ ...
653
+
654
+ @typing.overload
655
+ 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]]]:
656
+ """
657
+ Specifies the Conda environment for the step.
658
+
659
+ Information in this decorator will augment any
660
+ attributes set in the `@conda_base` flow-level decorator. Hence,
661
+ you can use `@conda_base` to set packages required by all
662
+ steps and use `@conda` to specify step-specific overrides.
663
+
664
+
665
+ Parameters
666
+ ----------
667
+ packages : Dict[str, str], default {}
581
668
  Packages to use for this step. The key is the name of the package
582
669
  and the value is the version to use.
583
- python : str, optional, default: None
670
+ libraries : Dict[str, str], default {}
671
+ Supported for backward compatibility. When used with packages, packages will take precedence.
672
+ python : str, optional, default None
584
673
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
585
674
  that the version used will correspond to the version of the Python interpreter used to start the run.
675
+ disabled : bool, default False
676
+ If set to True, disables @conda.
586
677
  """
587
678
  ...
588
679
 
589
680
  @typing.overload
590
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
681
+ def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
591
682
  ...
592
683
 
593
684
  @typing.overload
594
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
685
+ def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
595
686
  ...
596
687
 
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):
688
+ 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):
598
689
  """
599
- Specifies the PyPI packages for the step.
690
+ Specifies the Conda environment for the step.
600
691
 
601
692
  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.
693
+ attributes set in the `@conda_base` flow-level decorator. Hence,
694
+ you can use `@conda_base` to set packages required by all
695
+ steps and use `@conda` to specify step-specific overrides.
605
696
 
606
697
 
607
698
  Parameters
608
699
  ----------
609
- packages : Dict[str, str], default: {}
700
+ packages : Dict[str, str], default {}
610
701
  Packages to use for this step. The key is the name of the package
611
702
  and the value is the version to use.
612
- python : str, optional, default: None
703
+ libraries : Dict[str, str], default {}
704
+ Supported for backward compatibility. When used with packages, packages will take precedence.
705
+ python : str, optional, default None
613
706
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
614
707
  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.
621
-
622
-
623
- Parameters
624
- ----------
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.
708
+ disabled : bool, default False
709
+ If set to True, disables @conda.
631
710
  """
632
711
  ...
633
712
 
634
713
  @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]]]:
714
+ 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]]]:
636
715
  """
637
- Specifies the number of times the task corresponding
638
- to a step needs to be retried.
716
+ Specifies the resources needed when executing this step.
639
717
 
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)`.
718
+ Use `@resources` to specify the resource requirements
719
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
643
720
 
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.
721
+ You can choose the compute layer on the command line by executing e.g.
722
+ ```
723
+ python myflow.py run --with batch
724
+ ```
725
+ or
726
+ ```
727
+ python myflow.py run --with kubernetes
728
+ ```
729
+ which executes the flow on the desired system using the
730
+ requirements specified in `@resources`.
647
731
 
648
732
 
649
733
  Parameters
650
734
  ----------
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.
735
+ cpu : int, default 1
736
+ Number of CPUs required for this step.
737
+ gpu : int, optional, default None
738
+ Number of GPUs required for this step.
739
+ disk : int, optional, default None
740
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
741
+ memory : int, default 4096
742
+ Memory size (in MB) required for this step.
743
+ shared_memory : int, optional, default None
744
+ The value for the size (in MiB) of the /dev/shm volume for this step.
745
+ This parameter maps to the `--shm-size` option in Docker.
655
746
  """
656
747
  ...
657
748
 
658
749
  @typing.overload
659
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
750
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
660
751
  ...
661
752
 
662
753
  @typing.overload
663
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
754
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
664
755
  ...
665
756
 
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):
757
+ 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):
667
758
  """
668
- Specifies the number of times the task corresponding
669
- to a step needs to be retried.
759
+ Specifies the resources needed when executing this step.
670
760
 
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)`.
761
+ Use `@resources` to specify the resource requirements
762
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
674
763
 
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.
764
+ You can choose the compute layer on the command line by executing e.g.
765
+ ```
766
+ python myflow.py run --with batch
767
+ ```
768
+ or
769
+ ```
770
+ python myflow.py run --with kubernetes
771
+ ```
772
+ which executes the flow on the desired system using the
773
+ requirements specified in `@resources`.
678
774
 
679
775
 
680
776
  Parameters
681
777
  ----------
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.
778
+ cpu : int, default 1
779
+ Number of CPUs required for this step.
780
+ gpu : int, optional, default None
781
+ Number of GPUs required for this step.
782
+ disk : int, optional, default None
783
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
784
+ memory : int, default 4096
785
+ Memory size (in MB) required for this step.
786
+ shared_memory : int, optional, default None
787
+ The value for the size (in MiB) of the /dev/shm volume for this step.
788
+ This parameter maps to the `--shm-size` option in Docker.
686
789
  """
687
790
  ...
688
791
 
689
792
  @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]]]:
793
+ 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]]]:
691
794
  """
692
- Specifies the Conda environment for the step.
795
+ Specifies the PyPI packages for the step.
693
796
 
694
797
  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.
798
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
799
+ you can use `@pypi_base` to set packages required by all
800
+ steps and use `@pypi` to specify step-specific overrides.
698
801
 
699
802
 
700
803
  Parameters
701
804
  ----------
702
- packages : Dict[str, str], default {}
805
+ packages : Dict[str, str], default: {}
703
806
  Packages to use for this step. The key is the name of the package
704
807
  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
808
+ python : str, optional, default: None
708
809
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
709
810
  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
811
  """
713
812
  ...
714
813
 
715
814
  @typing.overload
716
- def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
815
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
717
816
  ...
718
817
 
719
818
  @typing.overload
720
- def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
819
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
721
820
  ...
722
821
 
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):
822
+ 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):
724
823
  """
725
- Specifies the Conda environment for the step.
824
+ Specifies the PyPI packages for the step.
726
825
 
727
826
  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.
827
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
828
+ you can use `@pypi_base` to set packages required by all
829
+ steps and use `@pypi` to specify step-specific overrides.
731
830
 
732
831
 
733
832
  Parameters
734
833
  ----------
735
- packages : Dict[str, str], default {}
834
+ packages : Dict[str, str], default: {}
736
835
  Packages to use for this step. The key is the name of the package
737
836
  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
837
+ python : str, optional, default: None
741
838
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
742
839
  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
840
  """
746
841
  ...
747
842
 
@@ -794,267 +889,9 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
794
889
  """
795
890
  ...
796
891
 
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]]]:
892
+ 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]]]:
799
893
  """
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):
828
- """
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.
835
-
836
-
837
- Parameters
838
- ----------
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.
845
- """
846
- ...
847
-
848
- @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]]]:
850
- """
851
- Specifies a timeout for your step.
852
-
853
- This decorator is useful if this step may hang indefinitely.
854
-
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.
858
-
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.
861
-
862
-
863
- Parameters
864
- ----------
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.
871
- """
872
- ...
873
-
874
- @typing.overload
875
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
876
- ...
877
-
878
- @typing.overload
879
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
880
- ...
881
-
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):
883
- """
884
- Specifies a timeout for your step.
885
-
886
- This decorator is useful if this step may hang indefinitely.
887
-
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.
891
-
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.
894
-
895
-
896
- Parameters
897
- ----------
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.
904
- """
905
- ...
906
-
907
- @typing.overload
908
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
909
- """
910
- Decorator prototype for all step decorators. This function gets specialized
911
- and imported for all decorators types by _import_plugin_decorators().
912
- """
913
- ...
914
-
915
- @typing.overload
916
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
917
- ...
918
-
919
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
920
- """
921
- Decorator prototype for all step decorators. This function gets specialized
922
- and imported for all decorators types by _import_plugin_decorators().
923
- """
924
- ...
925
-
926
- @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.
894
+ Specifies that this step should execute on Kubernetes.
1058
895
 
1059
896
 
1060
897
  Parameters
@@ -1141,83 +978,39 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
1141
978
  """
1142
979
  ...
1143
980
 
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]]]:
981
+ @typing.overload
982
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1145
983
  """
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"])`
1160
-
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
- ```
1168
-
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"]
1175
- ```
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
1183
- ```
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
1201
- ```
1202
-
1203
-
1204
- Parameters
1205
- ----------
1206
- temp_dir_root : str, optional
1207
- The root directory that will hold the temporary directory where objects will be downloaded.
1208
-
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.
1211
-
1212
- Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
1213
-
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
-
1219
- - If repo is found in the datastore:
1220
- - Loads it directly from datastore to local path (can be temporary directory or specified path)
984
+ Decorator prototype for all step decorators. This function gets specialized
985
+ and imported for all decorators types by _import_plugin_decorators().
986
+ """
987
+ ...
988
+
989
+ @typing.overload
990
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
991
+ ...
992
+
993
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
994
+ """
995
+ Decorator prototype for all step decorators. This function gets specialized
996
+ and imported for all decorators types by _import_plugin_decorators().
997
+ """
998
+ ...
999
+
1000
+ @typing.overload
1001
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1002
+ """
1003
+ Internal decorator to support Fast bakery
1004
+ """
1005
+ ...
1006
+
1007
+ @typing.overload
1008
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1009
+ ...
1010
+
1011
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
1012
+ """
1013
+ Internal decorator to support Fast bakery
1221
1014
  """
1222
1015
  ...
1223
1016
 
@@ -1254,54 +1047,216 @@ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], Non
1254
1047
  """
1255
1048
  ...
1256
1049
 
1050
+ 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]]]:
1051
+ """
1052
+ Specifies that this step should execute on DGX cloud.
1053
+
1054
+
1055
+ Parameters
1056
+ ----------
1057
+ gpu : int
1058
+ Number of GPUs to use.
1059
+ gpu_type : str
1060
+ Type of Nvidia GPU to use.
1061
+ queue_timeout : int
1062
+ Time to keep the job in NVCF's queue.
1063
+ """
1064
+ ...
1065
+
1257
1066
  @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]]:
1067
+ 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]]]:
1259
1068
  """
1260
- Specifies the times when the flow should be run when running on a
1261
- production scheduler.
1069
+ Enables checkpointing for a step.
1070
+
1071
+ > Examples
1072
+
1073
+ - Saving Checkpoints
1074
+
1075
+ ```python
1076
+ @checkpoint
1077
+ @step
1078
+ def train(self):
1079
+ model = create_model(self.parameters, checkpoint_path = None)
1080
+ for i in range(self.epochs):
1081
+ # some training logic
1082
+ loss = model.train(self.dataset)
1083
+ if i % 10 == 0:
1084
+ model.save(
1085
+ current.checkpoint.directory,
1086
+ )
1087
+ # saves the contents of the `current.checkpoint.directory` as a checkpoint
1088
+ # and returns a reference dictionary to the checkpoint saved in the datastore
1089
+ self.latest_checkpoint = current.checkpoint.save(
1090
+ name="epoch_checkpoint",
1091
+ metadata={
1092
+ "epoch": i,
1093
+ "loss": loss,
1094
+ }
1095
+ )
1096
+ ```
1097
+
1098
+ - Using Loaded Checkpoints
1099
+
1100
+ ```python
1101
+ @retry(times=3)
1102
+ @checkpoint
1103
+ @step
1104
+ def train(self):
1105
+ # Assume that the task has restarted and the previous attempt of the task
1106
+ # saved a checkpoint
1107
+ checkpoint_path = None
1108
+ if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1109
+ print("Loaded checkpoint from the previous attempt")
1110
+ checkpoint_path = current.checkpoint.directory
1111
+
1112
+ model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1113
+ for i in range(self.epochs):
1114
+ ...
1115
+ ```
1262
1116
 
1263
1117
 
1264
1118
  Parameters
1265
1119
  ----------
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).
1120
+ load_policy : str, default: "fresh"
1121
+ The policy for loading the checkpoint. The following policies are supported:
1122
+ - "eager": Loads the the latest available checkpoint within the namespace.
1123
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1124
+ will be loaded at the start of the task.
1125
+ - "none": Do not load any checkpoint
1126
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1127
+ This mode helps loading checkpoints across various retry attempts of the same task.
1128
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1129
+ created within the task will be loaded when the task is retries execution on failure.
1130
+
1131
+ temp_dir_root : str, default: None
1132
+ The root directory under which `current.checkpoint.directory` will be created.
1278
1133
  """
1279
1134
  ...
1280
1135
 
1281
1136
  @typing.overload
1282
- def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1137
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1283
1138
  ...
1284
1139
 
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):
1140
+ @typing.overload
1141
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1142
+ ...
1143
+
1144
+ 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):
1286
1145
  """
1287
- Specifies the times when the flow should be run when running on a
1288
- production scheduler.
1146
+ Enables checkpointing for a step.
1147
+
1148
+ > Examples
1149
+
1150
+ - Saving Checkpoints
1151
+
1152
+ ```python
1153
+ @checkpoint
1154
+ @step
1155
+ def train(self):
1156
+ model = create_model(self.parameters, checkpoint_path = None)
1157
+ for i in range(self.epochs):
1158
+ # some training logic
1159
+ loss = model.train(self.dataset)
1160
+ if i % 10 == 0:
1161
+ model.save(
1162
+ current.checkpoint.directory,
1163
+ )
1164
+ # saves the contents of the `current.checkpoint.directory` as a checkpoint
1165
+ # and returns a reference dictionary to the checkpoint saved in the datastore
1166
+ self.latest_checkpoint = current.checkpoint.save(
1167
+ name="epoch_checkpoint",
1168
+ metadata={
1169
+ "epoch": i,
1170
+ "loss": loss,
1171
+ }
1172
+ )
1173
+ ```
1174
+
1175
+ - Using Loaded Checkpoints
1176
+
1177
+ ```python
1178
+ @retry(times=3)
1179
+ @checkpoint
1180
+ @step
1181
+ def train(self):
1182
+ # Assume that the task has restarted and the previous attempt of the task
1183
+ # saved a checkpoint
1184
+ checkpoint_path = None
1185
+ if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1186
+ print("Loaded checkpoint from the previous attempt")
1187
+ checkpoint_path = current.checkpoint.directory
1188
+
1189
+ model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1190
+ for i in range(self.epochs):
1191
+ ...
1192
+ ```
1193
+
1194
+
1195
+ Parameters
1196
+ ----------
1197
+ load_policy : str, default: "fresh"
1198
+ The policy for loading the checkpoint. The following policies are supported:
1199
+ - "eager": Loads the the latest available checkpoint within the namespace.
1200
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1201
+ will be loaded at the start of the task.
1202
+ - "none": Do not load any checkpoint
1203
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1204
+ This mode helps loading checkpoints across various retry attempts of the same task.
1205
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1206
+ created within the task will be loaded when the task is retries execution on failure.
1207
+
1208
+ temp_dir_root : str, default: None
1209
+ The root directory under which `current.checkpoint.directory` will be created.
1210
+ """
1211
+ ...
1212
+
1213
+ 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]]]:
1214
+ """
1215
+ This decorator is used to run vllm APIs as Metaflow task sidecars.
1216
+
1217
+ User code call
1218
+ --------------
1219
+ @vllm(
1220
+ model="...",
1221
+ ...
1222
+ )
1223
+
1224
+ Valid backend options
1225
+ ---------------------
1226
+ - 'local': Run as a separate process on the local task machine.
1227
+
1228
+ Valid model options
1229
+ -------------------
1230
+ Any HuggingFace model identifier, e.g. 'meta-llama/Llama-3.2-1B'
1231
+
1232
+ NOTE: vLLM's OpenAI-compatible server serves ONE model per server instance.
1233
+ If you need multiple models, you must create multiple @vllm decorators.
1289
1234
 
1290
1235
 
1291
1236
  Parameters
1292
1237
  ----------
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).
1238
+ model: str
1239
+ HuggingFace model identifier to be served by vLLM.
1240
+ backend: str
1241
+ Determines where and how to run the vLLM process.
1242
+ openai_api_server: bool
1243
+ Whether to use OpenAI-compatible API server mode (subprocess) instead of native engine.
1244
+ Default is False (uses native engine).
1245
+ Set to True for backward compatibility with existing code.
1246
+ debug: bool
1247
+ Whether to turn on verbose debugging logs.
1248
+ card_refresh_interval: int
1249
+ Interval in seconds for refreshing the vLLM status card.
1250
+ Only used when openai_api_server=True.
1251
+ max_retries: int
1252
+ Maximum number of retries checking for vLLM server startup.
1253
+ Only used when openai_api_server=True.
1254
+ retry_alert_frequency: int
1255
+ Frequency of alert logs for vLLM server startup retries.
1256
+ Only used when openai_api_server=True.
1257
+ engine_args : dict
1258
+ Additional keyword arguments to pass to the vLLM engine.
1259
+ For example, `tensor_parallel_size=2`.
1305
1260
  """
1306
1261
  ...
1307
1262
 
@@ -1340,142 +1295,6 @@ def project(*, name: str, branch: typing.Optional[str] = None, production: bool
1340
1295
  """
1341
1296
  ...
1342
1297
 
1343
- @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]]:
1345
- """
1346
- Specifies the event(s) that this flow depends on.
1347
-
1348
- ```
1349
- @trigger(event='foo')
1350
- ```
1351
- or
1352
- ```
1353
- @trigger(events=['foo', 'bar'])
1354
- ```
1355
-
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'}])
1365
- ```
1366
-
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'}})
1374
- ```
1375
-
1376
-
1377
- Parameters
1378
- ----------
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.
1385
- """
1386
- ...
1387
-
1388
- @typing.overload
1389
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1390
- ...
1391
-
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] = {}):
1393
- """
1394
- Specifies the event(s) that this flow depends on.
1395
-
1396
- ```
1397
- @trigger(event='foo')
1398
- ```
1399
- or
1400
- ```
1401
- @trigger(events=['foo', 'bar'])
1402
- ```
1403
-
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
- ```
1414
-
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:
1420
- ```
1421
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1422
- ```
1423
-
1424
-
1425
- Parameters
1426
- ----------
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.
1433
- """
1434
- ...
1435
-
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]]:
1437
- """
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.
1440
-
1441
-
1442
- Parameters
1443
- ----------
1444
- timeout : int
1445
- Time, in seconds before the task times out and fails. (Default: 3600)
1446
- poke_interval : int
1447
- Time in seconds that the job should wait in between each try. (Default: 60)
1448
- mode : str
1449
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1450
- exponential_backoff : bool
1451
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1452
- pool : str
1453
- the slot pool this task should run in,
1454
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1455
- soft_fail : bool
1456
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1457
- name : str
1458
- Name of the sensor on Airflow
1459
- description : str
1460
- 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)
1476
- """
1477
- ...
1478
-
1479
1298
  @typing.overload
1480
1299
  def trigger_on_finish(*, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1481
1300
  """
@@ -1577,97 +1396,54 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
1577
1396
  """
1578
1397
  ...
1579
1398
 
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)
1620
- """
1621
- ...
1622
-
1623
1399
  @typing.overload
1624
- def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1400
+ 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]]:
1625
1401
  """
1626
- Specifies the Conda environment for all steps of the flow.
1627
-
1628
- Use `@conda_base` to set common libraries required by all
1629
- steps and use `@conda` to specify step-specific additions.
1402
+ Specifies the times when the flow should be run when running on a
1403
+ production scheduler.
1630
1404
 
1631
1405
 
1632
1406
  Parameters
1633
1407
  ----------
1634
- packages : Dict[str, str], default {}
1635
- Packages to use for this flow. The key is the name of the package
1636
- and the value is the version to use.
1637
- libraries : Dict[str, str], default {}
1638
- Supported for backward compatibility. When used with packages, packages will take precedence.
1639
- python : str, optional, default None
1640
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1641
- that the version used will correspond to the version of the Python interpreter used to start the run.
1642
- disabled : bool, default False
1643
- If set to True, disables Conda.
1408
+ hourly : bool, default False
1409
+ Run the workflow hourly.
1410
+ daily : bool, default True
1411
+ Run the workflow daily.
1412
+ weekly : bool, default False
1413
+ Run the workflow weekly.
1414
+ cron : str, optional, default None
1415
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1416
+ specified by this expression.
1417
+ timezone : str, optional, default None
1418
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1419
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1644
1420
  """
1645
1421
  ...
1646
1422
 
1647
1423
  @typing.overload
1648
- def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1424
+ def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1649
1425
  ...
1650
1426
 
1651
- def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
1652
- """
1653
- Specifies the Conda environment for all steps of the flow.
1654
-
1655
- Use `@conda_base` to set common libraries required by all
1656
- steps and use `@conda` to specify step-specific additions.
1427
+ 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):
1428
+ """
1429
+ Specifies the times when the flow should be run when running on a
1430
+ production scheduler.
1657
1431
 
1658
1432
 
1659
1433
  Parameters
1660
1434
  ----------
1661
- packages : Dict[str, str], default {}
1662
- Packages to use for this flow. The key is the name of the package
1663
- and the value is the version to use.
1664
- libraries : Dict[str, str], default {}
1665
- Supported for backward compatibility. When used with packages, packages will take precedence.
1666
- python : str, optional, default None
1667
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1668
- that the version used will correspond to the version of the Python interpreter used to start the run.
1669
- disabled : bool, default False
1670
- If set to True, disables Conda.
1435
+ hourly : bool, default False
1436
+ Run the workflow hourly.
1437
+ daily : bool, default True
1438
+ Run the workflow daily.
1439
+ weekly : bool, default False
1440
+ Run the workflow weekly.
1441
+ cron : str, optional, default None
1442
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1443
+ specified by this expression.
1444
+ timezone : str, optional, default None
1445
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1446
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1671
1447
  """
1672
1448
  ...
1673
1449
 
@@ -1785,6 +1561,193 @@ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None)
1785
1561
  """
1786
1562
  ...
1787
1563
 
1564
+ @typing.overload
1565
+ 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]]:
1566
+ """
1567
+ Specifies the event(s) that this flow depends on.
1568
+
1569
+ ```
1570
+ @trigger(event='foo')
1571
+ ```
1572
+ or
1573
+ ```
1574
+ @trigger(events=['foo', 'bar'])
1575
+ ```
1576
+
1577
+ Additionally, you can specify the parameter mappings
1578
+ to map event payload to Metaflow parameters for the flow.
1579
+ ```
1580
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1581
+ ```
1582
+ or
1583
+ ```
1584
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1585
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1586
+ ```
1587
+
1588
+ 'parameters' can also be a list of strings and tuples like so:
1589
+ ```
1590
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1591
+ ```
1592
+ This is equivalent to:
1593
+ ```
1594
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1595
+ ```
1596
+
1597
+
1598
+ Parameters
1599
+ ----------
1600
+ event : Union[str, Dict[str, Any]], optional, default None
1601
+ Event dependency for this flow.
1602
+ events : List[Union[str, Dict[str, Any]]], default []
1603
+ Events dependency for this flow.
1604
+ options : Dict[str, Any], default {}
1605
+ Backend-specific configuration for tuning eventing behavior.
1606
+ """
1607
+ ...
1608
+
1609
+ @typing.overload
1610
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1611
+ ...
1612
+
1613
+ 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] = {}):
1614
+ """
1615
+ Specifies the event(s) that this flow depends on.
1616
+
1617
+ ```
1618
+ @trigger(event='foo')
1619
+ ```
1620
+ or
1621
+ ```
1622
+ @trigger(events=['foo', 'bar'])
1623
+ ```
1624
+
1625
+ Additionally, you can specify the parameter mappings
1626
+ to map event payload to Metaflow parameters for the flow.
1627
+ ```
1628
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1629
+ ```
1630
+ or
1631
+ ```
1632
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1633
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1634
+ ```
1635
+
1636
+ 'parameters' can also be a list of strings and tuples like so:
1637
+ ```
1638
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1639
+ ```
1640
+ This is equivalent to:
1641
+ ```
1642
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1643
+ ```
1644
+
1645
+
1646
+ Parameters
1647
+ ----------
1648
+ event : Union[str, Dict[str, Any]], optional, default None
1649
+ Event dependency for this flow.
1650
+ events : List[Union[str, Dict[str, Any]]], default []
1651
+ Events dependency for this flow.
1652
+ options : Dict[str, Any], default {}
1653
+ Backend-specific configuration for tuning eventing behavior.
1654
+ """
1655
+ ...
1656
+
1657
+ 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]]:
1658
+ """
1659
+ 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.
1660
+ 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.
1661
+
1662
+
1663
+ Parameters
1664
+ ----------
1665
+ timeout : int
1666
+ Time, in seconds before the task times out and fails. (Default: 3600)
1667
+ poke_interval : int
1668
+ Time in seconds that the job should wait in between each try. (Default: 60)
1669
+ mode : str
1670
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1671
+ exponential_backoff : bool
1672
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1673
+ pool : str
1674
+ the slot pool this task should run in,
1675
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1676
+ soft_fail : bool
1677
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1678
+ name : str
1679
+ Name of the sensor on Airflow
1680
+ description : str
1681
+ Description of sensor in the Airflow UI
1682
+ external_dag_id : str
1683
+ The dag_id that contains the task you want to wait for.
1684
+ external_task_ids : List[str]
1685
+ The list of task_ids that you want to wait for.
1686
+ If None (default value) the sensor waits for the DAG. (Default: None)
1687
+ allowed_states : List[str]
1688
+ Iterable of allowed states, (Default: ['success'])
1689
+ failed_states : List[str]
1690
+ Iterable of failed or dis-allowed states. (Default: None)
1691
+ execution_delta : datetime.timedelta
1692
+ time difference with the previous execution to look at,
1693
+ the default is the same logical date as the current task or DAG. (Default: None)
1694
+ check_existence: bool
1695
+ Set to True to check if the external task exists or check if
1696
+ the DAG to wait for exists. (Default: True)
1697
+ """
1698
+ ...
1699
+
1700
+ @typing.overload
1701
+ def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1702
+ """
1703
+ Specifies the Conda environment for all steps of the flow.
1704
+
1705
+ Use `@conda_base` to set common libraries required by all
1706
+ steps and use `@conda` to specify step-specific additions.
1707
+
1708
+
1709
+ Parameters
1710
+ ----------
1711
+ packages : Dict[str, str], default {}
1712
+ Packages to use for this flow. The key is the name of the package
1713
+ and the value is the version to use.
1714
+ libraries : Dict[str, str], default {}
1715
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1716
+ python : str, optional, default None
1717
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1718
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1719
+ disabled : bool, default False
1720
+ If set to True, disables Conda.
1721
+ """
1722
+ ...
1723
+
1724
+ @typing.overload
1725
+ def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1726
+ ...
1727
+
1728
+ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
1729
+ """
1730
+ Specifies the Conda environment for all steps of the flow.
1731
+
1732
+ Use `@conda_base` to set common libraries required by all
1733
+ steps and use `@conda` to specify step-specific additions.
1734
+
1735
+
1736
+ Parameters
1737
+ ----------
1738
+ packages : Dict[str, str], default {}
1739
+ Packages to use for this flow. The key is the name of the package
1740
+ and the value is the version to use.
1741
+ libraries : Dict[str, str], default {}
1742
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1743
+ python : str, optional, default None
1744
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1745
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1746
+ disabled : bool, default False
1747
+ If set to True, disables Conda.
1748
+ """
1749
+ ...
1750
+
1788
1751
  @typing.overload
1789
1752
  def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1790
1753
  """
@@ -1826,5 +1789,48 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
1826
1789
  """
1827
1790
  ...
1828
1791
 
1792
+ 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]]:
1793
+ """
1794
+ 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)
1795
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1796
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1797
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1798
+ starts only after all sensors finish.
1799
+
1800
+
1801
+ Parameters
1802
+ ----------
1803
+ timeout : int
1804
+ Time, in seconds before the task times out and fails. (Default: 3600)
1805
+ poke_interval : int
1806
+ Time in seconds that the job should wait in between each try. (Default: 60)
1807
+ mode : str
1808
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1809
+ exponential_backoff : bool
1810
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1811
+ pool : str
1812
+ the slot pool this task should run in,
1813
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1814
+ soft_fail : bool
1815
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1816
+ name : str
1817
+ Name of the sensor on Airflow
1818
+ description : str
1819
+ Description of sensor in the Airflow UI
1820
+ bucket_key : Union[str, List[str]]
1821
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1822
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1823
+ bucket_name : str
1824
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1825
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1826
+ wildcard_match : bool
1827
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1828
+ aws_conn_id : str
1829
+ a reference to the s3 connection on Airflow. (Default: None)
1830
+ verify : bool
1831
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1832
+ """
1833
+ ...
1834
+
1829
1835
  pkg_name: str
1830
1836