ob-metaflow-stubs 6.0.10.3__py2.py3-none-any.whl → 6.0.10.5__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 (262) hide show
  1. metaflow-stubs/__init__.pyi +1012 -996
  2. metaflow-stubs/cards.pyi +2 -2
  3. metaflow-stubs/cli.pyi +2 -2
  4. metaflow-stubs/cli_components/__init__.pyi +2 -2
  5. metaflow-stubs/cli_components/utils.pyi +2 -2
  6. metaflow-stubs/client/__init__.pyi +2 -2
  7. metaflow-stubs/client/core.pyi +6 -6
  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 +5 -5
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +4 -4
  14. metaflow-stubs/meta_files.pyi +2 -2
  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 +2 -2
  20. metaflow-stubs/metaflow_current.pyi +117 -73
  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 +4 -4
  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 +4 -4
  35. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +2 -2
  36. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +4 -4
  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 +2 -2
  40. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +2 -2
  41. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +2 -2
  42. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +3 -3
  43. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +2 -2
  44. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +2 -2
  45. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +2 -2
  46. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +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 +2 -2
  49. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +2 -2
  50. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +2 -2
  51. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +90 -6
  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 +2 -2
  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 +3 -3
  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 +3 -3
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/capsule.pyi +3 -3
  75. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/click_importer.pyi +2 -2
  76. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/__init__.pyi +2 -2
  77. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/code_package/code_packager.pyi +2 -2
  78. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/__init__.pyi +2 -2
  79. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/cli_generator.pyi +2 -2
  80. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/config/config_utils.pyi +4 -4
  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 +3 -3
  84. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/dependencies.pyi +2 -2
  85. metaflow-stubs/mf_extensions/outerbounds/plugins/apps/core/deployer.pyi +5 -5
  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 +2 -2
  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 +3 -3
  96. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +3 -3
  97. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +2 -2
  98. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +2 -2
  99. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +2 -2
  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 +3 -3
  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/mf_extensions/outerbounds/toplevel/s3_proxy.pyi +2 -2
  116. metaflow-stubs/multicore_utils.pyi +2 -2
  117. metaflow-stubs/ob_internal.pyi +2 -2
  118. metaflow-stubs/packaging_sys/__init__.pyi +5 -5
  119. metaflow-stubs/packaging_sys/backend.pyi +5 -5
  120. metaflow-stubs/packaging_sys/distribution_support.pyi +5 -5
  121. metaflow-stubs/packaging_sys/tar_backend.pyi +6 -6
  122. metaflow-stubs/packaging_sys/utils.pyi +2 -2
  123. metaflow-stubs/packaging_sys/v1.pyi +3 -3
  124. metaflow-stubs/parameters.pyi +4 -4
  125. metaflow-stubs/plugins/__init__.pyi +16 -16
  126. metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
  127. metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
  128. metaflow-stubs/plugins/airflow/exception.pyi +2 -2
  129. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
  130. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
  131. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
  132. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
  133. metaflow-stubs/plugins/argo/__init__.pyi +2 -2
  134. metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
  135. metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
  136. metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
  137. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +2 -2
  138. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
  139. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +2 -2
  140. metaflow-stubs/plugins/argo/exit_hooks.pyi +2 -2
  141. metaflow-stubs/plugins/aws/__init__.pyi +2 -2
  142. metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
  143. metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
  144. metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
  145. metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
  146. metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
  147. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +2 -2
  148. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
  149. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +5 -5
  150. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
  151. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
  152. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
  153. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
  154. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
  155. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +3 -3
  156. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +3 -3
  157. metaflow-stubs/plugins/azure/__init__.pyi +2 -2
  158. metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
  159. metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
  160. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +5 -5
  161. metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
  162. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
  163. metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
  164. metaflow-stubs/plugins/cards/__init__.pyi +2 -2
  165. metaflow-stubs/plugins/cards/card_client.pyi +2 -2
  166. metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
  167. metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
  168. metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
  169. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
  170. metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
  171. metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
  172. metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
  173. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
  174. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
  175. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
  176. metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
  177. metaflow-stubs/plugins/cards/component_serializer.pyi +2 -2
  178. metaflow-stubs/plugins/cards/exception.pyi +2 -2
  179. metaflow-stubs/plugins/catch_decorator.pyi +3 -3
  180. metaflow-stubs/plugins/datatools/__init__.pyi +2 -2
  181. metaflow-stubs/plugins/datatools/local.pyi +2 -2
  182. metaflow-stubs/plugins/datatools/s3/__init__.pyi +2 -2
  183. metaflow-stubs/plugins/datatools/s3/s3.pyi +2 -2
  184. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
  185. metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
  186. metaflow-stubs/plugins/debug_logger.pyi +2 -2
  187. metaflow-stubs/plugins/debug_monitor.pyi +2 -2
  188. metaflow-stubs/plugins/environment_decorator.pyi +2 -2
  189. metaflow-stubs/plugins/events_decorator.pyi +45 -4
  190. metaflow-stubs/plugins/exit_hook/__init__.pyi +2 -2
  191. metaflow-stubs/plugins/exit_hook/exit_hook_decorator.pyi +2 -2
  192. metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
  193. metaflow-stubs/plugins/frameworks/pytorch.pyi +2 -2
  194. metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
  195. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +5 -5
  196. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
  197. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
  198. metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
  199. metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
  200. metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
  201. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
  202. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +2 -2
  203. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
  204. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +2 -2
  205. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
  206. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +2 -2
  207. metaflow-stubs/plugins/ollama/__init__.pyi +3 -3
  208. metaflow-stubs/plugins/optuna/__init__.pyi +2 -2
  209. metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
  210. metaflow-stubs/plugins/perimeters.pyi +2 -2
  211. metaflow-stubs/plugins/project_decorator.pyi +2 -2
  212. metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
  213. metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
  214. metaflow-stubs/plugins/pypi/conda_environment.pyi +5 -5
  215. metaflow-stubs/plugins/pypi/parsers.pyi +2 -2
  216. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
  217. metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
  218. metaflow-stubs/plugins/pypi/utils.pyi +2 -2
  219. metaflow-stubs/plugins/resources_decorator.pyi +2 -2
  220. metaflow-stubs/plugins/retry_decorator.pyi +2 -2
  221. metaflow-stubs/plugins/secrets/__init__.pyi +3 -3
  222. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +4 -4
  223. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
  224. metaflow-stubs/plugins/secrets/secrets_func.pyi +2 -2
  225. metaflow-stubs/plugins/secrets/secrets_spec.pyi +2 -2
  226. metaflow-stubs/plugins/secrets/utils.pyi +2 -2
  227. metaflow-stubs/plugins/snowflake/__init__.pyi +2 -2
  228. metaflow-stubs/plugins/storage_executor.pyi +2 -2
  229. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +2 -2
  230. metaflow-stubs/plugins/timeout_decorator.pyi +3 -3
  231. metaflow-stubs/plugins/torchtune/__init__.pyi +2 -2
  232. metaflow-stubs/plugins/uv/__init__.pyi +2 -2
  233. metaflow-stubs/plugins/uv/uv_environment.pyi +2 -2
  234. metaflow-stubs/profilers/__init__.pyi +2 -2
  235. metaflow-stubs/pylint_wrapper.pyi +2 -2
  236. metaflow-stubs/runner/__init__.pyi +2 -2
  237. metaflow-stubs/runner/deployer.pyi +5 -5
  238. metaflow-stubs/runner/deployer_impl.pyi +3 -3
  239. metaflow-stubs/runner/metaflow_runner.pyi +4 -4
  240. metaflow-stubs/runner/nbdeploy.pyi +2 -2
  241. metaflow-stubs/runner/nbrun.pyi +2 -2
  242. metaflow-stubs/runner/subprocess_manager.pyi +2 -2
  243. metaflow-stubs/runner/utils.pyi +4 -4
  244. metaflow-stubs/system/__init__.pyi +2 -2
  245. metaflow-stubs/system/system_logger.pyi +3 -3
  246. metaflow-stubs/system/system_monitor.pyi +2 -2
  247. metaflow-stubs/tagging_util.pyi +2 -2
  248. metaflow-stubs/tuple_util.pyi +2 -2
  249. metaflow-stubs/user_configs/__init__.pyi +2 -2
  250. metaflow-stubs/user_configs/config_options.pyi +3 -3
  251. metaflow-stubs/user_configs/config_parameters.pyi +7 -7
  252. metaflow-stubs/user_decorators/__init__.pyi +2 -2
  253. metaflow-stubs/user_decorators/common.pyi +2 -2
  254. metaflow-stubs/user_decorators/mutable_flow.pyi +5 -5
  255. metaflow-stubs/user_decorators/mutable_step.pyi +5 -5
  256. metaflow-stubs/user_decorators/user_flow_decorator.pyi +3 -3
  257. metaflow-stubs/user_decorators/user_step_decorator.pyi +5 -5
  258. {ob_metaflow_stubs-6.0.10.3.dist-info → ob_metaflow_stubs-6.0.10.5.dist-info}/METADATA +1 -1
  259. ob_metaflow_stubs-6.0.10.5.dist-info/RECORD +262 -0
  260. ob_metaflow_stubs-6.0.10.3.dist-info/RECORD +0 -262
  261. {ob_metaflow_stubs-6.0.10.3.dist-info → ob_metaflow_stubs-6.0.10.5.dist-info}/WHEEL +0 -0
  262. {ob_metaflow_stubs-6.0.10.3.dist-info → ob_metaflow_stubs-6.0.10.5.dist-info}/top_level.txt +0 -0
@@ -1,15 +1,15 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
- # MF version: 2.18.5.1+obcheckpoint(0.2.5);ob(v1) #
4
- # Generated on 2025-09-16T18:01:26.529291 #
3
+ # MF version: 2.18.7.1+obcheckpoint(0.2.6);ob(v1) #
4
+ # Generated on 2025-09-19T08:41:35.349888 #
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
 
@@ -39,10 +39,10 @@ from .user_decorators.user_step_decorator import UserStepDecorator as UserStepDe
39
39
  from .user_decorators.user_step_decorator import StepMutator as StepMutator
40
40
  from .user_decorators.user_step_decorator import user_step_decorator as user_step_decorator
41
41
  from .user_decorators.user_flow_decorator import FlowMutator as FlowMutator
42
+ from . import tuple_util as tuple_util
42
43
  from . import cards as cards
43
- from . import events as events
44
44
  from . import metaflow_git as metaflow_git
45
- from . import tuple_util as tuple_util
45
+ from . import events as events
46
46
  from . import runner as runner
47
47
  from . import plugins as plugins
48
48
  from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
@@ -168,57 +168,131 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
168
168
  ...
169
169
 
170
170
  @typing.overload
