ob-metaflow-stubs 6.0.3.175rc0__py2.py3-none-any.whl → 6.0.3.176rc1__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 (218) hide show
  1. metaflow-stubs/__init__.pyi +622 -616
  2. metaflow-stubs/cards.pyi +1 -1
  3. metaflow-stubs/cli.pyi +1 -1
  4. metaflow-stubs/cli_components/__init__.pyi +1 -1
  5. metaflow-stubs/cli_components/utils.pyi +1 -1
  6. metaflow-stubs/client/__init__.pyi +1 -1
  7. metaflow-stubs/client/core.pyi +5 -5
  8. metaflow-stubs/client/filecache.pyi +2 -2
  9. metaflow-stubs/events.pyi +2 -2
  10. metaflow-stubs/exception.pyi +1 -1
  11. metaflow-stubs/flowspec.pyi +3 -3
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +3 -3
  14. metaflow-stubs/info_file.pyi +1 -1
  15. metaflow-stubs/metadata_provider/__init__.pyi +1 -1
  16. metaflow-stubs/metadata_provider/heartbeat.pyi +1 -1
  17. metaflow-stubs/metadata_provider/metadata.pyi +1 -1
  18. metaflow-stubs/metadata_provider/util.pyi +1 -1
  19. metaflow-stubs/metaflow_config.pyi +1 -1
  20. metaflow-stubs/metaflow_current.pyi +71 -71
  21. metaflow-stubs/metaflow_git.pyi +1 -1
  22. metaflow-stubs/mf_extensions/__init__.pyi +1 -1
  23. metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
  24. metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
  25. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
  26. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
  27. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
  28. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
  29. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +2 -2
  30. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +1 -1
  31. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
  32. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +3 -3
  33. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
  34. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +3 -3
  35. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
  36. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +4 -4
  38. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +1 -1
  39. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +2 -2
  40. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +1 -1
  41. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +1 -1
  42. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +2 -2
  43. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +1 -1
  44. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +1 -1
  45. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +1 -1
  46. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +1 -1
  47. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
  48. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +2 -2
  49. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
  50. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
  51. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +1 -1
  52. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +1 -1
  53. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +2 -2
  54. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +1 -1
  55. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +2 -2
  56. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +1 -1
  57. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +1 -1
  58. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +1 -1
  59. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +1 -1
  60. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
  61. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
  62. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +1 -1
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +1 -1
  64. metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +1 -1
  65. metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
  66. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
  67. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/async_cards.pyi +60 -0
  68. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
  69. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
  70. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
  71. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
  72. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/__init__.pyi +1 -1
  73. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/baker.pyi +2 -2
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/docker_environment.pyi +1 -1
  75. metaflow-stubs/mf_extensions/outerbounds/plugins/fast_bakery/fast_bakery.pyi +1 -1
  76. metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/__init__.pyi +1 -1
  77. metaflow-stubs/mf_extensions/outerbounds/plugins/kubernetes/pod_killer.pyi +1 -1
  78. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
  79. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/constants.pyi +1 -1
  80. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/exceptions.pyi +1 -1
  81. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +60 -2
  82. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/status_card.pyi +73 -0
  83. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
  84. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
  85. metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
  86. metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
  87. metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
  88. metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
  89. metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
  90. metaflow-stubs/multicore_utils.pyi +1 -1
  91. metaflow-stubs/ob_internal.pyi +1 -1
  92. metaflow-stubs/parameters.pyi +3 -3
  93. metaflow-stubs/plugins/__init__.pyi +10 -10
  94. metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
  95. metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
  96. metaflow-stubs/plugins/airflow/exception.pyi +1 -1
  97. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
  98. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
  99. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
  100. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
  101. metaflow-stubs/plugins/argo/__init__.pyi +1 -1
  102. metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
  103. metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
  104. metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
  105. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +1 -1
  106. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +2 -2
  107. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +3 -3
  108. metaflow-stubs/plugins/aws/__init__.pyi +1 -1
  109. metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
  110. metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
  111. metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
  112. metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
  113. metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
  114. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
  115. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
  116. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -3
  117. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
  118. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
  119. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
  120. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
  121. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
  122. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +3 -3
  123. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
  124. metaflow-stubs/plugins/azure/__init__.pyi +1 -1
  125. metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
  126. metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
  127. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +3 -3
  128. metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
  129. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
  130. metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
  131. metaflow-stubs/plugins/cards/__init__.pyi +1 -1
  132. metaflow-stubs/plugins/cards/card_client.pyi +2 -2
  133. metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
  134. metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
  135. metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
  136. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
  137. metaflow-stubs/plugins/cards/card_modules/basic.pyi +1 -1
  138. metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
  139. metaflow-stubs/plugins/cards/card_modules/components.pyi +2 -2
  140. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
  141. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
  142. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
  143. metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
  144. metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
  145. metaflow-stubs/plugins/cards/exception.pyi +1 -1
  146. metaflow-stubs/plugins/catch_decorator.pyi +1 -1
  147. metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
  148. metaflow-stubs/plugins/datatools/local.pyi +1 -1
  149. metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
  150. metaflow-stubs/plugins/datatools/s3/s3.pyi +3 -3
  151. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
  152. metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
  153. metaflow-stubs/plugins/debug_logger.pyi +1 -1
  154. metaflow-stubs/plugins/debug_monitor.pyi +1 -1
  155. metaflow-stubs/plugins/environment_decorator.pyi +1 -1
  156. metaflow-stubs/plugins/events_decorator.pyi +1 -1
  157. metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
  158. metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
  159. metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
  160. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +3 -3
  161. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
  162. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
  163. metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
  164. metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
  165. metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
  166. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +1 -1
  167. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
  168. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
  169. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
  170. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
  171. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
  172. metaflow-stubs/plugins/ollama/__init__.pyi +13 -4
  173. metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
  174. metaflow-stubs/plugins/perimeters.pyi +1 -1
  175. metaflow-stubs/plugins/project_decorator.pyi +1 -1
  176. metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
  177. metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
  178. metaflow-stubs/plugins/pypi/conda_environment.pyi +2 -2
  179. metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
  180. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
  181. metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
  182. metaflow-stubs/plugins/pypi/utils.pyi +1 -1
  183. metaflow-stubs/plugins/resources_decorator.pyi +1 -1
  184. metaflow-stubs/plugins/retry_decorator.pyi +1 -1
  185. metaflow-stubs/plugins/secrets/__init__.pyi +1 -1
  186. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +3 -3
  187. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
  188. metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
  189. metaflow-stubs/plugins/storage_executor.pyi +1 -1
  190. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
  191. metaflow-stubs/plugins/timeout_decorator.pyi +1 -1
  192. metaflow-stubs/plugins/torchtune/__init__.pyi +1 -1
  193. metaflow-stubs/plugins/uv/__init__.pyi +1 -1
  194. metaflow-stubs/plugins/uv/uv_environment.pyi +1 -1
  195. metaflow-stubs/profilers/__init__.pyi +1 -1
  196. metaflow-stubs/pylint_wrapper.pyi +1 -1
  197. metaflow-stubs/runner/__init__.pyi +1 -1
  198. metaflow-stubs/runner/deployer.pyi +4 -4
  199. metaflow-stubs/runner/deployer_impl.pyi +2 -2
  200. metaflow-stubs/runner/metaflow_runner.pyi +4 -4
  201. metaflow-stubs/runner/nbdeploy.pyi +1 -1
  202. metaflow-stubs/runner/nbrun.pyi +1 -1
  203. metaflow-stubs/runner/subprocess_manager.pyi +1 -1
  204. metaflow-stubs/runner/utils.pyi +2 -2
  205. metaflow-stubs/system/__init__.pyi +1 -1
  206. metaflow-stubs/system/system_logger.pyi +2 -2
  207. metaflow-stubs/system/system_monitor.pyi +1 -1
  208. metaflow-stubs/tagging_util.pyi +1 -1
  209. metaflow-stubs/tuple_util.pyi +1 -1
  210. metaflow-stubs/user_configs/__init__.pyi +1 -1
  211. metaflow-stubs/user_configs/config_decorators.pyi +5 -5
  212. metaflow-stubs/user_configs/config_options.pyi +1 -1
  213. metaflow-stubs/user_configs/config_parameters.pyi +5 -5
  214. {ob_metaflow_stubs-6.0.3.175rc0.dist-info → ob_metaflow_stubs-6.0.3.176rc1.dist-info}/METADATA +1 -1
  215. ob_metaflow_stubs-6.0.3.176rc1.dist-info/RECORD +218 -0
  216. ob_metaflow_stubs-6.0.3.175rc0.dist-info/RECORD +0 -216
  217. {ob_metaflow_stubs-6.0.3.175rc0.dist-info → ob_metaflow_stubs-6.0.3.176rc1.dist-info}/WHEEL +0 -0
  218. {ob_metaflow_stubs-6.0.3.175rc0.dist-info → ob_metaflow_stubs-6.0.3.176rc1.dist-info}/top_level.txt +0 -0