171
- 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]]]:
171
+ 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]]]:
172
172
  """
173
- Specifies the number of times the task corresponding
174
- to a step needs to be retried.
173
+ Enables loading / saving of models within a step.
175
174
 
176
- This decorator is useful for handling transient errors, such as networking issues.
177
- If your task contains operations that can't be retried safely, e.g. database updates,
178
- it is advisable to annotate it with `@retry(times=0)`.
175
+ > Examples
176
+ - Saving Models
177
+ ```python
178
+ @model
179
+ @step
180
+ def train(self):
181
+ # current.model.save returns a dictionary reference to the model saved
182
+ self.my_model = current.model.save(
183
+ path_to_my_model,
184
+ label="my_model",
185
+ metadata={
186
+ "epochs": 10,
187
+ "batch-size": 32,
188
+ "learning-rate": 0.001,
189
+ }
190
+ )
191
+ self.next(self.test)
179
192
 
180
- This can be used in conjunction with the `@catch` decorator. The `@catch`
181
- decorator will execute a no-op task after all retries have been exhausted,
182
- ensuring that the flow execution can continue.
193
+ @model(load="my_model")
194
+ @step
195
+ def test(self):
196
+ # `current.model.loaded` returns a dictionary of the loaded models
197
+ # where the key is the name of the artifact and the value is the path to the model
198
+ print(os.listdir(current.model.loaded["my_model"]))
199
+ self.next(self.end)
200
+ ```
201
+
202
+ - Loading models
203
+ ```python
204
+ @step
205
+ def train(self):
206
+ # current.model.load returns the path to the model loaded
207
+ checkpoint_path = current.model.load(
208
+ self.checkpoint_key,
209
+ )
210
+ model_path = current.model.load(
211
+ self.model,
212
+ )
213
+ self.next(self.test)
214
+ ```
183
215
 
184
216
 
185
217
  Parameters
186
218
  ----------
187
- times : int, default 3
188
- Number of times to retry this task.
189
- minutes_between_retries : int, default 2
190
- Number of minutes between retries.
219
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
220
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
221
+ 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`.
222
+ 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
223
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
224
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
225
+
226
+ temp_dir_root : str, default: None
227
+ The root directory under which `current.model.loaded` will store loaded models
191
228
  """
192
229
  ...
193
230
 
194
231
  @typing.overload
195
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
232
+ def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
196
233
  ...
197
234
 
198
235
  @typing.overload
199
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
236
+ def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
200
237
  ...
201
238
 
202
- 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):
239
+ 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):
203
240
  """
204
- Specifies the number of times the task corresponding
205
- to a step needs to be retried.
241
+ Enables loading / saving of models within a step.
206
242
 
207
- This decorator is useful for handling transient errors, such as networking issues.
208
- If your task contains operations that can't be retried safely, e.g. database updates,
209
- it is advisable to annotate it with `@retry(times=0)`.
243
+ > Examples
244
+ - Saving Models
245
+ ```python
246
+ @model
247
+ @step
248
+ def train(self):
249
+ # current.model.save returns a dictionary reference to the model saved
250
+ self.my_model = current.model.save(
251
+ path_to_my_model,
252
+ label="my_model",
253
+ metadata={
254
+ "epochs": 10,
255
+ "batch-size": 32,
256
+ "learning-rate": 0.001,
257
+ }
258
+ )
259
+ self.next(self.test)
210
260
 
211
- This can be used in conjunction with the `@catch` decorator. The `@catch`
212
- decorator will execute a no-op task after all retries have been exhausted,
213
- ensuring that the flow execution can continue.
261
+ @model(load="my_model")
262
+ @step
263
+ def test(self):
264
+ # `current.model.loaded` returns a dictionary of the loaded models
265
+ # where the key is the name of the artifact and the value is the path to the model
266
+ print(os.listdir(current.model.loaded["my_model"]))
267
+ self.next(self.end)
268
+ ```
269
+
270
+ - Loading models
271
+ ```python
272
+ @step
273
+ def train(self):
274
+ # current.model.load returns the path to the model loaded
275
+ checkpoint_path = current.model.load(
276
+ self.checkpoint_key,
277
+ )
278
+ model_path = current.model.load(
279
+ self.model,
280
+ )
281
+ self.next(self.test)
282
+ ```
214
283
 
215
284
 
216
285
  Parameters
217
286
  ----------
218
- times : int, default 3
219
- Number of times to retry this task.
220
- minutes_between_retries : int, default 2
221
- Number of minutes between retries.
287
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
288
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
289
+ 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`.
290
+ 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
291
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
292
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
293
+
294
+ temp_dir_root : str, default: None
295
+ The root directory under which `current.model.loaded` will store loaded models
222
296
  """
223
297
  ...
224
298
 
@@ -273,120 +347,356 @@ def vllm(*, model: str, backend: str, openai_api_server: bool, debug: bool, card
273
347
  ...
274
348
 
275
349
  @typing.overload
276
- def coreweave_s3_proxy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
350
+ def nebius_s3_proxy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
277
351
  """
278
- CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
352
+ Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
279
353
  It exists to make it easier for users to know that this decorator should only be used with
280
- a Neo Cloud like CoreWeave.
354
+ a Neo Cloud like Nebius.
281
355
  """
282
356
  ...
283
357
 
284
358
  @typing.overload
285
- def coreweave_s3_proxy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
359
+ def nebius_s3_proxy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
286
360
  ...
287
361
 
288
- def coreweave_s3_proxy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
362
+ def nebius_s3_proxy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
289
363
  """
290
- CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
364
+ Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
291
365
  It exists to make it easier for users to know that this decorator should only be used with
292
- a Neo Cloud like CoreWeave.
366
+ a Neo Cloud like Nebius.
293
367
  """
294
368
  ...
295
369
 
296
370
  @typing.overload
297
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
371
+ 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]]]:
298
372
  """
299
- Decorator prototype for all step decorators. This function gets specialized
300
- and imported for all decorators types by _import_plugin_decorators().
373
+ Specifies the PyPI packages for the step.
374
+
375
+ Information in this decorator will augment any
376
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
377
+ you can use `@pypi_base` to set packages required by all
378
+ steps and use `@pypi` to specify step-specific overrides.
379
+
380
+
381
+ Parameters
382
+ ----------
383
+ packages : Dict[str, str], default: {}
384
+ Packages to use for this step. The key is the name of the package
385
+ and the value is the version to use.
386
+ python : str, optional, default: None
387
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
388
+ that the version used will correspond to the version of the Python interpreter used to start the run.
301
389
  """
302
390
  ...
303
391
 
304
392
  @typing.overload
305
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
393
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
306
394
  ...
307
395
 
308
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
396
+ @typing.overload
397
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
398
+ ...
399
+
400
+ 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):
309
401
  """
310
- Decorator prototype for all step decorators. This function gets specialized
311
- and imported for all decorators types by _import_plugin_decorators().
402
+ Specifies the PyPI packages for the step.
403
+
404
+ Information in this decorator will augment any
405
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
406
+ you can use `@pypi_base` to set packages required by all
407
+ steps and use `@pypi` to specify step-specific overrides.
408
+
409
+
410
+ Parameters
411
+ ----------
412
+ packages : Dict[str, str], default: {}
413
+ Packages to use for this step. The key is the name of the package
414
+ and the value is the version to use.
415
+ python : str, optional, default: None
416
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
417
+ that the version used will correspond to the version of the Python interpreter used to start the run.
312
418
  """
313
419
  ...
314
420
 
315
421
  @typing.overload
316
- def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
422
+ def coreweave_s3_proxy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
317
423
  """
318
- A simple decorator that demonstrates using CardDecoratorInjector
319
- to inject a card and render simple markdown content.
424
+ CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
425
+ It exists to make it easier for users to know that this decorator should only be used with
426
+ a Neo Cloud like CoreWeave.
320
427
  """
321
428
  ...
322
429
 
323
430
  @typing.overload
324
- def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
431
+ def coreweave_s3_proxy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
325
432
  ...
326
433
 
327
- def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
434
+ def coreweave_s3_proxy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
328
435
  """
329
- A simple decorator that demonstrates using CardDecoratorInjector
330
- to inject a card and render simple markdown content.
436
+ CoreWeave-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
437
+ It exists to make it easier for users to know that this decorator should only be used with
438
+ a Neo Cloud like CoreWeave.
331
439
  """
332
440
  ...
333
441
 
334
442
  @typing.overload
335
- 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]]]:
443
+ 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]]]:
336
444
  """
337
- Specifies a timeout for your step.
338
-
339
- This decorator is useful if this step may hang indefinitely.
445
+ Specifies the resources needed when executing this step.
340
446
 
341
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
342
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
343
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
447
+ Use `@resources` to specify the resource requirements
448
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
344
449
 
345
- Note that all the values specified in parameters are added together so if you specify
346
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
450
+ You can choose the compute layer on the command line by executing e.g.
451
+ ```
452
+ python myflow.py run --with batch
453
+ ```
454
+ or
455
+ ```
456
+ python myflow.py run --with kubernetes
457
+ ```
458
+ which executes the flow on the desired system using the
459
+ requirements specified in `@resources`.
347
460
 
348
461
 
349
462
  Parameters
350
463
  ----------
351
- seconds : int, default 0
352
- Number of seconds to wait prior to timing out.
353
- minutes : int, default 0
354
- Number of minutes to wait prior to timing out.
355
- hours : int, default 0
356
- Number of hours to wait prior to timing out.
464
+ cpu : int, default 1
465
+ Number of CPUs required for this step.
466
+ gpu : int, optional, default None
467
+ Number of GPUs required for this step.
468
+ disk : int, optional, default None
469
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
470
+ memory : int, default 4096
471
+ Memory size (in MB) required for this step.
472
+ shared_memory : int, optional, default None
473
+ The value for the size (in MiB) of the /dev/shm volume for this step.
474
+ This parameter maps to the `--shm-size` option in Docker.
357
475
  """
358
476
  ...
359
477
 
360
478
  @typing.overload
361
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
479
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
362
480
  ...
363
481
 
364
482
  @typing.overload
365
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
483
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
366
484
  ...
367
485
 
368
- 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):
486
+ 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):
369
487
  """
370
- Specifies a timeout for your step.
488
+ Specifies the resources needed when executing this step.
371
489
 
372
- This decorator is useful if this step may hang indefinitely.
490
+ Use `@resources` to specify the resource requirements
491
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
373
492
 
374
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
375
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
376
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
493
+ You can choose the compute layer on the command line by executing e.g.
494
+ ```
495
+ python myflow.py run --with batch
496
+ ```
497
+ or
498
+ ```
499
+ python myflow.py run --with kubernetes
500
+ ```
501
+ which executes the flow on the desired system using the
502
+ requirements specified in `@resources`.
377
503
 
378
- Note that all the values specified in parameters are added together so if you specify
379
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
504
+
505
+ Parameters
506
+ ----------
507
+ cpu : int, default 1
508
+ Number of CPUs required for this step.
509
+ gpu : int, optional, default None
510
+ Number of GPUs required for this step.
511
+ disk : int, optional, default None
512
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
513
+ memory : int, default 4096
514
+ Memory size (in MB) required for this step.
515
+ shared_memory : int, optional, default None
516
+ The value for the size (in MiB) of the /dev/shm volume for this step.
517
+ This parameter maps to the `--shm-size` option in Docker.
518
+ """
519
+ ...
520
+
521
+ def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, cache_scope: 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]]]:
522
+ """
523
+ Decorator that helps cache, version, and store models/datasets from the Hugging Face Hub.
524
+
525
+ > Examples
526
+
527
+ **Usage: creating references to models from the Hugging Face Hub that may be loaded in downstream steps**
528
+ ```python
529
+ @huggingface_hub
530
+ @step
531
+ def pull_model_from_huggingface(self):
532
+ # `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
533
+ # and saves it in the backend storage based on the model's `repo_id`. If there exists a model
534
+ # with the same `repo_id` in the backend storage, it will not download the model again. The return
535
+ # value of the function is a reference to the model in the backend storage.
536
+ # This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
537
+
538
+ self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
539
+ self.llama_model = current.huggingface_hub.snapshot_download(
540
+ repo_id=self.model_id,
541
+ allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
542
+ )
543
+ self.next(self.train)
544
+ ```
545
+
546
+ **Usage: explicitly loading models at runtime from the Hugging Face Hub or from cache (from Metaflow's datastore)**
547
+ ```python
548
+ @huggingface_hub
549
+ @step
550
+ def run_training(self):
551
+ # Temporary directory (auto-cleaned on exit)
552
+ with current.huggingface_hub.load(
553
+ repo_id="google-bert/bert-base-uncased",
554
+ allow_patterns=["*.bin"],
555
+ ) as local_path:
556
+ # Use files under local_path
557
+ train_model(local_path)
558
+ ...
559
+
560
+ ```
561
+
562
+ **Usage: loading models directly from the Hugging Face Hub or from cache (from Metaflow's datastore)**
563
+ ```python
564
+ @huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
565
+ @step
566
+ def pull_model_from_huggingface(self):
567
+ path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
568
+ ```
569
+
570
+ ```python
571
+ @huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora", "/my-lora-directory")])
572
+ @step
573
+ def finetune_model(self):
574
+ path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
575
+ # path_to_model will be /my-directory
576
+ ```
577
+
578
+ ```python
579
+ # Takes all the arguments passed to `snapshot_download`
580
+ # except for `local_dir`
581
+ @huggingface_hub(load=[
582
+ {
583
+ "repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
584
+ },
585
+ {
586
+ "repo_id": "myorg/mistral-lora",
587
+ "repo_type": "model",
588
+ },
589
+ ])
590
+ @step
591
+ def finetune_model(self):
592
+ path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
593
+ # path_to_model will be /my-directory
594
+ ```
380
595
 
381
596
 
382
597
  Parameters
383
598
  ----------
384
- seconds : int, default 0
385
- Number of seconds to wait prior to timing out.
386
- minutes : int, default 0
387
- Number of minutes to wait prior to timing out.
388
- hours : int, default 0
389
- Number of hours to wait prior to timing out.
599
+ temp_dir_root : str, optional
600
+ The root directory that will hold the temporary directory where objects will be downloaded.
601
+
602
+ cache_scope : str, optional
603
+ The scope of the cache. Can be `checkpoint` / `flow` / `global`.
604
+
605
+ - `checkpoint` (default): All repos are stored like objects saved by `@checkpoint`.
606
+ i.e., the cached path is derived from the namespace, flow, step, and Metaflow foreach iteration.
607
+ Any repo downloaded under this scope will only be retrieved from the cache when the step runs under the same namespace in the same flow (at the same foreach index).
608
+
609
+ - `flow`: All repos are cached under the flow, regardless of namespace.
610
+ i.e., the cached path is derived solely from the flow name.
611
+ When to use this mode:
612
+ - Multiple users are executing the same flow and want shared access to the repos cached by the decorator.
613
+ - Multiple versions of a flow are deployed, all needing access to the same repos cached by the decorator.
614
+
615
+ - `global`: All repos are cached under a globally static path.
616
+ i.e., the base path of the cache is static and all repos are stored under it.
617
+ When to use this mode:
618
+ - All repos from the Hugging Face Hub need to be shared by users across all flow executions.
619
+
620
+ Each caching scope comes with its own trade-offs:
621
+ - `checkpoint`:
622
+ - Has explicit control over when caches are populated (controlled by the same flow that has the `@huggingface_hub` decorator) but ends up hitting the Hugging Face Hub more often if there are many users/namespaces/steps.
623
+ - Since objects are written on a `namespace/flow/step` basis, the blast radius of a bad checkpoint is limited to a particular flow in a namespace.
624
+ - `flow`:
625
+ - Has less control over when caches are populated (can be written by any execution instance of a flow from any namespace) but results in more cache hits.
626
+ - The blast radius of a bad checkpoint is limited to all runs of a particular flow.
627
+ - It doesn't promote cache reuse across flows.
628
+ - `global`:
629
+ - Has no control over when caches are populated (can be written by any flow execution) but has the highest cache hit rate.
630
+ - It promotes cache reuse across flows.
631
+ - The blast radius of a bad checkpoint spans every flow that could be using a particular repo.
632
+
633
+ load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
634
+ The list of repos (models/datasets) to load.
635
+
636
+ Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
637
+
638
+ - If repo (model/dataset) is not found in the datastore:
639
+ - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
640
+ - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
641
+ - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
642
+
643
+ - If repo is found in the datastore:
644
+ - Loads it directly from datastore to local path (can be temporary directory or specified path)
645
+ """
646
+ ...
647
+
648
+ @typing.overload
649
+ 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]]]:
650
+ """
651
+ Specifies the number of times the task corresponding
652
+ to a step needs to be retried.
653
+
654
+ This decorator is useful for handling transient errors, such as networking issues.
655
+ If your task contains operations that can't be retried safely, e.g. database updates,
656
+ it is advisable to annotate it with `@retry(times=0)`.
657
+
658
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
659
+ decorator will execute a no-op task after all retries have been exhausted,
660
+ ensuring that the flow execution can continue.
661
+
662
+
663
+ Parameters
664
+ ----------
665
+ times : int, default 3
666
+ Number of times to retry this task.
667
+ minutes_between_retries : int, default 2
668
+ Number of minutes between retries.
669
+ """
670
+ ...
671
+
672
+ @typing.overload
673
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
674
+ ...
675
+
676
+ @typing.overload
677
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
678
+ ...
679
+
680
+ 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):
681
+ """
682
+ Specifies the number of times the task corresponding
683
+ to a step needs to be retried.
684
+
685
+ This decorator is useful for handling transient errors, such as networking issues.
686
+ If your task contains operations that can't be retried safely, e.g. database updates,
687
+ it is advisable to annotate it with `@retry(times=0)`.
688
+
689
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
690
+ decorator will execute a no-op task after all retries have been exhausted,
691
+ ensuring that the flow execution can continue.
692
+
693
+
694
+ Parameters
695
+ ----------
696
+ times : int, default 3
697
+ Number of times to retry this task.
698
+ minutes_between_retries : int, default 2
699
+ Number of minutes between retries.
390
700
  """
391
701
  ...
392
702
 
@@ -480,593 +790,408 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
480
790
  ...
481
791
 
482
792
  @typing.overload
483
- def card(*, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
793
+ def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
484
794
  """
485
- Creates a human-readable report, a Metaflow Card, after this step completes.
486
-
487
- Note that you may add multiple `@card` decorators in a step with different parameters.
488
-
489
-
490
- Parameters
491
- ----------
492
- type : str, default 'default'
493
- Card type.
494
- id : str, optional, default None
495
- If multiple cards are present, use this id to identify this card.
496
- options : Dict[str, Any], default {}
497
- Options passed to the card. The contents depend on the card type.
498
- timeout : int, default 45
499
- Interrupt reporting if it takes more than this many seconds.
795
+ Decorator prototype for all step decorators. This function gets specialized
796
+ and imported for all decorators types by _import_plugin_decorators().
500
797
  """
501
798
  ...
502
799
 
503
800
  @typing.overload
504
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
801
+ def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
505
802
  ...
506
803
 
507
- @typing.overload
508
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
804
+ def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
805
+ """
806
+ Decorator prototype for all step decorators. This function gets specialized
807
+ and imported for all decorators types by _import_plugin_decorators().
808
+ """
509
809
  ...
510
810
 
511
- def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45):
811
+ def s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode: typing.Optional[str] = None, debug: typing.Optional[bool] = 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]]]:
512
812
  """
513
- Creates a human-readable report, a Metaflow Card, after this step completes.
514
-
515
- Note that you may add multiple `@card` decorators in a step with different parameters.
813
+ S3 Proxy decorator for routing S3 requests through a local proxy service.
516
814
 
517
815
 
518
816
  Parameters
519
817
  ----------
520
- type : str, default 'default'
521
- Card type.
522
- id : str, optional, default None
523
- If multiple cards are present, use this id to identify this card.
524
- options : Dict[str, Any], default {}
525
- Options passed to the card. The contents depend on the card type.
526
- timeout : int, default 45
527
- Interrupt reporting if it takes more than this many seconds.
528
- """
529
- ...
530
-
531
- @typing.overload
532
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
818
+ integration_name : str, optional
819
+ Name of the S3 proxy integration. If not specified, will use the only
820
+ available S3 proxy integration in the namespace (fails if multiple exist).
821
+ write_mode : str, optional
822
+ The desired behavior during write operations to target (origin) S3 bucket.
823
+ allowed options are:
824
+ "origin-and-cache" -> write to both the target S3 bucket and local object
825
+ storage
826
+ "origin" -> only write to the target S3 bucket
827
+ "cache" -> only write to the object storage service used for caching
828
+ debug : bool, optional
829
+ Enable debug logging for proxy operations.
533
830
  """
534
- Internal decorator to support Fast bakery
831
+ ...
832
+
833
+ @typing.overload
834
+ 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]]]:
835
+ """
836
+ Specifies secrets to be retrieved and injected as environment variables prior to
837
+ the execution of a step.
838
+
839
+
840
+ Parameters
841
+ ----------
842
+ sources : List[Union[str, Dict[str, Any]]], default: []
843
+ List of secret specs, defining how the secrets are to be retrieved
844
+ role : str, optional, default: None
845
+ Role to use for fetching secrets
535
846
  """
536
847
  ...
537
848
 
538
849
  @typing.overload
539
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
850
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
540
851
  ...
541
852
 
542
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
853
+ @typing.overload
854
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
855
+ ...
856
+
857
+ 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):
543
858
  """
544
- Internal decorator to support Fast bakery
859
+ Specifies secrets to be retrieved and injected as environment variables prior to
860
+ the execution of a step.
861
+
862
+
863
+ Parameters
864
+ ----------
865
+ sources : List[Union[str, Dict[str, Any]]], default: []
866
+ List of secret specs, defining how the secrets are to be retrieved
867
+ role : str, optional, default: None
868
+ Role to use for fetching secrets
545
869
  """
546
870
  ...
547
871
 
548
872
  @typing.overload
549
- 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]]]:
873
+ def environment(*, vars: typing.Dict[str, str] = {}) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
550
874
  """
551
- Specifies that the step will success under all circumstances.
552
-
553
- The decorator will create an optional artifact, specified by `var`, which
554
- contains the exception raised. You can use it to detect the presence
555
- of errors, indicating that all happy-path artifacts produced by the step
556
- are missing.
875
+ Specifies environment variables to be set prior to the execution of a step.
557
876
 