@@ -1,15 +1,15 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
3
  # MF version: 2.15.14.1+obcheckpoint(0.2.1);ob(v1) #
4
- # Generated on 2025-05-30T00:54:07.424022 #
4
+ # Generated on 2025-06-03T02:57:26.607647 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
9
  import typing
10
10
  if typing.TYPE_CHECKING:
11
- import datetime
12
11
  import typing
12
+ import datetime
13
13
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
14
14
  StepFlag = typing.NewType("StepFlag", bool)
15
15
 
@@ -36,17 +36,17 @@ from .user_configs.config_parameters import config_expr as config_expr
36
36
  from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
37
37
  from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
38
38
  from . import cards as cards
39
- from . import metaflow_git as metaflow_git
40
39
  from . import tuple_util as tuple_util
41
40
  from . import events as events
41
+ from . import metaflow_git as metaflow_git
42
42
  from . import runner as runner
43
43
  from . import plugins as plugins
44
44
  from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
45
45
  from . import includefile as includefile
46
46
  from .includefile import IncludeFile as IncludeFile
47
+ from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
47
48
  from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
48
49
  from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
49
- from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
50
50
  from . import client as client
51
51
  from .client.core import namespace as namespace
52
52
  from .client.core import get_namespace as get_namespace
@@ -154,142 +154,131 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
154
154
  """
155
155
  ...
156
156
 
157
+ 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]]]:
158
+ """
159
+ Specifies that this step should execute on DGX cloud.
160
+
161
+
162
+ Parameters
163
+ ----------
164
+ gpu : int
165
+ Number of GPUs to use.
166
+ gpu_type : str
167
+ Type of Nvidia GPU to use.
168
+ queue_timeout : int
169
+ Time to keep the job in NVCF's queue.
170
+ """
171
+ ...
172
+
157
173
  @typing.overload
158
- 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]]]:
174
+ 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]]]:
159
175
  """
160
- Specifies the PyPI packages for the step.
176
+ Enables checkpointing for a step.
161
177
 
162
- Information in this decorator will augment any
163
- attributes set in the `@pyi_base` flow-level decorator. Hence,
164
- you can use `@pypi_base` to set packages required by all
165
- steps and use `@pypi` to specify step-specific overrides.
166
178
 
167
179
 
168
180
  Parameters
169
181
  ----------
170
- packages : Dict[str, str], default: {}
171
- Packages to use for this step. The key is the name of the package
172
- and the value is the version to use.
173
- python : str, optional, default: None
174
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
175
- that the version used will correspond to the version of the Python interpreter used to start the run.
182
+ load_policy : str, default: "fresh"
183
+ The policy for loading the checkpoint. The following policies are supported:
184
+ - "eager": Loads the the latest available checkpoint within the namespace.
185
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
186
+ will be loaded at the start of the task.
187
+ - "none": Do not load any checkpoint
188
+ - "fresh": Loads the lastest checkpoint created within the running Task.
189
+ This mode helps loading checkpoints across various retry attempts of the same task.
190
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
191
+ created within the task will be loaded when the task is retries execution on failure.
192
+
193
+ temp_dir_root : str, default: None
194
+ The root directory under which `current.checkpoint.directory` will be created.
176
195
  """
177
196
  ...
178
197
 
179
198
  @typing.overload
180
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
199
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
181
200
  ...
182
201
 
183
202
  @typing.overload
184
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
203
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
185
204
  ...
186
205
 
187
- 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):
206
+ 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):
188
207
  """
189
- Specifies the PyPI packages for the step.
208
+ Enables checkpointing for a step.
190
209
 
191
- Information in this decorator will augment any
192
- attributes set in the `@pyi_base` flow-level decorator. Hence,
193
- you can use `@pypi_base` to set packages required by all
194
- steps and use `@pypi` to specify step-specific overrides.
195
210
 
196
211
 
197
212
  Parameters
198
213
  ----------
199
- packages : Dict[str, str], default: {}
200
- Packages to use for this step. The key is the name of the package
201
- and the value is the version to use.
202
- python : str, optional, default: None
203
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
204
- that the version used will correspond to the version of the Python interpreter used to start the run.
214
+ load_policy : str, default: "fresh"
215
+ The policy for loading the checkpoint. The following policies are supported:
216
+ - "eager": Loads the the latest available checkpoint within the namespace.
217
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
218
+ will be loaded at the start of the task.
219
+ - "none": Do not load any checkpoint
220
+ - "fresh": Loads the lastest checkpoint created within the running Task.
221
+ This mode helps loading checkpoints across various retry attempts of the same task.
222
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
223
+ created within the task will be loaded when the task is retries execution on failure.
224
+
225
+ temp_dir_root : str, default: None
226
+ The root directory under which `current.checkpoint.directory` will be created.
205
227
  """
206
228
  ...
207
229
 
208
230
  @typing.overload
209
- 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]]]:
231
+ 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]]]:
210
232
  """
211
- Specifies that the step will success under all circumstances.
233
+ Specifies the number of times the task corresponding
234
+ to a step needs to be retried.
212
235
 
213
- The decorator will create an optional artifact, specified by `var`, which
214
- contains the exception raised. You can use it to detect the presence
215
- of errors, indicating that all happy-path artifacts produced by the step
216
- are missing.
236
+ This decorator is useful for handling transient errors, such as networking issues.
237
+ If your task contains operations that can't be retried safely, e.g. database updates,
238
+ it is advisable to annotate it with `@retry(times=0)`.
239
+
240
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
241
+ decorator will execute a no-op task after all retries have been exhausted,
242
+ ensuring that the flow execution can continue.
217
243
 