558
877
 
559
878
  Parameters
560
879
  ----------
561
- var : str, optional, default None
562
- Name of the artifact in which to store the caught exception.
563
- If not specified, the exception is not stored.
564
- print_exception : bool, default True
565
- Determines whether or not the exception is printed to
566
- stdout when caught.
880
+ vars : Dict[str, str], default {}
881
+ Dictionary of environment variables to set.
567
882
  """
568
883
  ...
569
884
 
570
885
  @typing.overload
571
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
886
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
572
887
  ...
573
888
 
574
889
  @typing.overload
575
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
890
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
576
891
  ...
577
892
 
578
- 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):
893
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
579
894
  """
580
- Specifies that the step will success under all circumstances.
581
-
582
- The decorator will create an optional artifact, specified by `var`, which
583
- contains the exception raised. You can use it to detect the presence
584
- of errors, indicating that all happy-path artifacts produced by the step
585
- are missing.
895
+ Specifies environment variables to be set prior to the execution of a step.
586
896
 
587
897
 
588
898
  Parameters
589
899
  ----------
590
- var : str, optional, default None
591
- Name of the artifact in which to store the caught exception.
592
- If not specified, the exception is not stored.
593
- print_exception : bool, default True
594
- Determines whether or not the exception is printed to
595
- stdout when caught.
900
+ vars : Dict[str, str], default {}
901
+ Dictionary of environment variables to set.
596
902
  """
597
903
  ...
598
904
 
599
905
  @typing.overload
600
- 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]]]:
906
+ 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]]]:
601
907
  """
602
- Specifies the PyPI packages for the step.
908
+ Specifies a timeout for your step.
603
909
 
604
- Information in this decorator will augment any
605
- attributes set in the `@pyi_base` flow-level decorator. Hence,
606
- you can use `@pypi_base` to set packages required by all
607
- steps and use `@pypi` to specify step-specific overrides.
910
+ This decorator is useful if this step may hang indefinitely.
911
+
912
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
913
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
914
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
915
+
916
+ Note that all the values specified in parameters are added together so if you specify
917
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
608
918
 
609
919
 
610
920
  Parameters
611
921
  ----------
612
- packages : Dict[str, str], default: {}
613
- Packages to use for this step. The key is the name of the package
614
- and the value is the version to use.
615
- python : str, optional, default: None
616
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
617
- that the version used will correspond to the version of the Python interpreter used to start the run.
922
+ seconds : int, default 0
923
+ Number of seconds to wait prior to timing out.
924
+ minutes : int, default 0
925
+ Number of minutes to wait prior to timing out.
926
+ hours : int, default 0
927
+ Number of hours to wait prior to timing out.
618
928
  """
619
929
  ...
620
930
 
621
931
  @typing.overload
622
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
932
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
623
933
  ...
624
934
 
625
935
  @typing.overload
626
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
936
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
627
937
  ...
628
938
 
629
- 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):
939
+ 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):
630
940
  """
631
- Specifies the PyPI packages for the step.
941
+ Specifies a timeout for your step.
632
942
 
633
- Information in this decorator will augment any
634
- attributes set in the `@pyi_base` flow-level decorator. Hence,
635
- you can use `@pypi_base` to set packages required by all
636
- steps and use `@pypi` to specify step-specific overrides.
943
+ This decorator is useful if this step may hang indefinitely.
944
+
945
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
946
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
947
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
948
+
949
+ Note that all the values specified in parameters are added together so if you specify
950
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
637
951
 
638
952
 
639
953
  Parameters
640
954
  ----------
641
- packages : Dict[str, str], default: {}
642
- Packages to use for this step. The key is the name of the package
643
- and the value is the version to use.
644
- python : str, optional, default: None
645
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
646
- that the version used will correspond to the version of the Python interpreter used to start the run.
955
+ seconds : int, default 0
956
+ Number of seconds to wait prior to timing out.
957
+ minutes : int, default 0
958
+ Number of minutes to wait prior to timing out.
959
+ hours : int, default 0
960
+ Number of hours to wait prior to timing out.
647
961
  """
648
962
  ...
649
963
 
650
- def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, cache_scope: 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]]]:
964
+ @typing.overload
965
+ 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]]]:
651
966
  """
652
- Decorator that helps cache, version, and store models/datasets from the Hugging Face Hub.
967
+ Enables checkpointing for a step.
653
968
 
654
969
  > Examples
655
970
 
656
- **Usage: creating references to models from the Hugging Face Hub that may be loaded in downstream steps**
657
- ```python
658
- @huggingface_hub
659
- @step
660
- def pull_model_from_huggingface(self):
661
- # `current.huggingface_hub.snapshot_download` downloads the model from the Hugging Face Hub
662
- # and saves it in the backend storage based on the model's `repo_id`. If there exists a model
663
- # with the same `repo_id` in the backend storage, it will not download the model again. The return
664
- # value of the function is a reference to the model in the backend storage.
665
- # This reference can be used to load the model in the subsequent steps via `@model(load=["llama_model"])`
666
-
667
- self.model_id = "mistralai/Mistral-7B-Instruct-v0.1"
668
- self.llama_model = current.huggingface_hub.snapshot_download(
669
- repo_id=self.model_id,
670
- allow_patterns=["*.safetensors", "*.json", "tokenizer.*"],
671
- )
672
- self.next(self.train)
673
- ```
971
+ - Saving Checkpoints
674
972
 
675
- **Usage: loading models directly from the Hugging Face Hub or from cache (from Metaflow's datastore)**
676
973
  ```python
677
- @huggingface_hub(load=["mistralai/Mistral-7B-Instruct-v0.1"])
678
- @step
679
- def pull_model_from_huggingface(self):
680
- path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
974
+ @checkpoint
975
+ @step
976
+ def train(self):
977
+ model = create_model(self.parameters, checkpoint_path = None)
978
+ for i in range(self.epochs):
979
+ # some training logic
980
+ loss = model.train(self.dataset)
981
+ if i % 10 == 0:
982
+ model.save(
983
+ current.checkpoint.directory,
984
+ )
985
+ # saves the contents of the `current.checkpoint.directory` as a checkpoint
986
+ # and returns a reference dictionary to the checkpoint saved in the datastore
987
+ self.latest_checkpoint = current.checkpoint.save(
988
+ name="epoch_checkpoint",
989
+ metadata={
990
+ "epoch": i,
991
+ "loss": loss,
992
+ }
993
+ )
681
994
  ```
682
995
 
683
- ```python
684
- @huggingface_hub(load=[("mistralai/Mistral-7B-Instruct-v0.1", "/my-directory"), ("myorg/mistral-lora", "/my-lora-directory")])
685
- @step
686
- def finetune_model(self):
687
- path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
688
- # path_to_model will be /my-directory
689
- ```
996
+ - Using Loaded Checkpoints
690
997
 
691
998
  ```python
692
- # Takes all the arguments passed to `snapshot_download`
693
- # except for `local_dir`
694
- @huggingface_hub(load=[
695
- {
696
- "repo_id": "mistralai/Mistral-7B-Instruct-v0.1",
697
- },
698
- {
699
- "repo_id": "myorg/mistral-lora",
700
- "repo_type": "model",
701
- },
702
- ])
703
- @step
704
- def finetune_model(self):
705
- path_to_model = current.huggingface_hub.loaded["mistralai/Mistral-7B-Instruct-v0.1"]
706
- # path_to_model will be /my-directory
999
+ @retry(times=3)
1000
+ @checkpoint
1001
+ @step
1002
+ def train(self):
1003
+ # Assume that the task has restarted and the previous attempt of the task
1004
+ # saved a checkpoint
1005
+ checkpoint_path = None
1006
+ if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1007
+ print("Loaded checkpoint from the previous attempt")
1008
+ checkpoint_path = current.checkpoint.directory
1009
+
1010
+ model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1011
+ for i in range(self.epochs):
1012
+ ...
707
1013
  ```
708
1014
 
709
1015
 
710
1016
  Parameters
711
1017
  ----------
712
- temp_dir_root : str, optional
713
- The root directory that will hold the temporary directory where objects will be downloaded.
714
-
715
- cache_scope : str, optional
716
- The scope of the cache. Can be `checkpoint` / `flow` / `global`.
717
-
718
- - `checkpoint` (default): All repos are stored like objects saved by `@checkpoint`.
719
- i.e., the cached path is derived from the namespace, flow, step, and Metaflow foreach iteration.
720
- Any repo downloaded under this scope will only be retrieved from the cache when the step runs under the same namespace in the same flow (at the same foreach index).
1018
+ load_policy : str, default: "fresh"
1019
+ The policy for loading the checkpoint. The following policies are supported:
1020
+ - "eager": Loads the the latest available checkpoint within the namespace.
1021
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1022
+ will be loaded at the start of the task.
1023
+ - "none": Do not load any checkpoint
1024
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1025
+ This mode helps loading checkpoints across various retry attempts of the same task.
1026
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1027
+ created within the task will be loaded when the task is retries execution on failure.
721
1028
 
722
- - `flow`: All repos are cached under the flow, regardless of namespace.
723
- i.e., the cached path is derived solely from the flow name.
724
- When to use this mode:
725
- - Multiple users are executing the same flow and want shared access to the repos cached by the decorator.
726
- - Multiple versions of a flow are deployed, all needing access to the same repos cached by the decorator.
727
-
728
- - `global`: All repos are cached under a globally static path.
729
- i.e., the base path of the cache is static and all repos are stored under it.
730
- When to use this mode:
731
- - All repos from the Hugging Face Hub need to be shared by users across all flow executions.
732
-
733
- Each caching scope comes with its own trade-offs:
734
- - `checkpoint`:
735
- - Has explicit control over when caches are populated (controlled by the same flow that has the `@huggingface_hub` decorator) but ends up hitting the Hugging Face Hub more often if there are many users/namespaces/steps.
736
- - Since objects are written on a `namespace/flow/step` basis, the blast radius of a bad checkpoint is limited to a particular flow in a namespace.
737
- - `flow`:
738
- - Has less control over when caches are populated (can be written by any execution instance of a flow from any namespace) but results in more cache hits.
739
- - The blast radius of a bad checkpoint is limited to all runs of a particular flow.
740
- - It doesn't promote cache reuse across flows.
741
- - `global`:
742
- - Has no control over when caches are populated (can be written by any flow execution) but has the highest cache hit rate.
743
- - It promotes cache reuse across flows.
744
- - The blast radius of a bad checkpoint spans every flow that could be using a particular repo.
745
-
746
- load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
747
- The list of repos (models/datasets) to load.
748
-
749
- Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
750
-
751
- - If repo (model/dataset) is not found in the datastore:
752
- - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
753
- - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
754
- - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
755
-
756
- - If repo is found in the datastore:
757
- - Loads it directly from datastore to local path (can be temporary directory or specified path)
758
- """
759
- ...
760
-
761
- 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]]]:
762
- """
763
- Specifies that this step should execute on DGX cloud.
764
-
765
-
766
- Parameters
767
- ----------
768
- gpu : int
769
- Number of GPUs to use.
770
- gpu_type : str
771
- Type of Nvidia GPU to use.
772
- queue_timeout : int
773
- Time to keep the job in NVCF's queue.
774
- """
775
- ...
776
-
777
- @typing.overload
778
- def environment(*, vars: typing.Dict[str, str] = {}) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
779
- """
780
- Specifies environment variables to be set prior to the execution of a step.
781
-
782
-
783
- Parameters
784
- ----------
785
- vars : Dict[str, str], default {}
786
- Dictionary of environment variables to set.
1029
+ temp_dir_root : str, default: None
1030
+ The root directory under which `current.checkpoint.directory` will be created.
787
1031
  """
788
1032
  ...
789
1033
 
790
1034
  @typing.overload
791
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1035
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
792
1036
  ...
793
1037
 
794
1038
  @typing.overload
795
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1039
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
796
1040
  ...
797
1041
 
798
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
1042
+ 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):
799
1043
  """
800
- Specifies environment variables to be set prior to the execution of a step.
1044
+ Enables checkpointing for a step.
801
1045
 
1046
+ > Examples
802
1047
 
803
- Parameters
804
- ----------
805
- vars : Dict[str, str], default {}
806
- Dictionary of environment variables to set.
807
- """
808
- ...
809
-
810
- @typing.overload
811
- 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]]]:
812
- """
813
- Enables loading / saving of models within a step.
1048
+ - Saving Checkpoints
814
1049
 
815
- > Examples
816
- - Saving Models
817
1050
  ```python
818
- @model
1051
+ @checkpoint
819
1052
  @step
820
1053
  def train(self):
821
- # current.model.save returns a dictionary reference to the model saved
822
- self.my_model = current.model.save(
823
- path_to_my_model,
824
- label="my_model",
825
- metadata={
826
- "epochs": 10,
827
- "batch-size": 32,
828
- "learning-rate": 0.001,
829
- }
830
- )
831
- self.next(self.test)
832
-
833
- @model(load="my_model")
834
- @step
835
- def test(self):
836
- # `current.model.loaded` returns a dictionary of the loaded models
837
- # where the key is the name of the artifact and the value is the path to the model
838
- print(os.listdir(current.model.loaded["my_model"]))
839
- self.next(self.end)
1054
+ model = create_model(self.parameters, checkpoint_path = None)
1055
+ for i in range(self.epochs):
1056
+ # some training logic
1057
+ loss = model.train(self.dataset)
1058
+ if i % 10 == 0:
1059
+ model.save(
1060
+ current.checkpoint.directory,
1061
+ )
1062
+ # saves the contents of the `current.checkpoint.directory` as a checkpoint
1063
+ # and returns a reference dictionary to the checkpoint saved in the datastore
1064
+ self.latest_checkpoint = current.checkpoint.save(
1065
+ name="epoch_checkpoint",
1066
+ metadata={
1067
+ "epoch": i,
1068
+ "loss": loss,
1069
+ }
1070
+ )
840
1071
  ```
841
1072
 
842
- - Loading models
1073
+ - Using Loaded Checkpoints
1074
+
843
1075
  ```python
1076
+ @retry(times=3)
1077
+ @checkpoint
844
1078
  @step
845
1079
  def train(self):
846
- # current.model.load returns the path to the model loaded
847
- checkpoint_path = current.model.load(
848
- self.checkpoint_key,
849
- )
850
- model_path = current.model.load(
851
- self.model,
852
- )
853
- self.next(self.test)
1080
+ # Assume that the task has restarted and the previous attempt of the task
1081
+ # saved a checkpoint
1082
+ checkpoint_path = None
1083
+ if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1084
+ print("Loaded checkpoint from the previous attempt")
1085
+ checkpoint_path = current.checkpoint.directory
1086
+
1087
+ model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1088
+ for i in range(self.epochs):
1089
+ ...
854
1090
  ```
855
1091
 
856
1092
 
857
1093
  Parameters
858
1094
  ----------
859
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
860
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
861
- 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`.
862
- 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
863
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
864
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
1095
+ load_policy : str, default: "fresh"
1096
+ The policy for loading the checkpoint. The following policies are supported:
1097
+ - "eager": Loads the the latest available checkpoint within the namespace.
1098
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1099
+ will be loaded at the start of the task.
1100
+ - "none": Do not load any checkpoint
1101
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1102
+ This mode helps loading checkpoints across various retry attempts of the same task.
1103
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1104
+ created within the task will be loaded when the task is retries execution on failure.
865
1105
 
866
1106
  temp_dir_root : str, default: None
867
- The root directory under which `current.model.loaded` will store loaded models
1107
+ The root directory under which `current.checkpoint.directory` will be created.
868
1108
  """
869
1109
  ...
870
1110
 
871
1111
  @typing.overload
872
- def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
873
- ...
874
-
875
- @typing.overload
876
- def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
877
- ...
878
-
879
- 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):
1112
+ 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]]]:
880
1113
  """
881
- Enables loading / saving of models within a step.
882
-
883
- > Examples
884
- - Saving Models
885
- ```python
886
- @model
887
- @step
888
- def train(self):
889
- # current.model.save returns a dictionary reference to the model saved
890
- self.my_model = current.model.save(
891
- path_to_my_model,
892
- label="my_model",
893
- metadata={
894
- "epochs": 10,
895
- "batch-size": 32,
896
- "learning-rate": 0.001,
897
- }
898
- )
899
- self.next(self.test)
900
-
901
- @model(load="my_model")
902
- @step
903
- def test(self):
904
- # `current.model.loaded` returns a dictionary of the loaded models
905
- # where the key is the name of the artifact and the value is the path to the model
906
- print(os.listdir(current.model.loaded["my_model"]))
907
- self.next(self.end)
908
- ```
1114
+ Specifies that the step will success under all circumstances.
909
1115
 
910
- - Loading models
911
- ```python
912
- @step
913
- def train(self):
914
- # current.model.load returns the path to the model loaded
915
- checkpoint_path = current.model.load(
916
- self.checkpoint_key,
917
- )
918
- model_path = current.model.load(
919
- self.model,
920
- )
921
- self.next(self.test)
922
- ```
1116
+ The decorator will create an optional artifact, specified by `var`, which
1117
+ contains the exception raised. You can use it to detect the presence
1118
+ of errors, indicating that all happy-path artifacts produced by the step
1119
+ are missing.
923
1120
 
924
1121
 
925
1122
  Parameters
926
1123
  ----------
927
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
928
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
929
- 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`.
930
- 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
931
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
932
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
933
-
934
- temp_dir_root : str, default: None
935
- The root directory under which `current.model.loaded` will store loaded models
1124
+ var : str, optional, default None
1125
+ Name of the artifact in which to store the caught exception.
1126
+ If not specified, the exception is not stored.
1127
+ print_exception : bool, default True
1128
+ Determines whether or not the exception is printed to
1129
+ stdout when caught.
936
1130
  """
937
1131
  ...
938
1132
 
939
- def s3_proxy(*, integration_name: typing.Optional[str] = None, write_mode: typing.Optional[str] = None, debug: typing.Optional[bool] = 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]]]:
1133
+ @typing.overload
1134
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1135
+ ...
1136
+
1137
+ @typing.overload
1138
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1139
+ ...
1140
+
1141
+ 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):
940
1142
  """
941
- S3 Proxy decorator for routing S3 requests through a local proxy service.
1143
+ Specifies that the step will success under all circumstances.
1144
+
1145
+ The decorator will create an optional artifact, specified by `var`, which
1146
+ contains the exception raised. You can use it to detect the presence
1147
+ of errors, indicating that all happy-path artifacts produced by the step
1148
+ are missing.
942
1149
 
943
1150
 
944
1151
  Parameters
945
1152
  ----------
946
- integration_name : str, optional
947
- Name of the S3 proxy integration. If not specified, will use the only
948
- available S3 proxy integration in the namespace (fails if multiple exist).
949
- write_mode : str, optional
950
- The desired behavior during write operations to target (origin) S3 bucket.
951
- allowed options are:
952
- "origin-and-cache" -> write to both the target S3 bucket and local object
953
- storage
954
- "origin" -> only write to the target S3 bucket
955
- "cache" -> only write to the object storage service used for caching
956
- debug : bool, optional
957
- Enable debug logging for proxy operations.
1153
+ var : str, optional, default None
1154
+ Name of the artifact in which to store the caught exception.
1155
+ If not specified, the exception is not stored.
1156
+ print_exception : bool, default True
1157
+ Determines whether or not the exception is printed to
1158
+ stdout when caught.
958
1159
  """
959
1160
  ...
960
1161
 
961
1162
  @typing.overload
962
- def app_deploy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1163
+ def test_append_card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
963
1164
  """
964
- Decorator prototype for all step decorators. This function gets specialized
965
- and imported for all decorators types by _import_plugin_decorators().
1165
+ A simple decorator that demonstrates using CardDecoratorInjector
1166
+ to inject a card and render simple markdown content.
966
1167
  """
967
1168
  ...
968
1169
 
969
1170
  @typing.overload
970
- def app_deploy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1171
+ def test_append_card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
971
1172
  ...
972
1173
 
973
- def app_deploy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
1174
+ def test_append_card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
974
1175
  """
975
- Decorator prototype for all step decorators. This function gets specialized
976
- and imported for all decorators types by _import_plugin_decorators().
1176
+ A simple decorator that demonstrates using CardDecoratorInjector
1177
+ to inject a card and render simple markdown content.
977
1178
  """
978
1179
  ...
979
1180
 
980
1181
  @typing.overload
981
- 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]]]:
1182
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
982
1183
  """
983
- Specifies the resources needed when executing this step.
984
-
985
- Use `@resources` to specify the resource requirements
986
- independently of the specific compute layer (`@batch`, `@kubernetes`).
987
-
988
- You can choose the compute layer on the command line by executing e.g.
989
- ```
990
- python myflow.py run --with batch
991
- ```
992
- or
993
- ```
994
- python myflow.py run --with kubernetes
995
- ```
996
- which executes the flow on the desired system using the
997
- requirements specified in `@resources`.
998
-
999
-
1000
- Parameters
1001
- ----------
1002
- cpu : int, default 1
1003
- Number of CPUs required for this step.
1004
- gpu : int, optional, default None
1005
- Number of GPUs required for this step.
1006
- disk : int, optional, default None
1007
- Disk size (in MB) required for this step. Only applies on Kubernetes.
1008
- memory : int, default 4096
1009
- Memory size (in MB) required for this step.
1010
- shared_memory : int, optional, default None
1011
- The value for the size (in MiB) of the /dev/shm volume for this step.
1012
- This parameter maps to the `--shm-size` option in Docker.
1184
+ Internal decorator to support Fast bakery
1013
1185
  """
1014
1186
  ...
1015
1187
 
1016
1188
  @typing.overload
1017
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1018
- ...
1019
-
1020
- @typing.overload
1021
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1022
- ...
1023
-
1024
- 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):
1025
- """
1026
- Specifies the resources needed when executing this step.
1027
-
1028
- Use `@resources` to specify the resource requirements
1029
- independently of the specific compute layer (`@batch`, `@kubernetes`).
1030
-
1031
- You can choose the compute layer on the command line by executing e.g.
1032
- ```
1033
- python myflow.py run --with batch
1034
- ```
1035
- or
1036
- ```
1037
- python myflow.py run --with kubernetes
1038
- ```
1039
- which executes the flow on the desired system using the
1040
- requirements specified in `@resources`.
1041
-
1042
-
1043
- Parameters
1044
- ----------
1045
- cpu : int, default 1
1046
- Number of CPUs required for this step.
1047
- gpu : int, optional, default None
1048
- Number of GPUs required for this step.
1049
- disk : int, optional, default None
1050
- Disk size (in MB) required for this step. Only applies on Kubernetes.
1051
- memory : int, default 4096
1052
- Memory size (in MB) required for this step.
1053
- shared_memory : int, optional, default None
1054
- The value for the size (in MiB) of the /dev/shm volume for this step.
1055
- This parameter maps to the `--shm-size` option in Docker.
1056
- """
1189
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1057
1190
  ...
1058
1191
 
1059
- 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]]]:
1192
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
1060
1193
  """
1061
- Specifies that this step should execute on DGX cloud.
1062
-
1063
-
1064
- Parameters
1065
- ----------
1066
- gpu : int
1067
- Number of GPUs to use.
1068
- gpu_type : str
1069
- Type of Nvidia GPU to use.
1194
+ Internal decorator to support Fast bakery
1070
1195
  """
1071
1196
  ...
1072
1197
 
@@ -1111,189 +1236,100 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
1111
1236
  Information in this decorator will augment any
1112
1237
  attributes set in the `@conda_base` flow-level decorator. Hence,
1113
1238
  you can use `@conda_base` to set packages required by all
1114
- steps and use `@conda` to specify step-specific overrides.
1115
-
1116
-
1117
- Parameters
1118
- ----------
1119
- packages : Dict[str, str], default {}
1120
- Packages to use for this step. The key is the name of the package
1121
- and the value is the version to use.
1122
- libraries : Dict[str, str], default {}
1123
- Supported for backward compatibility. When used with packages, packages will take precedence.
1124
- python : str, optional, default None
1125
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1126
- that the version used will correspond to the version of the Python interpreter used to start the run.
1127
- disabled : bool, default False
1128
- If set to True, disables @conda.
1129
- """
1130
- ...
1131
-
1132
- @typing.overload
1133
- def nebius_s3_proxy(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1134
- """
1135
- Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
1136
- It exists to make it easier for users to know that this decorator should only be used with
1137
- a Neo Cloud like Nebius.
1138
- """
1139
- ...
1140
-
1141
- @typing.overload
1142
- def nebius_s3_proxy(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1143
- ...
1144
-
1145
- def nebius_s3_proxy(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
1146
- """
1147
- Nebius-specific S3 Proxy decorator for routing S3 requests through a local proxy service.
1148
- It exists to make it easier for users to know that this decorator should only be used with
1149
- a Neo Cloud like Nebius.
1150
- """
1151
- ...
1152
-
1153
- @typing.overload
1154
- 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]]]:
1155
- """
1156
- Enables checkpointing for a step.
1157
-
1158
- > Examples
1159
-
1160
- - Saving Checkpoints
1161
-
1162
- ```python
1163
- @checkpoint
1164
- @step
1165
- def train(self):
1166
- model = create_model(self.parameters, checkpoint_path = None)
1167
- for i in range(self.epochs):
1168
- # some training logic
1169
- loss = model.train(self.dataset)
1170
- if i % 10 == 0:
1171
- model.save(
1172
- current.checkpoint.directory,
1173
- )
1174
- # saves the contents of the `current.checkpoint.directory` as a checkpoint
1175
- # and returns a reference dictionary to the checkpoint saved in the datastore
1176
- self.latest_checkpoint = current.checkpoint.save(
1177
- name="epoch_checkpoint",
1178
- metadata={
1179
- "epoch": i,
1180
- "loss": loss,
1181
- }
1182
- )
1183
- ```
1184
-
1185
- - Using Loaded Checkpoints
1186
-
1187
- ```python
1188
- @retry(times=3)
1189
- @checkpoint
1190
- @step
1191
- def train(self):
1192
- # Assume that the task has restarted and the previous attempt of the task
1193
- # saved a checkpoint
1194
- checkpoint_path = None
1195
- if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1196
- print("Loaded checkpoint from the previous attempt")
1197
- checkpoint_path = current.checkpoint.directory
1198
-
1199
- model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1200
- for i in range(self.epochs):
1201
- ...
1202
- ```
1239
+ steps and use `@conda` to specify step-specific overrides.
1203
1240
 
1204
1241
 
1205
1242
  Parameters
1206
1243
  ----------
1207
- load_policy : str, default: "fresh"
1208
- The policy for loading the checkpoint. The following policies are supported:
1209
- - "eager": Loads the the latest available checkpoint within the namespace.
1210
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1211
- will be loaded at the start of the task.
1212
- - "none": Do not load any checkpoint
1213
- - "fresh": Loads the lastest checkpoint created within the running Task.
1214
- This mode helps loading checkpoints across various retry attempts of the same task.
1215
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1216
- created within the task will be loaded when the task is retries execution on failure.
1244
+ packages : Dict[str, str], default {}
1245
+ Packages to use for this step. The key is the name of the package
1246
+ and the value is the version to use.
1247
+ libraries : Dict[str, str], default {}
1248
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1249
+ python : str, optional, default None
1250
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1251
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1252
+ disabled : bool, default False
1253
+ If set to True, disables @conda.
1254
+ """
1255
+ ...
1256
+
1257
+ @typing.overload
1258
+ def card(*, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
1259
+ """
1260
+ Creates a human-readable report, a Metaflow Card, after this step completes.
1217
1261
 
1218
- temp_dir_root : str, default: None
1219
- The root directory under which `current.checkpoint.directory` will be created.
1262
+ Note that you may add multiple `@card` decorators in a step with different parameters.
1263
+
1264
+
1265
+ Parameters
1266
+ ----------
1267
+ type : str, default 'default'
1268
+ Card type.
1269
+ id : str, optional, default None
1270
+ If multiple cards are present, use this id to identify this card.
1271
+ options : Dict[str, Any], default {}
1272
+ Options passed to the card. The contents depend on the card type.
1273
+ timeout : int, default 45
1274
+ Interrupt reporting if it takes more than this many seconds.
1220
1275
  """
1221
1276
  ...
1222
1277
 
1223
1278
  @typing.overload
1224
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1279
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1225
1280
  ...
1226
1281
 
1227
1282
  @typing.overload
1228
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1283
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1229
1284
  ...
1230
1285
 
1231
- 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
+ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, type: str = 'default', id: typing.Optional[str] = None, options: typing.Dict[str, typing.Any] = {}, timeout: int = 45):
1232
1287
  """
1233
- Enables checkpointing for a step.
1234
-
1235
- > Examples
1288
+ Creates a human-readable report, a Metaflow Card, after this step completes.
1236
1289
 
1237
- - Saving Checkpoints
1290
+ Note that you may add multiple `@card` decorators in a step with different parameters.
1238
1291
 
1239
- ```python
1240
- @checkpoint
1241
- @step
1242
- def train(self):
1243
- model = create_model(self.parameters, checkpoint_path = None)
1244
- for i in range(self.epochs):
1245
- # some training logic
1246
- loss = model.train(self.dataset)
1247
- if i % 10 == 0:
1248
- model.save(
1249
- current.checkpoint.directory,
1250
- )
1251
- # saves the contents of the `current.checkpoint.directory` as a checkpoint
1252
- # and returns a reference dictionary to the checkpoint saved in the datastore
1253
- self.latest_checkpoint = current.checkpoint.save(
1254
- name="epoch_checkpoint",
1255
- metadata={
1256
- "epoch": i,
1257
- "loss": loss,
1258
- }
1259
- )
1260
- ```
1261
1292
 
1262
- - Using Loaded Checkpoints
1293
+ Parameters
1294
+ ----------
1295
+ type : str, default 'default'
1296
+ Card type.
1297
+ id : str, optional, default None
1298
+ If multiple cards are present, use this id to identify this card.
1299
+ options : Dict[str, Any], default {}
1300
+ Options passed to the card. The contents depend on the card type.
1301
+ timeout : int, default 45
1302
+ Interrupt reporting if it takes more than this many seconds.
1303
+ """
1304
+ ...
1305
+
1306
+ 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]]]:
1307
+ """
1308
+ Specifies that this step should execute on DGX cloud.
1263
1309
 
1264
- ```python
1265
- @retry(times=3)
1266
- @checkpoint
1267
- @step
1268
- def train(self):
1269
- # Assume that the task has restarted and the previous attempt of the task
1270
- # saved a checkpoint
1271
- checkpoint_path = None
1272
- if current.checkpoint.is_loaded: # Check if a checkpoint is loaded
1273
- print("Loaded checkpoint from the previous attempt")
1274
- checkpoint_path = current.checkpoint.directory
1275
1310
 
1276
- model = create_model(self.parameters, checkpoint_path = checkpoint_path)
1277
- for i in range(self.epochs):
1278
- ...
1279
- ```
1311
+ Parameters
1312
+ ----------
1313
+ gpu : int
1314
+ Number of GPUs to use.
1315
+ gpu_type : str
1316
+ Type of Nvidia GPU to use.
1317
+ """
1318
+ ...
1319
+
1320
+ 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]]]:
1321
+ """
1322
+ Specifies that this step should execute on DGX cloud.
1280
1323
 
1281
1324
 
1282
1325
  Parameters
1283
1326
  ----------
1284
- load_policy : str, default: "fresh"
1285
- The policy for loading the checkpoint. The following policies are supported:
1286
- - "eager": Loads the the latest available checkpoint within the namespace.
1287
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1288
- will be loaded at the start of the task.
1289
- - "none": Do not load any checkpoint
1290
- - "fresh": Loads the lastest checkpoint created within the running Task.
1291
- This mode helps loading checkpoints across various retry attempts of the same task.
1292
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1293
- created within the task will be loaded when the task is retries execution on failure.
1294
-
1295
- temp_dir_root : str, default: None
1296
- The root directory under which `current.checkpoint.directory` will be created.
1327
+ gpu : int
1328
+ Number of GPUs to use.
1329
+ gpu_type : str
1330
+ Type of Nvidia GPU to use.
1331
+ queue_timeout : int
1332
+ Time to keep the job in NVCF's queue.
1297
1333
  """