218
244
 
219
245
  Parameters
220
246
  ----------
221
- var : str, optional, default None
222
- Name of the artifact in which to store the caught exception.
223
- If not specified, the exception is not stored.
224
- print_exception : bool, default True
225
- Determines whether or not the exception is printed to
226
- stdout when caught.
247
+ times : int, default 3
248
+ Number of times to retry this task.
249
+ minutes_between_retries : int, default 2
250
+ Number of minutes between retries.
227
251
  """
228
252
  ...
229
253
 
230
254
  @typing.overload
231
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
255
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
232
256
  ...
233
257
 
234
258
  @typing.overload
235
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
236
- ...
237
-
238
- 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):
239
- """
240
- Specifies that the step will success under all circumstances.
241
-
242
- The decorator will create an optional artifact, specified by `var`, which
243
- contains the exception raised. You can use it to detect the presence
244
- of errors, indicating that all happy-path artifacts produced by the step
245
- are missing.
246
-
247
-
248
- Parameters
249
- ----------
250
- var : str, optional, default None
251
- Name of the artifact in which to store the caught exception.
252
- If not specified, the exception is not stored.
253
- print_exception : bool, default True
254
- Determines whether or not the exception is printed to
255
- stdout when caught.
256
- """
259
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
257
260
  ...
258
261
 
259
- def ollama(*, models: list, backend: str, force_pull: bool, skip_push_check: bool, debug: bool) -> 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]]]:
262
+ 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):
260
263
  """
261
- This decorator is used to run Ollama APIs as Metaflow task sidecars.
262
-
263
- User code call
264
- --------------
265
- @ollama(
266
- models=[...],
267
- ...
268
- )
264
+ Specifies the number of times the task corresponding
265
+ to a step needs to be retried.
269
266
 
270
- Valid backend options
271
- ---------------------
272
- - 'local': Run as a separate process on the local task machine.
273
- - (TODO) 'managed': Outerbounds hosts and selects compute provider.
274
- - (TODO) 'remote': Spin up separate instance to serve Ollama models.
267
+ This decorator is useful for handling transient errors, such as networking issues.
268
+ If your task contains operations that can't be retried safely, e.g. database updates,
269
+ it is advisable to annotate it with `@retry(times=0)`.
275
270
 
276
- Valid model options
277
- -------------------
278
- Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
271
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
272
+ decorator will execute a no-op task after all retries have been exhausted,
273
+ ensuring that the flow execution can continue.
279
274
 
280
275
 
281
276
  Parameters
282
277
  ----------
283
- models: list[str]
284
- List of Ollama containers running models in sidecars.
285
- backend: str
286
- Determines where and how to run the Ollama process.
287
- force_pull: bool
288
- Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
289
- skip_push_check: bool
290
- Whether to skip the check that populates/overwrites remote cache on terminating an ollama model.
291
- debug: bool
292
- Whether to turn on verbose debugging logs.
278
+ times : int, default 3
279
+ Number of times to retry this task.
280
+ minutes_between_retries : int, default 2
281
+ Number of minutes between retries.
293
282
  """
294
283
  ...
295
284
 
@@ -379,203 +368,180 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
379
368
  ...
380
369
 
381
370
  @typing.overload
382
- 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]]]:
371
+ 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]]]:
383
372
  """
384
- Enables loading / saving of models within a step.
373
+ Specifies that the step will success under all circumstances.
385
374
 
375
+ The decorator will create an optional artifact, specified by `var`, which
376
+ contains the exception raised. You can use it to detect the presence
377
+ of errors, indicating that all happy-path artifacts produced by the step
378
+ are missing.
386
379
 
387
380
 
388
381
  Parameters
389
382
  ----------
390
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
391
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
392
- These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
393
- - `current.checkpoint`
394
- - `current.model`
395
- - `current.huggingface_hub`
396
-
397
- 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
398
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
399
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
400
-
401
- temp_dir_root : str, default: None
402
- The root directory under which `current.model.loaded` will store loaded models
383
+ var : str, optional, default None
384
+ Name of the artifact in which to store the caught exception.
385
+ If not specified, the exception is not stored.
386
+ print_exception : bool, default True
387
+ Determines whether or not the exception is printed to
388
+ stdout when caught.
403
389
  """
404
390
  ...
405
391
 
406
392
  @typing.overload
407
- def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
393
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
408
394
  ...
409
395
 
410
396
  @typing.overload
411
- def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
397
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
412
398
  ...
413
399
 
414
- 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):
400
+ 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):
415
401
  """
416
- Enables loading / saving of models within a step.
402
+ Specifies that the step will success under all circumstances.
417
403
 
404
+ The decorator will create an optional artifact, specified by `var`, which
405
+ contains the exception raised. You can use it to detect the presence
406
+ of errors, indicating that all happy-path artifacts produced by the step
407
+ are missing.
418
408
 
419
409
 
420
410
  Parameters
421
411
  ----------
422
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
423
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
424
- These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
425
- - `current.checkpoint`
426
- - `current.model`
427
- - `current.huggingface_hub`
428
-
429
- 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
430
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
431
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
432
-
433
- temp_dir_root : str, default: None
434
- The root directory under which `current.model.loaded` will store loaded models
412
+ var : str, optional, default None
413
+ Name of the artifact in which to store the caught exception.
414
+ If not specified, the exception is not stored.
415
+ print_exception : bool, default True
416
+ Determines whether or not the exception is printed to
417
+ stdout when caught.
435
418
  """
436
419
  ...
437
420
 
438
- def app_deploy(*, app_port: int, app_name: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
421
+ def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.Union[typing.List[str], typing.List[typing.Tuple[typing.Dict, str]], typing.List[typing.Tuple[str, str]], typing.List[typing.Dict], None]) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
439
422
  """
440
- Specifies that this step is used to deploy an instance of the app.
441
- Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
423
+ Decorator that helps cache, version and store models/datasets from huggingface hub.
442
424
 
443
425
 
444
426
  Parameters
445
427
  ----------
446
- app_port : int
447
- Number of GPUs to use.
448
- app_name : str
449
- Name of the app to deploy.
428
+ temp_dir_root : str, optional
429
+ The root directory that will hold the temporary directory where objects will be downloaded.
430
+
431
+ load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
432
+ The list of repos (models/datasets) to load.
433
+
434
+ Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
435
+
436
+ - If repo (model/dataset) is not found in the datastore:
437
+ - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
438
+ - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
439
+ - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
440
+
441
+ - If repo is found in the datastore:
442
+ - Loads it directly from datastore to local path (can be temporary directory or specified path)
450
443
  """
451
444
  ...
452
445
 
453
- @typing.overload
454
- 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]]]:
446
+ def ollama(*, models: list, backend: str, force_pull: bool, cache_update_policy: str, force_cache_update: bool, debug: bool, circuit_breaker_config: dict, timeout_config: dict) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
455
447
  """
456
- Specifies the number of times the task corresponding
457
- to a step needs to be retried.
448
+ This decorator is used to run Ollama APIs as Metaflow task sidecars.
458
449
 
459
- This decorator is useful for handling transient errors, such as networking issues.
460
- If your task contains operations that can't be retried safely, e.g. database updates,
461
- it is advisable to annotate it with `@retry(times=0)`.
450
+ User code call
451
+ --------------
452
+ @ollama(
453
+ models=[...],
454
+ ...
455
+ )
462
456
 