1298
1334
  ...
1299
1335
 
@@ -1340,77 +1376,207 @@ def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy:
1340
1376
  """
1341
1377
  ...
1342
1378
 
1343
- @typing.overload
1344
- 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]]]:
1379
+ @typing.overload
1380
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1381
+ """
1382
+ Decorator prototype for all step decorators. This function gets specialized
1383
+ and imported for all decorators types by _import_plugin_decorators().
1384
+ """
1385
+ ...
1386
+
1387
+ @typing.overload
1388
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1389
+ ...
1390
+
1391
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
1392
+ """
1393
+ Decorator prototype for all step decorators. This function gets specialized
1394
+ and imported for all decorators types by _import_plugin_decorators().
1395
+ """
1396
+ ...
1397
+
1398
+ @typing.overload
1399
+ 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]]:
1400
+ """
1401
+ Specifies the flow(s) that this flow depends on.
1402
+
1403
+ ```
1404
+ @trigger_on_finish(flow='FooFlow')
1405
+ ```
1406
+ or
1407
+ ```
1408
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1409
+ ```
1410
+ This decorator respects the @project decorator and triggers the flow
1411
+ when upstream runs within the same namespace complete successfully
1412
+
1413
+ Additionally, you can specify project aware upstream flow dependencies
1414
+ by specifying the fully qualified project_flow_name.
1415
+ ```
1416
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1417
+ ```
1418
+ or
1419
+ ```
1420
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1421
+ ```
1422
+
1423
+ You can also specify just the project or project branch (other values will be
1424
+ inferred from the current project or project branch):
1425
+ ```
1426
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1427
+ ```
1428
+
1429
+ Note that `branch` is typically one of:
1430
+ - `prod`
1431
+ - `user.bob`
1432
+ - `test.my_experiment`
1433
+ - `prod.staging`
1434
+
1435
+
1436
+ Parameters
1437
+ ----------
1438
+ flow : Union[str, Dict[str, str]], optional, default None
1439
+ Upstream flow dependency for this flow.
1440
+ flows : List[Union[str, Dict[str, str]]], default []
1441
+ Upstream flow dependencies for this flow.
1442
+ options : Dict[str, Any], default {}
1443
+ Backend-specific configuration for tuning eventing behavior.
1444
+ """
1445
+ ...
1446
+
1447
+ @typing.overload
1448
+ def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1449
+ ...
1450
+
1451
+ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1452
+ """
1453
+ Specifies the flow(s) that this flow depends on.
1454
+
1455
+ ```
1456
+ @trigger_on_finish(flow='FooFlow')
1457
+ ```
1458
+ or
1459
+ ```
1460
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1461
+ ```
1462
+ This decorator respects the @project decorator and triggers the flow
1463
+ when upstream runs within the same namespace complete successfully
1464
+
1465
+ Additionally, you can specify project aware upstream flow dependencies
1466
+ by specifying the fully qualified project_flow_name.
1467
+ ```
1468
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1469
+ ```
1470
+ or
1471
+ ```
1472
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1473
+ ```
1474
+
1475
+ You can also specify just the project or project branch (other values will be
1476
+ inferred from the current project or project branch):
1477
+ ```
1478
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1479
+ ```
1480
+
1481
+ Note that `branch` is typically one of:
1482
+ - `prod`
1483
+ - `user.bob`
1484
+ - `test.my_experiment`
1485
+ - `prod.staging`
1486
+
1487
+
1488
+ Parameters
1489
+ ----------
1490
+ flow : Union[str, Dict[str, str]], optional, default None
1491
+ Upstream flow dependency for this flow.
1492
+ flows : List[Union[str, Dict[str, str]]], default []
1493
+ Upstream flow dependencies for this flow.
1494
+ options : Dict[str, Any], default {}
1495
+ Backend-specific configuration for tuning eventing behavior.
1496
+ """
1497
+ ...
1498
+
1499
+ 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]]:
1345
1500
  """
1346
- Specifies secrets to be retrieved and injected as environment variables prior to
1347
- the execution of a step.
1501
+ 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.
1502
+ 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.
1348
1503
 
1349
1504
 
1350
1505
  Parameters
1351
1506
  ----------
1352
- sources : List[Union[str, Dict[str, Any]]], default: []
1353
- List of secret specs, defining how the secrets are to be retrieved
1354
- role : str, optional, default: None
1355
- Role to use for fetching secrets
1507
+ timeout : int
1508
+ Time, in seconds before the task times out and fails. (Default: 3600)
1509
+ poke_interval : int
1510
+ Time in seconds that the job should wait in between each try. (Default: 60)
1511
+ mode : str
1512
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1513
+ exponential_backoff : bool
1514
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1515
+ pool : str
1516
+ the slot pool this task should run in,
1517
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1518
+ soft_fail : bool
1519
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1520
+ name : str
1521
+ Name of the sensor on Airflow
1522
+ description : str
1523
+ Description of sensor in the Airflow UI
1524
+ external_dag_id : str
1525
+ The dag_id that contains the task you want to wait for.
1526
+ external_task_ids : List[str]
1527
+ The list of task_ids that you want to wait for.
1528
+ If None (default value) the sensor waits for the DAG. (Default: None)
1529
+ allowed_states : List[str]
1530
+ Iterable of allowed states, (Default: ['success'])
1531
+ failed_states : List[str]
1532
+ Iterable of failed or dis-allowed states. (Default: None)
1533
+ execution_delta : datetime.timedelta
1534
+ time difference with the previous execution to look at,
1535
+ the default is the same logical date as the current task or DAG. (Default: None)
1536
+ check_existence: bool
1537
+ Set to True to check if the external task exists or check if
1538
+ the DAG to wait for exists. (Default: True)
1356
1539
  """
1357
1540
  ...
1358
1541
 
1359
1542
  @typing.overload
1360
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1361
- ...
1362
-
1363
- @typing.overload
1364
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1365
- ...
1366
-
1367
- 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):
1543
+ def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1368
1544
  """
1369
- Specifies secrets to be retrieved and injected as environment variables prior to
1370
- the execution of a step.
1545
+ Specifies the PyPI packages for all steps of the flow.
1371
1546
 
1547
+ Use `@pypi_base` to set common packages required by all
1548
+ steps and use `@pypi` to specify step-specific overrides.
1372
1549
 
1373
1550
  Parameters
1374
1551
  ----------
1375
- sources : List[Union[str, Dict[str, Any]]], default: []
1376
- List of secret specs, defining how the secrets are to be retrieved
1377
- role : str, optional, default: None
1378
- Role to use for fetching secrets
1552
+ packages : Dict[str, str], default: {}
1553
+ Packages to use for this flow. The key is the name of the package
1554
+ and the value is the version to use.
1555
+ python : str, optional, default: None
1556
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1557
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1379
1558
  """
1380
1559
  ...
1381
1560
 
1382
- def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1561
+ @typing.overload
1562
+ def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1563
+ ...
1564
+
1565
+ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1383
1566
  """
1384
- Specifies what flows belong to the same project.
1385
-
1386
- A project-specific namespace is created for all flows that
1387
- use the same `@project(name)`.
1567
+ Specifies the PyPI packages for all steps of the flow.
1388
1568
 
1569
+ Use `@pypi_base` to set common packages required by all
1570
+ steps and use `@pypi` to specify step-specific overrides.
1389
1571
 
1390
1572
  Parameters
1391
1573
  ----------
1392
- name : str
1393
- Project name. Make sure that the name is unique amongst all
1394
- projects that use the same production scheduler. The name may
1395
- contain only lowercase alphanumeric characters and underscores.
1396
-
1397
- branch : Optional[str], default None
1398
- The branch to use. If not specified, the branch is set to
1399
- `user.<username>` unless `production` is set to `True`. This can
1400
- also be set on the command line using `--branch` as a top-level option.
1401
- It is an error to specify `branch` in the decorator and on the command line.
1402
-
1403
- production : bool, default False
1404
- Whether or not the branch is the production branch. This can also be set on the
1405
- command line using `--production` as a top-level option. It is an error to specify
1406
- `production` in the decorator and on the command line.
1407
- The project branch name will be:
1408
- - if `branch` is specified:
1409
- - if `production` is True: `prod.<branch>`
1410
- - if `production` is False: `test.<branch>`
1411
- - if `branch` is not specified:
1412
- - if `production` is True: `prod`
1413
- - if `production` is False: `user.<username>`
1574
+ packages : Dict[str, str], default: {}
1575
+ Packages to use for this flow. The key is the name of the package
1576
+ and the value is the version to use.
1577
+ python : str, optional, default: None
1578
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1579
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1414
1580
  """
1415
1581
  ...
1416
1582
 
@@ -1454,150 +1620,14 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
1454
1620
  Run the workflow hourly.
1455
1621
  daily : bool, default True
1456
1622
  Run the workflow daily.
1457
- weekly : bool, default False
1458
- Run the workflow weekly.
1459
- cron : str, optional, default None
1460
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1461
- specified by this expression.
1462
- timezone : str, optional, default None
1463
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1464
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1465
- """
1466
- ...
1467
-
1468
- 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]]:
1469
- """
1470
- 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)
1471
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1472
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1473
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1474
- starts only after all sensors finish.
1475
-
1476
-
1477
- Parameters
1478
- ----------
1479
- timeout : int
1480
- Time, in seconds before the task times out and fails. (Default: 3600)
1481
- poke_interval : int
1482
- Time in seconds that the job should wait in between each try. (Default: 60)
1483
- mode : str
1484
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1485
- exponential_backoff : bool
1486
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1487
- pool : str
1488
- the slot pool this task should run in,
1489
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1490
- soft_fail : bool
1491
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1492
- name : str
1493
- Name of the sensor on Airflow
1494
- description : str
1495
- Description of sensor in the Airflow UI
1496
- bucket_key : Union[str, List[str]]
1497
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1498
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1499
- bucket_name : str
1500
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1501
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1502
- wildcard_match : bool
1503
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1504
- aws_conn_id : str
1505
- a reference to the s3 connection on Airflow. (Default: None)
1506
- verify : bool
1507
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1508
- """
1509
- ...
1510
-
1511
- @typing.overload
1512
- 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]]:
1513
- """
1514
- Specifies the event(s) that this flow depends on.
1515
-
1516
- ```
1517
- @trigger(event='foo')
1518
- ```
1519
- or
1520
- ```
1521
- @trigger(events=['foo', 'bar'])
1522
- ```
1523
-
1524
- Additionally, you can specify the parameter mappings
1525
- to map event payload to Metaflow parameters for the flow.
1526
- ```
1527
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1528
- ```
1529
- or
1530
- ```
1531
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1532
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1533
- ```
1534
-
1535
- 'parameters' can also be a list of strings and tuples like so:
1536
- ```
1537
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1538
- ```
1539
- This is equivalent to:
1540
- ```
1541
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1542
- ```
1543
-
1544
-
1545
- Parameters
1546
- ----------
1547
- event : Union[str, Dict[str, Any]], optional, default None
1548
- Event dependency for this flow.
1549
- events : List[Union[str, Dict[str, Any]]], default []
1550
- Events dependency for this flow.
1551
- options : Dict[str, Any], default {}
1552
- Backend-specific configuration for tuning eventing behavior.
1553
- """
1554
- ...
1555
-
1556
- @typing.overload
1557
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1558
- ...
1559
-
1560
- 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] = {}):
1561
- """
1562
- Specifies the event(s) that this flow depends on.
1563
-
1564
- ```
1565
- @trigger(event='foo')
1566
- ```
1567
- or
1568
- ```
1569
- @trigger(events=['foo', 'bar'])
1570
- ```
1571
-
1572
- Additionally, you can specify the parameter mappings
1573
- to map event payload to Metaflow parameters for the flow.
1574
- ```
1575
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1576
- ```
1577
- or
1578
- ```
1579
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1580
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1581
- ```
1582
-
1583
- 'parameters' can also be a list of strings and tuples like so:
1584
- ```
1585
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1586
- ```
1587
- This is equivalent to:
1588
- ```
1589
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1590
- ```
1591
-
1592
-
1593
- Parameters
1594
- ----------
1595
- event : Union[str, Dict[str, Any]], optional, default None
1596
- Event dependency for this flow.
1597
- events : List[Union[str, Dict[str, Any]]], default []
1598
- Events dependency for this flow.
1599
- options : Dict[str, Any], default {}
1600
- Backend-specific configuration for tuning eventing behavior.
1623
+ weekly : bool, default False
1624
+ Run the workflow weekly.
1625
+ cron : str, optional, default None
1626
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1627
+ specified by this expression.
1628
+ timezone : str, optional, default None
1629
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1630
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1601
1631
  """