463
- This can be used in conjunction with the `@catch` decorator. The `@catch`
464
- decorator will execute a no-op task after all retries have been exhausted,
465
- ensuring that the flow execution can continue.
457
+ Valid backend options
458
+ ---------------------
459
+ - 'local': Run as a separate process on the local task machine.
460
+ - (TODO) 'managed': Outerbounds hosts and selects compute provider.
461
+ - (TODO) 'remote': Spin up separate instance to serve Ollama models.
462
+
463
+ Valid model options
464
+ -------------------
465
+ Any model here https://ollama.com/search, e.g. 'llama3.2', 'llama3.3'
466
466
 
467
467
 
468
468
  Parameters
469
469
  ----------
470
- times : int, default 3
471
- Number of times to retry this task.
472
- minutes_between_retries : int, default 2
473
- Number of minutes between retries.
470
+ models: list[str]
471
+ List of Ollama containers running models in sidecars.
472
+ backend: str
473
+ Determines where and how to run the Ollama process.
474
+ force_pull: bool
475
+ Whether to run `ollama pull` no matter what, or first check the remote cache in Metaflow datastore for this model key.
476
+ cache_update_policy: str
477
+ Cache update policy: "auto", "force", or "never".
478
+ force_cache_update: bool
479
+ Simple override for "force" cache update policy.
480
+ debug: bool
481
+ Whether to turn on verbose debugging logs.
482
+ circuit_breaker_config: dict
483
+ Configuration for circuit breaker protection. Keys: failure_threshold, recovery_timeout, reset_timeout.
484
+ timeout_config: dict
485
+ Configuration for various operation timeouts. Keys: pull, stop, health_check, install, server_startup.
474
486
  """
475
487
  ...
476
488
 
477
489
  @typing.overload
478
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
479
- ...
480
-
481
- @typing.overload
482
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
483
- ...
484
-
485
- 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):
490
+ 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]]]:
486
491
  """
487
- Specifies the number of times the task corresponding
488
- to a step needs to be retried.
489
-
490
- This decorator is useful for handling transient errors, such as networking issues.
491
- If your task contains operations that can't be retried safely, e.g. database updates,
492
- it is advisable to annotate it with `@retry(times=0)`.
493
-
494
- This can be used in conjunction with the `@catch` decorator. The `@catch`
495
- decorator will execute a no-op task after all retries have been exhausted,
496
- ensuring that the flow execution can continue.
492
+ Specifies a timeout for your step.
497
493
 
494
+ This decorator is useful if this step may hang indefinitely.
498
495
 
499
- Parameters
500
- ----------
501
- times : int, default 3
502
- Number of times to retry this task.
503
- minutes_between_retries : int, default 2
504
- Number of minutes between retries.
505
- """
506
- ...
507
-
508
- @typing.overload
509
- 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]]]:
510
- """
511
- Enables checkpointing for a step.
496
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
497
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
498
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
512
499
 
500
+ Note that all the values specified in parameters are added together so if you specify
501
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
513
502
 
514
503
 
515
504
  Parameters
516
505
  ----------
517
- load_policy : str, default: "fresh"
518
- The policy for loading the checkpoint. The following policies are supported:
519
- - "eager": Loads the the latest available checkpoint within the namespace.
520
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
521
- will be loaded at the start of the task.
522
- - "none": Do not load any checkpoint
523
- - "fresh": Loads the lastest checkpoint created within the running Task.
524
- This mode helps loading checkpoints across various retry attempts of the same task.
525
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
526
- created within the task will be loaded when the task is retries execution on failure.
527
-
528
- temp_dir_root : str, default: None
529
- The root directory under which `current.checkpoint.directory` will be created.
506
+ seconds : int, default 0
507
+ Number of seconds to wait prior to timing out.
508
+ minutes : int, default 0
509
+ Number of minutes to wait prior to timing out.
510
+ hours : int, default 0
511
+ Number of hours to wait prior to timing out.
530
512
  """
531
513
  ...
532
514
 
533
515
  @typing.overload
534
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
516
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
535
517
  ...
536
518
 
537
519
  @typing.overload
538
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
520
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
539
521
  ...
540
522
 
541
- 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):
523
+ 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):
542
524
  """
543
- Enables checkpointing for a step.
525
+ Specifies a timeout for your step.
526
+
527
+ This decorator is useful if this step may hang indefinitely.
528
+
529
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
530
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
531
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
544
532
 
533
+ Note that all the values specified in parameters are added together so if you specify
534
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
545
535
 
546
536
 
547
537
  Parameters
548
538
  ----------
549
- load_policy : str, default: "fresh"
550
- The policy for loading the checkpoint. The following policies are supported:
551
- - "eager": Loads the the latest available checkpoint within the namespace.
552
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
553
- will be loaded at the start of the task.
554
- - "none": Do not load any checkpoint
555
- - "fresh": Loads the lastest checkpoint created within the running Task.
556
- This mode helps loading checkpoints across various retry attempts of the same task.
557
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
558
- created within the task will be loaded when the task is retries execution on failure.
559
-
560
- temp_dir_root : str, default: None
561
- The root directory under which `current.checkpoint.directory` will be created.
562
- """
563
- ...
564
-
565
- @typing.overload
566
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
567
- """
568
- Internal decorator to support Fast bakery
569
- """
570
- ...
571
-
572
- @typing.overload
573
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
574
- ...
575
-
576
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
577
- """
578
- Internal decorator to support Fast bakery
539
+ seconds : int, default 0
540
+ Number of seconds to wait prior to timing out.
541
+ minutes : int, default 0
542
+ Number of minutes to wait prior to timing out.
543
+ hours : int, default 0
544
+ Number of hours to wait prior to timing out.
579
545
  """
580
546
  ...
581
547
 
@@ -658,125 +624,114 @@ def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None]
658
624
  """
659
625
  ...
660
626
 
661
- def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.Union[typing.List[str], typing.List[typing.Tuple[typing.Dict, str]], typing.List[typing.Tuple[str, str]], typing.List[typing.Dict], None]) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
627
+ @typing.overload
628
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
662
629
  """
663
- Decorator that helps cache, version and store models/datasets from huggingface hub.
664
-
665
-
666
- Parameters
667
- ----------
668
- temp_dir_root : str, optional
669
- The root directory that will hold the temporary directory where objects will be downloaded.
670
-
671
- load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
672
- The list of repos (models/datasets) to load.
673
-
674
- Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
675
-
676
- - If repo (model/dataset) is not found in the datastore:
677
- - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
678
- - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
679
- - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
680
-
681
- - If repo is found in the datastore:
682
- - Loads it directly from datastore to local path (can be temporary directory or specified path)
630
+ Internal decorator to support Fast bakery
683
631
  """
684
632
  ...
685
633
 
686
634
  @typing.overload
687
- 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]]]:
635
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
636
+ ...
637
+
638
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
688
639
  """
689
- Specifies a timeout for your step.
690
-
691
- This decorator is useful if this step may hang indefinitely.
692
-
693
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
694
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
695
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
696
-
697
- Note that all the values specified in parameters are added together so if you specify
698
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
640
+ Internal decorator to support Fast bakery
641
+ """
642
+ ...
643
+
644
+ @typing.overload
645
+ 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]]]:
646
+ """
647
+ Specifies environment variables to be set prior to the execution of a step.
699
648
 
700
649
 
701
650
  Parameters
702
651
  ----------
703
- seconds : int, default 0
704
- Number of seconds to wait prior to timing out.
705
- minutes : int, default 0
706
- Number of minutes to wait prior to timing out.
707
- hours : int, default 0
708
- Number of hours to wait prior to timing out.
652
+ vars : Dict[str, str], default {}
653
+ Dictionary of environment variables to set.
709
654
  """
710
655
  ...
711
656
 
712
657
  @typing.overload
713
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
658
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
714
659
  ...
715
660
 
716
661
  @typing.overload
717
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
662
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
718
663
  ...
719
664
 
720
- 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):
665
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
721
666
  """
722
- Specifies a timeout for your step.
723
-
724
- This decorator is useful if this step may hang indefinitely.
725
-
726
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
727
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
728
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
729
-
730
- Note that all the values specified in parameters are added together so if you specify
731
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
667
+ Specifies environment variables to be set prior to the execution of a step.
732
668
 
733
669
 
734
670
  Parameters
735
671
  ----------
736
- seconds : int, default 0
737
- Number of seconds to wait prior to timing out.
738
- minutes : int, default 0
739
- Number of minutes to wait prior to timing out.
740
- hours : int, default 0
741
- Number of hours to wait prior to timing out.
672
+ vars : Dict[str, str], default {}
673
+ Dictionary of environment variables to set.
742
674
  """
743
675
  ...
744
676
 
745
677
  @typing.overload
746
- 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]]]:
678
+ 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]]]:
747
679
  """
748
- Creates a human-readable report, a Metaflow Card, after this step completes.
680
+ Specifies the PyPI packages for the step.
749
681
 
750
- Note that you may add multiple `@card` decorators in a step with different parameters.
682
+ Information in this decorator will augment any
683
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
684
+ you can use `@pypi_base` to set packages required by all
685
+ steps and use `@pypi` to specify step-specific overrides.
751
686
 
752
687
 
753
688
  Parameters
754
689
  ----------
755
- type : str, default 'default'
756
- Card type.
757
- id : str, optional, default None
758
- If multiple cards are present, use this id to identify this card.
759
- options : Dict[str, Any], default {}
760
- Options passed to the card. The contents depend on the card type.
761
- timeout : int, default 45
762
- Interrupt reporting if it takes more than this many seconds.
690
+ packages : Dict[str, str], default: {}
691
+ Packages to use for this step. The key is the name of the package
692
+ and the value is the version to use.
693
+ python : str, optional, default: None
694
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
695
+ that the version used will correspond to the version of the Python interpreter used to start the run.
763
696
  """
764
697
  ...
765
698
 
766
699
  @typing.overload
767
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
700
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
768
701
  ...
769
702
 
770
703
  @typing.overload
771
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
704
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
772
705
  ...
773
706
 
774
- 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):
707
+ 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):
775
708
  """
776
- Creates a human-readable report, a Metaflow Card, after this step completes.
777
-
778
- Note that you may add multiple `@card` decorators in a step with different parameters.
779
-
709
+ Specifies the PyPI packages for the step.
710
+
711
+ Information in this decorator will augment any
712
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
713
+ you can use `@pypi_base` to set packages required by all
714
+ steps and use `@pypi` to specify step-specific overrides.
715
+
716
+
717
+ Parameters
718
+ ----------
719
+ packages : Dict[str, str], default: {}
720
+ Packages to use for this step. The key is the name of the package
721
+ and the value is the version to use.
722
+ python : str, optional, default: None
723
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
724
+ that the version used will correspond to the version of the Python interpreter used to start the run.
725
+ """
726
+ ...
727
+
728
+ @typing.overload
729
+ 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]]]:
730
+ """
731
+ Creates a human-readable report, a Metaflow Card, after this step completes.
732
+
733
+ Note that you may add multiple `@card` decorators in a step with different parameters.
734
+
780
735
 
781
736
  Parameters
782
737
  ----------
@@ -792,39 +747,53 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
792
747
  ...
793
748
 
794
749
  @typing.overload
795
- 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]]]:
750
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
751
+ ...
752
+
753
+ @typing.overload
754
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
755
+ ...
756
+
757
+ 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):
796
758
  """
797
- Specifies environment variables to be set prior to the execution of a step.
759
+ Creates a human-readable report, a Metaflow Card, after this step completes.
760
+
761
+ Note that you may add multiple `@card` decorators in a step with different parameters.
798
762
 
799
763
 
800
764
  Parameters
801
765
  ----------
802
- vars : Dict[str, str], default {}
803
- Dictionary of environment variables to set.
766
+ type : str, default 'default'
767
+ Card type.
768
+ id : str, optional, default None
769
+ If multiple cards are present, use this id to identify this card.
770
+ options : Dict[str, Any], default {}
771
+ Options passed to the card. The contents depend on the card type.
772
+ timeout : int, default 45
773
+ Interrupt reporting if it takes more than this many seconds.
804
774
  """
805
775
  ...
806
776
 
807
777
  @typing.overload
808
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
778
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
779
+ """
780
+ Decorator prototype for all step decorators. This function gets specialized
781
+ and imported for all decorators types by _import_plugin_decorators().
782
+ """
809
783
  ...
810
784
 
811
785
  @typing.overload
812
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
786
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
813
787
  ...
814
788
 
815
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
789
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
816
790
  """
817
- Specifies environment variables to be set prior to the execution of a step.
818
-
819
-
820
- Parameters
821
- ----------
822
- vars : Dict[str, str], default {}
823
- Dictionary of environment variables to set.
791
+ Decorator prototype for all step decorators. This function gets specialized
792
+ and imported for all decorators types by _import_plugin_decorators().
824
793
  """
825
794
  ...
826
795
 
827
- 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]]]:
796
+ 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]]]:
828
797
  """
829
798
  Specifies that this step should execute on DGX cloud.
830
799
 