1602
1632
  ...
1603
1633
 
@@ -1766,190 +1796,176 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
1766
1796
  """
1767
1797
  ...
1768
1798
 
1799
+ 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]]:
1800
+ """
1801
+ 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)
1802
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1803
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1804
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1805
+ starts only after all sensors finish.
1806
+
1807
+
1808
+ Parameters
1809
+ ----------
1810
+ timeout : int
1811
+ Time, in seconds before the task times out and fails. (Default: 3600)
1812
+ poke_interval : int
1813
+ Time in seconds that the job should wait in between each try. (Default: 60)
1814
+ mode : str
1815
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1816
+ exponential_backoff : bool
1817
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1818
+ pool : str
1819
+ the slot pool this task should run in,
1820
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1821
+ soft_fail : bool
1822
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1823
+ name : str
1824
+ Name of the sensor on Airflow
1825
+ description : str
1826
+ Description of sensor in the Airflow UI
1827
+ bucket_key : Union[str, List[str]]
1828
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1829
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1830
+ bucket_name : str
1831
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1832
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1833
+ wildcard_match : bool
1834
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1835
+ aws_conn_id : str
1836
+ a reference to the s3 connection on Airflow. (Default: None)
1837
+ verify : bool
1838
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1839
+ """
1840
+ ...
1841
+
1842
+ def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1843
+ """
1844
+ Specifies what flows belong to the same project.
1845
+
1846
+ A project-specific namespace is created for all flows that
1847
+ use the same `@project(name)`.
1848
+
1849
+
1850
+ Parameters
1851
+ ----------
1852
+ name : str
1853
+ Project name. Make sure that the name is unique amongst all
1854
+ projects that use the same production scheduler. The name may
1855
+ contain only lowercase alphanumeric characters and underscores.
1856
+
1857
+ branch : Optional[str], default None
1858
+ The branch to use. If not specified, the branch is set to
1859
+ `user.<username>` unless `production` is set to `True`. This can
1860
+ also be set on the command line using `--branch` as a top-level option.
1861
+ It is an error to specify `branch` in the decorator and on the command line.
1862
+
1863
+ production : bool, default False
1864
+ Whether or not the branch is the production branch. This can also be set on the
1865
+ command line using `--production` as a top-level option. It is an error to specify
1866
+ `production` in the decorator and on the command line.
1867
+ The project branch name will be:
1868
+ - if `branch` is specified:
1869
+ - if `production` is True: `prod.<branch>`
1870
+ - if `production` is False: `test.<branch>`
1871
+ - if `branch` is not specified:
1872
+ - if `production` is True: `prod`
1873
+ - if `production` is False: `user.<username>`
1874
+ """
1875
+ ...
1876
+
1769
1877
  @typing.overload
1770
- 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]]:
1878
+ 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]]:
1771
1879
  """
1772
- Specifies the flow(s) that this flow depends on.
1880
+ Specifies the event(s) that this flow depends on.
1773
1881
 
1774
1882
  ```
1775
- @trigger_on_finish(flow='FooFlow')
1883
+ @trigger(event='foo')
1776
1884
  ```
1777
1885
  or
1778
1886
  ```
1779
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1887
+ @trigger(events=['foo', 'bar'])
1780
1888
  ```
1781
- This decorator respects the @project decorator and triggers the flow
1782
- when upstream runs within the same namespace complete successfully
1783
1889
 
1784
- Additionally, you can specify project aware upstream flow dependencies
1785
- by specifying the fully qualified project_flow_name.
1890
+ Additionally, you can specify the parameter mappings
1891
+ to map event payload to Metaflow parameters for the flow.
1786
1892
  ```
1787
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1893
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1788
1894
  ```
1789
1895
  or
1790
1896
  ```
1791
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1897
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1898
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1792
1899
  ```
1793
1900
 
1794
- You can also specify just the project or project branch (other values will be
1795
- inferred from the current project or project branch):
1901
+ 'parameters' can also be a list of strings and tuples like so:
1796
1902
  ```
1797
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1903
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1904
+ ```
1905
+ This is equivalent to:
1906
+ ```
1907
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1798
1908
  ```
1799
-
1800
- Note that `branch` is typically one of:
1801
- - `prod`
1802
- - `user.bob`
1803
- - `test.my_experiment`
1804
- - `prod.staging`
1805
1909
 
1806
1910
 
1807
1911
  Parameters
1808
1912
  ----------
1809
- flow : Union[str, Dict[str, str]], optional, default None
1810
- Upstream flow dependency for this flow.
1811
- flows : List[Union[str, Dict[str, str]]], default []
1812
- Upstream flow dependencies for this flow.
1913
+ event : Union[str, Dict[str, Any]], optional, default None
1914
+ Event dependency for this flow.
1915
+ events : List[Union[str, Dict[str, Any]]], default []
1916
+ Events dependency for this flow.
1813
1917
  options : Dict[str, Any], default {}
1814
1918
  Backend-specific configuration for tuning eventing behavior.
1815
1919
  """
1816
1920
  ...
1817
1921
 
1818
1922
  @typing.overload
1819
- def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1923
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1820
1924
  ...
1821
1925
 
1822
- def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1926
+ 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] = {}):
1823
1927
  """
1824
- Specifies the flow(s) that this flow depends on.
1928
+ Specifies the event(s) that this flow depends on.
1825
1929
 
1826
1930
  ```
1827
- @trigger_on_finish(flow='FooFlow')
1931
+ @trigger(event='foo')
1828
1932
  ```
1829
1933
  or
1830
1934
  ```
1831
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1935
+ @trigger(events=['foo', 'bar'])
1832
1936
  ```
1833
- This decorator respects the @project decorator and triggers the flow
1834
- when upstream runs within the same namespace complete successfully
1835
1937
 
1836
- Additionally, you can specify project aware upstream flow dependencies
1837
- by specifying the fully qualified project_flow_name.
1938
+ Additionally, you can specify the parameter mappings
1939
+ to map event payload to Metaflow parameters for the flow.
1838
1940
  ```
1839
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1941
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1840
1942
  ```
1841
1943
  or
1842
1944
  ```
1843
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1945
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1946
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1844
1947
  ```
1845
1948
 
1846
- You can also specify just the project or project branch (other values will be
1847
- inferred from the current project or project branch):
1949
+ 'parameters' can also be a list of strings and tuples like so:
1848
1950
  ```
1849
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1951
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1952
+ ```
1953
+ This is equivalent to:
1954
+ ```
1955
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1850
1956
  ```
1851
-
1852
- Note that `branch` is typically one of:
1853
- - `prod`
1854
- - `user.bob`
1855
- - `test.my_experiment`
1856
- - `prod.staging`
1857
1957
 
1858
1958
 
1859
1959
  Parameters
1860
1960
  ----------
1861
- flow : Union[str, Dict[str, str]], optional, default None
1862
- Upstream flow dependency for this flow.
1863
- flows : List[Union[str, Dict[str, str]]], default []
1864
- Upstream flow dependencies for this flow.
1961
+ event : Union[str, Dict[str, Any]], optional, default None
1962
+ Event dependency for this flow.
1963
+ events : List[Union[str, Dict[str, Any]]], default []
1964
+ Events dependency for this flow.
1865
1965
  options : Dict[str, Any], default {}
1866
1966
  Backend-specific configuration for tuning eventing behavior.
1867
1967
  """
1868
1968
  ...
1869
1969
 
1870
- @typing.overload
1871
- def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1872
- """
1873
- Specifies the PyPI packages for all steps of the flow.
1874
-
1875
- Use `@pypi_base` to set common packages required by all
1876
- steps and use `@pypi` to specify step-specific overrides.
1877
-
1878
- Parameters
1879
- ----------
1880
- packages : Dict[str, str], default: {}
1881
- Packages to use for this flow. The key is the name of the package
1882
- and the value is the version to use.
1883
- python : str, optional, default: None
1884
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1885
- that the version used will correspond to the version of the Python interpreter used to start the run.
1886
- """
1887
- ...
1888
-
1889
- @typing.overload
1890
- def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1891
- ...
1892
-
1893
- def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1894
- """
1895
- Specifies the PyPI packages for all steps of the flow.
1896
-
1897
- Use `@pypi_base` to set common packages required by all
1898
- steps and use `@pypi` to specify step-specific overrides.
1899
-
1900
- Parameters
1901
- ----------
1902
- packages : Dict[str, str], default: {}
1903
- Packages to use for this flow. The key is the name of the package
1904
- and the value is the version to use.
1905
- python : str, optional, default: None
1906
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1907
- that the version used will correspond to the version of the Python interpreter used to start the run.
1908
- """
1909
- ...
1910
-
1911
- 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]]:
1912
- """
1913
- 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.
1914
- 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.
1915
-
1916
-
1917
- Parameters
1918
- ----------
1919
- timeout : int
1920
- Time, in seconds before the task times out and fails. (Default: 3600)
1921
- poke_interval : int
1922
- Time in seconds that the job should wait in between each try. (Default: 60)
1923
- mode : str
1924
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1925
- exponential_backoff : bool
1926
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1927
- pool : str
1928
- the slot pool this task should run in,
1929
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1930
- soft_fail : bool
1931
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1932
- name : str
1933
- Name of the sensor on Airflow
1934
- description : str
1935
- Description of sensor in the Airflow UI
1936
- external_dag_id : str
1937
- The dag_id that contains the task you want to wait for.
1938
- external_task_ids : List[str]
1939
- The list of task_ids that you want to wait for.
1940
- If None (default value) the sensor waits for the DAG. (Default: None)
1941
- allowed_states : List[str]
1942
- Iterable of allowed states, (Default: ['success'])
1943
- failed_states : List[str]
1944
- Iterable of failed or dis-allowed states. (Default: None)
1945
- execution_delta : datetime.timedelta
1946
- time difference with the previous execution to look at,
1947
- the default is the same logical date as the current task or DAG. (Default: None)
1948
- check_existence: bool
1949
- Set to True to check if the external task exists or check if
1950
- the DAG to wait for exists. (Default: True)
1951
- """
1952
- ...
1953
-
1954
1970
  pkg_name: str
1955
1971