@@ -835,22 +804,78 @@ def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[t
835
804
  Number of GPUs to use.
836
805
  gpu_type : str
837
806
  Type of Nvidia GPU to use.
838
- queue_timeout : int
839
- Time to keep the job in NVCF's queue.
840
807
  """
841
808
  ...
842
809
 
843
- 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]]]:
810
+ def app_deploy(*, app_port: int, app_name: str) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
844
811
  """
845
- Specifies that this step should execute on DGX cloud.
812
+ Specifies that this step is used to deploy an instance of the app.
813
+ Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
846
814
 
847
815
 
848
816
  Parameters
849
817
  ----------
850
- gpu : int
818
+ app_port : int
851
819
  Number of GPUs to use.
852
- gpu_type : str
853
- Type of Nvidia GPU to use.
820
+ app_name : str
821
+ Name of the app to deploy.
822
+ """
823
+ ...
824
+
825
+ @typing.overload
826
+ 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]]]:
827
+ """
828
+ Enables loading / saving of models within a step.
829
+
830
+
831
+
832
+ Parameters
833
+ ----------
834
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
835
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
836
+ These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
837
+ - `current.checkpoint`
838
+ - `current.model`
839
+ - `current.huggingface_hub`
840
+
841
+ 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
842
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
843
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
844
+
845
+ temp_dir_root : str, default: None
846
+ The root directory under which `current.model.loaded` will store loaded models
847
+ """
848
+ ...
849
+
850
+ @typing.overload
851
+ def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
852
+ ...
853
+
854
+ @typing.overload
855
+ def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
856
+ ...
857
+
858
+ 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):
859
+ """
860
+ Enables loading / saving of models within a step.
861
+
862
+
863
+
864
+ Parameters
865
+ ----------
866
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
867
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
868
+ These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
869
+ - `current.checkpoint`
870
+ - `current.model`
871
+ - `current.huggingface_hub`
872
+
873
+ 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
874
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
875
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
876
+
877
+ temp_dir_root : str, default: None
878
+ The root directory under which `current.model.loaded` will store loaded models
854
879
  """
855
880
  ...
856
881
 
@@ -948,53 +973,155 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
948
973
  """
949
974
  ...
950
975
 
951
- @typing.overload
952
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
976
+ 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]]:
953
977
  """
954
- Decorator prototype for all step decorators. This function gets specialized
955
- and imported for all decorators types by _import_plugin_decorators().
978
+ 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.
979
+ 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.
980
+
981
+
982
+ Parameters
983
+ ----------
984
+ timeout : int
985
+ Time, in seconds before the task times out and fails. (Default: 3600)
986
+ poke_interval : int
987
+ Time in seconds that the job should wait in between each try. (Default: 60)
988
+ mode : str
989
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
990
+ exponential_backoff : bool
991
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
992
+ pool : str
993
+ the slot pool this task should run in,
994
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
995
+ soft_fail : bool
996
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
997
+ name : str
998
+ Name of the sensor on Airflow
999
+ description : str
1000
+ Description of sensor in the Airflow UI
1001
+ external_dag_id : str
1002
+ The dag_id that contains the task you want to wait for.
1003
+ external_task_ids : List[str]
1004
+ The list of task_ids that you want to wait for.
1005
+ If None (default value) the sensor waits for the DAG. (Default: None)
1006
+ allowed_states : List[str]
1007
+ Iterable of allowed states, (Default: ['success'])
1008
+ failed_states : List[str]
1009
+ Iterable of failed or dis-allowed states. (Default: None)
1010
+ execution_delta : datetime.timedelta
1011
+ time difference with the previous execution to look at,
1012
+ the default is the same logical date as the current task or DAG. (Default: None)
1013
+ check_existence: bool
1014
+ Set to True to check if the external task exists or check if
1015
+ the DAG to wait for exists. (Default: True)
956
1016
  """
957
1017
  ...
958
1018
 
959
- @typing.overload
960
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
961
- ...
962
-
963
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
1019
+ 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]]:
964
1020
  """
965
- Decorator prototype for all step decorators. This function gets specialized
966
- and imported for all decorators types by _import_plugin_decorators().
1021
+ 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)
1022
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1023
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1024
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1025
+ starts only after all sensors finish.
1026
+
1027
+
1028
+ Parameters
1029
+ ----------
1030
+ timeout : int
1031
+ Time, in seconds before the task times out and fails. (Default: 3600)
1032
+ poke_interval : int
1033
+ Time in seconds that the job should wait in between each try. (Default: 60)
1034
+ mode : str
1035
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1036
+ exponential_backoff : bool
1037
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1038
+ pool : str
1039
+ the slot pool this task should run in,
1040
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1041
+ soft_fail : bool
1042
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1043
+ name : str
1044
+ Name of the sensor on Airflow
1045
+ description : str
1046
+ Description of sensor in the Airflow UI
1047
+ bucket_key : Union[str, List[str]]
1048
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1049
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1050
+ bucket_name : str
1051
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1052
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1053
+ wildcard_match : bool
1054
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1055
+ aws_conn_id : str
1056
+ a reference to the s3 connection on Airflow. (Default: None)
1057
+ verify : bool
1058
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
967
1059
  """
968
1060
  ...
969
1061
 
970
- @typing.overload
971
- 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]]:
1062
+ def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
972
1063
  """
973
- Specifies the flow(s) that this flow depends on.
1064
+ Specifies what flows belong to the same project.
974
1065
 
975
- ```
976
- @trigger_on_finish(flow='FooFlow')
977
- ```
978
- or
979
- ```
980
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
981
- ```
982
- This decorator respects the @project decorator and triggers the flow
983
- when upstream runs within the same namespace complete successfully
1066
+ A project-specific namespace is created for all flows that
1067
+ use the same `@project(name)`.
984
1068
 
985
- Additionally, you can specify project aware upstream flow dependencies
986
- by specifying the fully qualified project_flow_name.
987
- ```
988
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
989
- ```
990
- or
991
- ```
992
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
993
- ```
994
1069
 
995
- You can also specify just the project or project branch (other values will be
996
- inferred from the current project or project branch):
997
- ```
1070
+ Parameters
1071
+ ----------
1072
+ name : str
1073
+ Project name. Make sure that the name is unique amongst all
1074
+ projects that use the same production scheduler. The name may
1075
+ contain only lowercase alphanumeric characters and underscores.
1076
+
1077
+ branch : Optional[str], default None
1078
+ The branch to use. If not specified, the branch is set to
1079
+ `user.<username>` unless `production` is set to `True`. This can
1080
+ also be set on the command line using `--branch` as a top-level option.
1081
+ It is an error to specify `branch` in the decorator and on the command line.
1082
+
1083
+ production : bool, default False
1084
+ Whether or not the branch is the production branch. This can also be set on the
1085
+ command line using `--production` as a top-level option. It is an error to specify
1086
+ `production` in the decorator and on the command line.
1087
+ The project branch name will be:
1088
+ - if `branch` is specified:
1089
+ - if `production` is True: `prod.<branch>`
1090
+ - if `production` is False: `test.<branch>`
1091
+ - if `branch` is not specified:
1092
+ - if `production` is True: `prod`
1093
+ - if `production` is False: `user.<username>`
1094
+ """
1095
+ ...
1096
+
1097
+ @typing.overload
1098
+ 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]]:
1099
+ """
1100
+ Specifies the flow(s) that this flow depends on.
1101
+
1102
+ ```
1103
+ @trigger_on_finish(flow='FooFlow')
1104
+ ```
1105
+ or
1106
+ ```
1107
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1108
+ ```
1109
+ This decorator respects the @project decorator and triggers the flow
1110
+ when upstream runs within the same namespace complete successfully
1111
+
1112
+ Additionally, you can specify project aware upstream flow dependencies
1113
+ by specifying the fully qualified project_flow_name.
1114
+ ```
1115
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1116
+ ```
1117
+ or
1118
+ ```
1119
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1120
+ ```
1121
+
1122
+ You can also specify just the project or project branch (other values will be
1123
+ inferred from the current project or project branch):
1124
+ ```
998
1125
  @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
999
1126
  ```
1000
1127
 
@@ -1161,168 +1288,44 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
1161
1288
  """
1162
1289
  ...
1163
1290
 
1164
- def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1165
- """
1166
- Allows setting external datastores to save data for the
1167
- `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1168
-
1169
- This decorator is useful when users wish to save data to a different datastore
1170
- than what is configured in Metaflow. This can be for variety of reasons:
1171
-
1172
- 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1173
- 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1174
- - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1175
- 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1176
- - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1177
-
1178
- Usage:
1179
- ----------
1180
-
1181
- - Using a custom IAM role to access the datastore.
1182
-
1183
- ```python
1184
- @with_artifact_store(
1185
- type="s3",
1186
- config=lambda: {
1187
- "root": "s3://my-bucket-foo/path/to/root",
1188
- "role_arn": ROLE,
1189
- },
1190
- )
1191
- class MyFlow(FlowSpec):
1192
-
1193
- @checkpoint
1194
- @step
1195
- def start(self):
1196
- with open("my_file.txt", "w") as f:
1197
- f.write("Hello, World!")
1198
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1199
- self.next(self.end)
1200
-
1201
- ```
1202
-
1203
- - Using credentials to access the s3-compatible datastore.
1204
-
1205
- ```python
1206
- @with_artifact_store(
1207
- type="s3",
1208
- config=lambda: {
1209
- "root": "s3://my-bucket-foo/path/to/root",
1210
- "client_params": {
1211
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1212
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1213
- },
1214
- },
1215
- )
1216
- class MyFlow(FlowSpec):
1217
-
1218
- @checkpoint
1219
- @step
1220
- def start(self):
1221
- with open("my_file.txt", "w") as f:
1222
- f.write("Hello, World!")
1223
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1224
- self.next(self.end)
1225
-
1226
- ```
1227
-
1228
- - Accessing objects stored in external datastores after task execution.
1229
-
1230
- ```python
1231
- run = Run("CheckpointsTestsFlow/8992")
1232
- with artifact_store_from(run=run, config={
1233
- "client_params": {
1234
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1235
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1236
- },
1237
- }):
1238
- with Checkpoint() as cp:
1239
- latest = cp.list(
1240
- task=run["start"].task
1241
- )[0]
1242
- print(latest)
1243
- cp.load(
1244
- latest,
1245
- "test-checkpoints"
1246
- )
1247
-
1248
- task = Task("TorchTuneFlow/8484/train/53673")
1249
- with artifact_store_from(run=run, config={
1250
- "client_params": {
1251
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1252
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1253
- },
1254
- }):
1255
- load_model(
1256
- task.data.model_ref,
1257
- "test-models"
1258
- )
1259
- ```
1260
- Parameters:
1261
- ----------
1262
-
1263
- type: str
1264
- The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1265
-
1266
- config: dict or Callable
1267
- Dictionary of configuration options for the datastore. The following keys are required:
1268
- - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1269
- - example: 's3://bucket-name/path/to/root'
1270
- - example: 'gs://bucket-name/path/to/root'
1271
- - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1272
- - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1273
- - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1274
- - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1275
- """
1276
- ...
1277
-
1278
1291
  @typing.overload
1279
- def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1292
+ def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1280
1293
  """
1281
- Specifies the Conda environment for all steps of the flow.
1282
-
1283
- Use `@conda_base` to set common libraries required by all
1284
- steps and use `@conda` to specify step-specific additions.
1294
+ Specifies the PyPI packages for all steps of the flow.
1285
1295
 
1296
+ Use `@pypi_base` to set common packages required by all
1297
+ steps and use `@pypi` to specify step-specific overrides.
1286
1298
 
1287
1299
  Parameters
1288
1300
  ----------
1289
- packages : Dict[str, str], default {}
1301
+ packages : Dict[str, str], default: {}
1290
1302
  Packages to use for this flow. The key is the name of the package
1291
1303
  and the value is the version to use.
1292
- libraries : Dict[str, str], default {}
1293
- Supported for backward compatibility. When used with packages, packages will take precedence.
1294
- python : str, optional, default None
1304
+ python : str, optional, default: None
1295
1305
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
1296
1306
  that the version used will correspond to the version of the Python interpreter used to start the run.
1297
- disabled : bool, default False
1298
- If set to True, disables Conda.
1299
1307
  """
1300
1308
  ...
1301
1309
 
1302
1310
  @typing.overload
1303
- def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1311
+ def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1304
1312
  ...
1305
1313
 
1306
- def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
1314
+ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1307
1315
  """
1308
- Specifies the Conda environment for all steps of the flow.
1309
-
1310
- Use `@conda_base` to set common libraries required by all
1311
- steps and use `@conda` to specify step-specific additions.
1316
+ Specifies the PyPI packages for all steps of the flow.
1312
1317
 
1318
+ Use `@pypi_base` to set common packages required by all
1319
+ steps and use `@pypi` to specify step-specific overrides.
1313
1320
 
1314
1321
  Parameters
1315
1322
  ----------
1316
- packages : Dict[str, str], default {}
1323
+ packages : Dict[str, str], default: {}
1317
1324
  Packages to use for this flow. The key is the name of the package
1318
1325
  and the value is the version to use.
1319
- libraries : Dict[str, str], default {}
1320
- Supported for backward compatibility. When used with packages, packages will take precedence.
1321
- python : str, optional, default None
1326
+ python : str, optional, default: None
1322
1327
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
1323
1328
  that the version used will correspond to the version of the Python interpreter used to start the run.
1324
- disabled : bool, default False
1325
- If set to True, disables Conda.
1326
1329
  """
1327
1330
  ...
1328
1331
 
@@ -1377,165 +1380,168 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
1377
1380
  """
1378
1381
  ...
1379
1382
 
1380
- 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]]:
1381
- """
1382
- 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)
1383
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1384
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1385
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1386
- starts only after all sensors finish.
1387
-
1388
-
1389
- Parameters
1390
- ----------
1391
- timeout : int
1392
- Time, in seconds before the task times out and fails. (Default: 3600)
1393
- poke_interval : int
1394
- Time in seconds that the job should wait in between each try. (Default: 60)
1395
- mode : str
1396
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1397
- exponential_backoff : bool
1398
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1399
- pool : str
1400
- the slot pool this task should run in,
1401
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1402
- soft_fail : bool
1403
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1404
- name : str
1405
- Name of the sensor on Airflow
1406
- description : str
1407
- Description of sensor in the Airflow UI
1408
- bucket_key : Union[str, List[str]]
1409
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1410
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1411
- bucket_name : str
1412
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1413
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1414
- wildcard_match : bool
1415
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1416
- aws_conn_id : str
1417
- a reference to the s3 connection on Airflow. (Default: None)
1418
- verify : bool
1419
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1420
- """
1421
- ...
1422
-
1423
- 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]]:
1424
- """
1425
- 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.
1426
- 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.
1427
-
1428
-
1429
- Parameters
1430
- ----------
1431
- timeout : int
1432
- Time, in seconds before the task times out and fails. (Default: 3600)
1433
- poke_interval : int
1434
- Time in seconds that the job should wait in between each try. (Default: 60)
1435
- mode : str
1436
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1437
- exponential_backoff : bool
1438
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1439
- pool : str
1440
- the slot pool this task should run in,
1441
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1442
- soft_fail : bool
1443
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1444
- name : str
1445
- Name of the sensor on Airflow
1446
- description : str
1447
- Description of sensor in the Airflow UI
1448
- external_dag_id : str
1449
- The dag_id that contains the task you want to wait for.
1450
- external_task_ids : List[str]
1451
- The list of task_ids that you want to wait for.
1452
- If None (default value) the sensor waits for the DAG. (Default: None)
1453
- allowed_states : List[str]
1454
- Iterable of allowed states, (Default: ['success'])
1455
- failed_states : List[str]
1456
- Iterable of failed or dis-allowed states. (Default: None)
1457
- execution_delta : datetime.timedelta
1458
- time difference with the previous execution to look at,
1459
- the default is the same logical date as the current task or DAG. (Default: None)
1460
- check_existence: bool
1461
- Set to True to check if the external task exists or check if
1462
- the DAG to wait for exists. (Default: True)
1463
- """
1464
- ...
1465
-
1466
1383
  @typing.overload
1467
- def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1384
+ def conda_base(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1468
1385
  """
1469
- Specifies the PyPI packages for all steps of the flow.
1386
+ Specifies the Conda environment for all steps of the flow.
1387
+
1388
+ Use `@conda_base` to set common libraries required by all
1389
+ steps and use `@conda` to specify step-specific additions.
1470
1390
 
1471
- Use `@pypi_base` to set common packages required by all
1472
- steps and use `@pypi` to specify step-specific overrides.
1473
1391
 
1474
1392
  Parameters
1475
1393
  ----------
1476
- packages : Dict[str, str], default: {}
1394
+ packages : Dict[str, str], default {}
1477
1395
  Packages to use for this flow. The key is the name of the package
1478
1396
  and the value is the version to use.
1479
- python : str, optional, default: None
1397
+ libraries : Dict[str, str], default {}
1398
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1399
+ python : str, optional, default None
1480
1400
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
1481
1401
  that the version used will correspond to the version of the Python interpreter used to start the run.
1402
+ disabled : bool, default False
1403
+ If set to True, disables Conda.
1482
1404
  """
1483
1405
  ...
1484
1406
 
1485
1407
  @typing.overload
1486
- def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1408
+ def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1487
1409
  ...
1488
1410
 
1489
- def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1411
+ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
1490
1412
  """
1491
- Specifies the PyPI packages for all steps of the flow.
1413
+ Specifies the Conda environment for all steps of the flow.
1414
+
1415
+ Use `@conda_base` to set common libraries required by all
1416
+ steps and use `@conda` to specify step-specific additions.
1492
1417
 
1493
- Use `@pypi_base` to set common packages required by all
1494
- steps and use `@pypi` to specify step-specific overrides.
1495
1418
 
1496
1419
  Parameters
1497
1420
  ----------
1498
- packages : Dict[str, str], default: {}
1421
+ packages : Dict[str, str], default {}
1499
1422
  Packages to use for this flow. The key is the name of the package
1500
1423
  and the value is the version to use.
1501
- python : str, optional, default: None
1424
+ libraries : Dict[str, str], default {}
1425
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1426
+ python : str, optional, default None
1502
1427
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
1503
1428
  that the version used will correspond to the version of the Python interpreter used to start the run.
1429
+ disabled : bool, default False
1430
+ If set to True, disables Conda.
1504
1431
  """
1505
1432
  ...
1506
1433
 
1507
- def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1434
+ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1508
1435
  """
1509
- Specifies what flows belong to the same project.
1436
+ Allows setting external datastores to save data for the
1437
+ `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1510
1438
 
1511
- A project-specific namespace is created for all flows that
1512
- use the same `@project(name)`.
1439
+ This decorator is useful when users wish to save data to a different datastore
1440
+ than what is configured in Metaflow. This can be for variety of reasons:
1513
1441
 
1442
+ 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1443
+ 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1444
+ - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1445
+ 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1446
+ - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1514
1447
 
1515
- Parameters
1448
+ Usage:
1516
1449
  ----------
1517
- name : str
1518
- Project name. Make sure that the name is unique amongst all
1519
- projects that use the same production scheduler. The name may
1520
- contain only lowercase alphanumeric characters and underscores.
1521
1450
 
1522
- branch : Optional[str], default None
1523
- The branch to use. If not specified, the branch is set to
1524
- `user.<username>` unless `production` is set to `True`. This can
1525
- also be set on the command line using `--branch` as a top-level option.
1526
- It is an error to specify `branch` in the decorator and on the command line.
1451
+ - Using a custom IAM role to access the datastore.
1527
1452
 
1528
- production : bool, default False
1529
- Whether or not the branch is the production branch. This can also be set on the
1530
- command line using `--production` as a top-level option. It is an error to specify
1531
- `production` in the decorator and on the command line.
1532
- The project branch name will be:
1533
- - if `branch` is specified:
1534
- - if `production` is True: `prod.<branch>`
1535
- - if `production` is False: `test.<branch>`
1536
- - if `branch` is not specified:
1537
- - if `production` is True: `prod`
1538
- - if `production` is False: `user.<username>`
1453
+ ```python
1454
+ @with_artifact_store(
1455
+ type="s3",
1456
+ config=lambda: {
1457
+ "root": "s3://my-bucket-foo/path/to/root",
1458
+ "role_arn": ROLE,
1459
+ },
1460
+ )
1461
+ class MyFlow(FlowSpec):
1462
+
1463
+ @checkpoint
1464
+ @step
1465
+ def start(self):
1466
+ with open("my_file.txt", "w") as f:
1467
+ f.write("Hello, World!")
1468
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1469
+ self.next(self.end)
1470
+
1471
+ ```
1472
+
1473
+ - Using credentials to access the s3-compatible datastore.
1474
+
1475
+ ```python
1476
+ @with_artifact_store(
1477
+ type="s3",
1478
+ config=lambda: {
1479
+ "root": "s3://my-bucket-foo/path/to/root",
1480
+ "client_params": {
1481
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1482
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1483
+ },
1484
+ },
1485
+ )
1486
+ class MyFlow(FlowSpec):
1487
+
1488
+ @checkpoint
1489
+ @step
1490
+ def start(self):
1491
+ with open("my_file.txt", "w") as f:
1492
+ f.write("Hello, World!")
1493
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1494
+ self.next(self.end)
1495
+
1496
+ ```
1497
+
1498
+ - Accessing objects stored in external datastores after task execution.
1499
+
1500
+ ```python
1501
+ run = Run("CheckpointsTestsFlow/8992")
1502
+ with artifact_store_from(run=run, config={
1503
+ "client_params": {
1504
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1505
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1506
+ },
1507
+ }):
1508
+ with Checkpoint() as cp:
1509
+ latest = cp.list(
1510
+ task=run["start"].task
1511
+ )[0]
1512
+ print(latest)
1513
+ cp.load(
1514
+ latest,
1515
+ "test-checkpoints"
1516
+ )
1517
+
1518
+ task = Task("TorchTuneFlow/8484/train/53673")
1519
+ with artifact_store_from(run=run, config={
1520
+ "client_params": {
1521
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1522
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1523
+ },
1524
+ }):
1525
+ load_model(
1526
+ task.data.model_ref,
1527
+ "test-models"
1528
+ )
1529
+ ```
1530
+ Parameters:
1531
+ ----------
1532
+
1533
+ type: str
1534
+ The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1535
+
1536
+ config: dict or Callable
1537
+ Dictionary of configuration options for the datastore. The following keys are required:
1538
+ - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1539
+ - example: 's3://bucket-name/path/to/root'
1540
+ - example: 'gs://bucket-name/path/to/root'
1541
+ - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1542
+ - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1543
+ - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1544
+ - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1539
1545
  """
1540
1546
  ...
1541
1547