ob-metaflow-stubs 6.0.3.161__py2.py3-none-any.whl → 6.0.3.162__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 (206) hide show
  1. metaflow-stubs/__init__.pyi +766 -766
  2. metaflow-stubs/cards.pyi +1 -1
  3. metaflow-stubs/cli.pyi +1 -1
  4. metaflow-stubs/cli_components/__init__.pyi +1 -1
  5. metaflow-stubs/cli_components/utils.pyi +1 -1
  6. metaflow-stubs/client/__init__.pyi +1 -1
  7. metaflow-stubs/client/core.pyi +3 -3
  8. metaflow-stubs/client/filecache.pyi +1 -1
  9. metaflow-stubs/events.pyi +2 -2
  10. metaflow-stubs/exception.pyi +1 -1
  11. metaflow-stubs/flowspec.pyi +2 -2
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +1 -1
  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 +96 -96
  21. metaflow-stubs/metaflow_git.pyi +1 -1
  22. metaflow-stubs/mf_extensions/__init__.pyi +1 -1
  23. metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +1 -1
  24. metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +1 -1
  25. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +1 -1
  26. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +1 -1
  27. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +1 -1
  28. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +1 -1
  29. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +2 -2
  30. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +1 -1
  31. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +1 -1
  32. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +2 -2
  33. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +1 -1
  34. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +3 -3
  35. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +1 -1
  36. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +4 -4
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +3 -3
  38. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +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 +2 -2
  47. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +1 -1
  48. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +1 -1
  49. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +1 -1
  50. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +1 -1
  51. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +2 -2
  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 +3 -3
  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 +2 -2
  60. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +1 -1
  61. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +1 -1
  62. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +1 -1
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +1 -1
  64. metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +1 -1
  65. metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +1 -1
  66. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +1 -1
  67. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +1 -1
  68. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +1 -1
  69. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +1 -1
  70. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +1 -1
  71. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +1 -1
  72. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +1 -1
  73. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +1 -1
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +1 -1
  75. metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +1 -1
  76. metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +1 -1
  77. metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +1 -1
  78. metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +1 -1
  79. metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +1 -1
  80. metaflow-stubs/multicore_utils.pyi +1 -1
  81. metaflow-stubs/parameters.pyi +2 -2
  82. metaflow-stubs/plugins/__init__.pyi +11 -11
  83. metaflow-stubs/plugins/airflow/__init__.pyi +1 -1
  84. metaflow-stubs/plugins/airflow/airflow_utils.pyi +1 -1
  85. metaflow-stubs/plugins/airflow/exception.pyi +1 -1
  86. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +1 -1
  87. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +1 -1
  88. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +1 -1
  89. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +1 -1
  90. metaflow-stubs/plugins/argo/__init__.pyi +1 -1
  91. metaflow-stubs/plugins/argo/argo_client.pyi +1 -1
  92. metaflow-stubs/plugins/argo/argo_events.pyi +1 -1
  93. metaflow-stubs/plugins/argo/argo_workflows.pyi +1 -1
  94. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +1 -1
  95. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +1 -1
  96. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +2 -2
  97. metaflow-stubs/plugins/aws/__init__.pyi +1 -1
  98. metaflow-stubs/plugins/aws/aws_client.pyi +1 -1
  99. metaflow-stubs/plugins/aws/aws_utils.pyi +1 -1
  100. metaflow-stubs/plugins/aws/batch/__init__.pyi +1 -1
  101. metaflow-stubs/plugins/aws/batch/batch.pyi +1 -1
  102. metaflow-stubs/plugins/aws/batch/batch_client.pyi +1 -1
  103. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +1 -1
  104. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +1 -1
  105. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +2 -2
  106. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +1 -1
  107. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +1 -1
  108. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +1 -1
  109. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +1 -1
  110. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +1 -1
  111. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +2 -2
  112. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
  113. metaflow-stubs/plugins/azure/__init__.pyi +1 -1
  114. metaflow-stubs/plugins/azure/azure_credential.pyi +1 -1
  115. metaflow-stubs/plugins/azure/azure_exceptions.pyi +1 -1
  116. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +2 -2
  117. metaflow-stubs/plugins/azure/azure_utils.pyi +1 -1
  118. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +1 -1
  119. metaflow-stubs/plugins/azure/includefile_support.pyi +1 -1
  120. metaflow-stubs/plugins/cards/__init__.pyi +1 -1
  121. metaflow-stubs/plugins/cards/card_client.pyi +2 -2
  122. metaflow-stubs/plugins/cards/card_creator.pyi +1 -1
  123. metaflow-stubs/plugins/cards/card_datastore.pyi +1 -1
  124. metaflow-stubs/plugins/cards/card_decorator.pyi +1 -1
  125. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +1 -1
  126. metaflow-stubs/plugins/cards/card_modules/basic.pyi +2 -2
  127. metaflow-stubs/plugins/cards/card_modules/card.pyi +1 -1
  128. metaflow-stubs/plugins/cards/card_modules/components.pyi +2 -2
  129. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +1 -1
  130. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +1 -1
  131. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +1 -1
  132. metaflow-stubs/plugins/cards/card_resolver.pyi +1 -1
  133. metaflow-stubs/plugins/cards/component_serializer.pyi +1 -1
  134. metaflow-stubs/plugins/cards/exception.pyi +1 -1
  135. metaflow-stubs/plugins/catch_decorator.pyi +1 -1
  136. metaflow-stubs/plugins/datatools/__init__.pyi +1 -1
  137. metaflow-stubs/plugins/datatools/local.pyi +1 -1
  138. metaflow-stubs/plugins/datatools/s3/__init__.pyi +1 -1
  139. metaflow-stubs/plugins/datatools/s3/s3.pyi +1 -1
  140. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +1 -1
  141. metaflow-stubs/plugins/datatools/s3/s3util.pyi +1 -1
  142. metaflow-stubs/plugins/debug_logger.pyi +1 -1
  143. metaflow-stubs/plugins/debug_monitor.pyi +1 -1
  144. metaflow-stubs/plugins/environment_decorator.pyi +1 -1
  145. metaflow-stubs/plugins/events_decorator.pyi +1 -1
  146. metaflow-stubs/plugins/frameworks/__init__.pyi +1 -1
  147. metaflow-stubs/plugins/frameworks/pytorch.pyi +1 -1
  148. metaflow-stubs/plugins/gcp/__init__.pyi +1 -1
  149. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +2 -2
  150. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +1 -1
  151. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +1 -1
  152. metaflow-stubs/plugins/gcp/gs_utils.pyi +1 -1
  153. metaflow-stubs/plugins/gcp/includefile_support.pyi +1 -1
  154. metaflow-stubs/plugins/kubernetes/__init__.pyi +1 -1
  155. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +1 -1
  156. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +1 -1
  157. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +1 -1
  158. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +1 -1
  159. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +1 -1
  160. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +1 -1
  161. metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
  162. metaflow-stubs/plugins/parallel_decorator.pyi +1 -1
  163. metaflow-stubs/plugins/perimeters.pyi +1 -1
  164. metaflow-stubs/plugins/project_decorator.pyi +1 -1
  165. metaflow-stubs/plugins/pypi/__init__.pyi +1 -1
  166. metaflow-stubs/plugins/pypi/conda_decorator.pyi +1 -1
  167. metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
  168. metaflow-stubs/plugins/pypi/parsers.pyi +1 -1
  169. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +1 -1
  170. metaflow-stubs/plugins/pypi/pypi_environment.pyi +1 -1
  171. metaflow-stubs/plugins/pypi/utils.pyi +1 -1
  172. metaflow-stubs/plugins/resources_decorator.pyi +1 -1
  173. metaflow-stubs/plugins/retry_decorator.pyi +1 -1
  174. metaflow-stubs/plugins/secrets/__init__.pyi +1 -1
  175. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +2 -2
  176. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +1 -1
  177. metaflow-stubs/plugins/snowflake/__init__.pyi +1 -1
  178. metaflow-stubs/plugins/storage_executor.pyi +1 -1
  179. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +1 -1
  180. metaflow-stubs/plugins/timeout_decorator.pyi +1 -1
  181. metaflow-stubs/plugins/uv/__init__.pyi +1 -1
  182. metaflow-stubs/plugins/uv/uv_environment.pyi +1 -1
  183. metaflow-stubs/profilers/__init__.pyi +1 -1
  184. metaflow-stubs/pylint_wrapper.pyi +1 -1
  185. metaflow-stubs/runner/__init__.pyi +1 -1
  186. metaflow-stubs/runner/deployer.pyi +4 -4
  187. metaflow-stubs/runner/deployer_impl.pyi +1 -1
  188. metaflow-stubs/runner/metaflow_runner.pyi +1 -1
  189. metaflow-stubs/runner/nbdeploy.pyi +1 -1
  190. metaflow-stubs/runner/nbrun.pyi +1 -1
  191. metaflow-stubs/runner/subprocess_manager.pyi +1 -1
  192. metaflow-stubs/runner/utils.pyi +1 -1
  193. metaflow-stubs/system/__init__.pyi +1 -1
  194. metaflow-stubs/system/system_logger.pyi +1 -1
  195. metaflow-stubs/system/system_monitor.pyi +1 -1
  196. metaflow-stubs/tagging_util.pyi +1 -1
  197. metaflow-stubs/tuple_util.pyi +1 -1
  198. metaflow-stubs/user_configs/__init__.pyi +1 -1
  199. metaflow-stubs/user_configs/config_decorators.pyi +4 -4
  200. metaflow-stubs/user_configs/config_options.pyi +2 -2
  201. metaflow-stubs/user_configs/config_parameters.pyi +6 -6
  202. {ob_metaflow_stubs-6.0.3.161.dist-info → ob_metaflow_stubs-6.0.3.162.dist-info}/METADATA +1 -1
  203. ob_metaflow_stubs-6.0.3.162.dist-info/RECORD +206 -0
  204. ob_metaflow_stubs-6.0.3.161.dist-info/RECORD +0 -206
  205. {ob_metaflow_stubs-6.0.3.161.dist-info → ob_metaflow_stubs-6.0.3.162.dist-info}/WHEEL +0 -0
  206. {ob_metaflow_stubs-6.0.3.161.dist-info → ob_metaflow_stubs-6.0.3.162.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
3
  # MF version: 2.15.10.1+obcheckpoint(0.2.1);ob(v1) #
4
- # Generated on 2025-05-05T20:26:16.823529 #
4
+ # Generated on 2025-05-05T21:26:32.787199 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
@@ -35,17 +35,17 @@ from .user_configs.config_parameters import ConfigValue as ConfigValue
35
35
  from .user_configs.config_parameters import config_expr as config_expr
36
36
  from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
37
37
  from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
38
- from . import events as events
39
- from . import tuple_util as tuple_util
40
38
  from . import cards as cards
39
+ from . import tuple_util as tuple_util
41
40
  from . import metaflow_git as metaflow_git
41
+ from . import events as events
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
48
47
  from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
48
+ from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
49
49
  from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
50
50
  from . import client as client
51
51
  from .client.core import namespace as namespace
@@ -153,122 +153,6 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
153
153
  """
154
154
  ...
155
155
 
156
- @typing.overload
157
- 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]]]:
158
- """
159
- Enables loading / saving of models within a step.
160
-
161
-
162
-
163
- Parameters
164
- ----------
165
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
166
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
167
- These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
168
- - `current.checkpoint`
169
- - `current.model`
170
- - `current.huggingface_hub`
171
-
172
- 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
173
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
174
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
175
-
176
- temp_dir_root : str, default: None
177
- The root directory under which `current.model.loaded` will store loaded models
178
- """
179
- ...
180
-
181
- @typing.overload
182
- def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
183
- ...
184
-
185
- @typing.overload
186
- def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
187
- ...
188
-
189
- 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):
190
- """
191
- Enables loading / saving of models within a step.
192
-
193
-
194
-
195
- Parameters
196
- ----------
197
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
198
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
199
- These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
200
- - `current.checkpoint`
201
- - `current.model`
202
- - `current.huggingface_hub`
203
-
204
- 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
205
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
206
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
207
-
208
- temp_dir_root : str, default: None
209
- The root directory under which `current.model.loaded` will store loaded models
210
- """
211
- ...
212
-
213
- @typing.overload
214
- 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]]]:
215
- """
216
- Specifies a timeout for your step.
217
-
218
- This decorator is useful if this step may hang indefinitely.
219
-
220
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
221
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
222
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
223
-
224
- Note that all the values specified in parameters are added together so if you specify
225
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
226
-
227
-
228
- Parameters
229
- ----------
230
- seconds : int, default 0
231
- Number of seconds to wait prior to timing out.
232
- minutes : int, default 0
233
- Number of minutes to wait prior to timing out.
234
- hours : int, default 0
235
- Number of hours to wait prior to timing out.
236
- """
237
- ...
238
-
239
- @typing.overload
240
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
241
- ...
242
-
243
- @typing.overload
244
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
245
- ...
246
-
247
- 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):
248
- """
249
- Specifies a timeout for your step.
250
-
251
- This decorator is useful if this step may hang indefinitely.
252
-
253
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
254
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
255
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
256
-
257
- Note that all the values specified in parameters are added together so if you specify
258
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
259
-
260
-
261
- Parameters
262
- ----------
263
- seconds : int, default 0
264
- Number of seconds to wait prior to timing out.
265
- minutes : int, default 0
266
- Number of minutes to wait prior to timing out.
267
- hours : int, default 0
268
- Number of hours to wait prior to timing out.
269
- """
270
- ...
271
-
272
156
  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]]]:
273
157
  """
274
158
  Specifies that this step is used to deploy an instance of the app.
@@ -284,57 +168,6 @@ def app_deploy(*, app_port: int, app_name: str) -> typing.Callable[[typing.Union
284
168
  """
285
169
  ...
286
170
 
287
- @typing.overload
288
- 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]]]:
289
- """
290
- Specifies that the step will success under all circumstances.
291
-
292
- The decorator will create an optional artifact, specified by `var`, which
293
- contains the exception raised. You can use it to detect the presence
294
- of errors, indicating that all happy-path artifacts produced by the step
295
- are missing.
296
-
297
-
298
- Parameters
299
- ----------
300
- var : str, optional, default None
301
- Name of the artifact in which to store the caught exception.
302
- If not specified, the exception is not stored.
303
- print_exception : bool, default True
304
- Determines whether or not the exception is printed to
305
- stdout when caught.
306
- """
307
- ...
308
-
309
- @typing.overload
310
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
311
- ...
312
-
313
- @typing.overload
314
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
315
- ...
316
-
317
- 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):
318
- """
319
- Specifies that the step will success under all circumstances.
320
-
321
- The decorator will create an optional artifact, specified by `var`, which
322
- contains the exception raised. You can use it to detect the presence
323
- of errors, indicating that all happy-path artifacts produced by the step
324
- are missing.
325
-
326
-
327
- Parameters
328
- ----------
329
- var : str, optional, default None
330
- Name of the artifact in which to store the caught exception.
331
- If not specified, the exception is not stored.
332
- print_exception : bool, default True
333
- Determines whether or not the exception is printed to
334
- stdout when caught.
335
- """
336
- ...
337
-
338
171
  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]]]:
339
172
  """
340
173
  Decorator that helps cache, version and store models/datasets from huggingface hub.
@@ -361,341 +194,73 @@ def huggingface_hub(*, temp_dir_root: typing.Optional[str] = None, load: typing.
361
194
  ...
362
195
 
363
196
  @typing.overload
364
- 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]]]:
197
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
365
198
  """
366
- Enables checkpointing for a step.
367
-
368
-
369
-
370
- Parameters
371
- ----------
372
- load_policy : str, default: "fresh"
373
- The policy for loading the checkpoint. The following policies are supported:
374
- - "eager": Loads the the latest available checkpoint within the namespace.
375
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
376
- will be loaded at the start of the task.
377
- - "none": Do not load any checkpoint
378
- - "fresh": Loads the lastest checkpoint created within the running Task.
379
- This mode helps loading checkpoints across various retry attempts of the same task.
380
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
381
- created within the task will be loaded when the task is retries execution on failure.
382
-
383
- temp_dir_root : str, default: None
384
- The root directory under which `current.checkpoint.directory` will be created.
199
+ Internal decorator to support Fast bakery
385
200
  """
386
201
  ...
387
202
 
388
203
  @typing.overload
389
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
390
- ...
391
-
392
- @typing.overload
393
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
204
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
394
205
  ...
395
206
 
396
- 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):
207
+ def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
397
208
  """
398
- Enables checkpointing for a step.
399
-
400
-
401
-
402
- Parameters
403
- ----------
404
- load_policy : str, default: "fresh"
405
- The policy for loading the checkpoint. The following policies are supported:
406
- - "eager": Loads the the latest available checkpoint within the namespace.
407
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
408
- will be loaded at the start of the task.
409
- - "none": Do not load any checkpoint
410
- - "fresh": Loads the lastest checkpoint created within the running Task.
411
- This mode helps loading checkpoints across various retry attempts of the same task.
412
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
413
- created within the task will be loaded when the task is retries execution on failure.
414
-
415
- temp_dir_root : str, default: None
416
- The root directory under which `current.checkpoint.directory` will be created.
209
+ Internal decorator to support Fast bakery
417
210
  """
418
211
  ...
419
212
 
420
213
  @typing.overload
421
- 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]]]:
214
+ def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> 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]]]:
422
215
  """
423
- Specifies environment variables to be set prior to the execution of a step.
216
+ Specifies secrets to be retrieved and injected as environment variables prior to
217
+ the execution of a step.
424
218
 
425
219
 
426
220
  Parameters
427
221
  ----------
428
- vars : Dict[str, str], default {}
429
- Dictionary of environment variables to set.
222
+ sources : List[Union[str, Dict[str, Any]]], default: []
223
+ List of secret specs, defining how the secrets are to be retrieved
430
224
  """
431
225
  ...
432
226
 
433
227
  @typing.overload
434
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
228
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
435
229
  ...
436
230
 
437
231
  @typing.overload
438
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
232
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
439
233
  ...
440
234
 
441
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
235
+ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
442
236
  """
443
- Specifies environment variables to be set prior to the execution of a step.
237
+ Specifies secrets to be retrieved and injected as environment variables prior to
238
+ the execution of a step.
444
239
 
445
240
 
446
241
  Parameters
447
242
  ----------
448
- vars : Dict[str, str], default {}
449
- Dictionary of environment variables to set.
243
+ sources : List[Union[str, Dict[str, Any]]], default: []
244
+ List of secret specs, defining how the secrets are to be retrieved
450
245
  """
451
246
  ...
452
247
 
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]]]:
248
+ 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]]]:
455
249
  """
456
- Specifies the number of times the task corresponding
457
- to a step needs to be retried.
458
-
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)`.
462
-
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.
466
-
467
-
468
- Parameters
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.
474
- """
475
- ...
476
-
477
- @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):
486
- """
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.
497
-
498
-
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 fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
510
- """
511
- Internal decorator to support Fast bakery
512
- """
513
- ...
514
-
515
- @typing.overload
516
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
517
- ...
518
-
519
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
520
- """
521
- Internal decorator to support Fast bakery
522
- """
523
- ...
524
-
525
- def nim(*, models: "list[NIM]", backend: 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]]]:
526
- """
527
- This decorator is used to run NIM containers in Metaflow tasks as sidecars.
528
-
529
- User code call
530
- -----------
531
- @nim(
532
- models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
533
- backend='managed'
534
- )
535
-
536
- Valid backend options
537
- ---------------------
538
- - 'managed': Outerbounds selects a compute provider based on the model.
539
-
540
- Valid model options
541
- ----------------
542
- - 'meta/llama3-8b-instruct': 8B parameter model
543
- - 'meta/llama3-70b-instruct': 70B parameter model
544
- - any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
250
+ Specifies that this step should execute on DGX cloud.
545
251
 
546
252
 
547
253
  Parameters
548
254
  ----------
549
- models: list[NIM]
550
- List of NIM containers running models in sidecars.
551
- backend: str
552
- Compute provider to run the NIM container.
255
+ gpu : int
256
+ Number of GPUs to use.
257
+ gpu_type : str
258
+ Type of Nvidia GPU to use.
553
259
  queue_timeout : int
554
260
  Time to keep the job in NVCF's queue.
555
261
  """
556
262
  ...
557
263
 
558
- def ollama(*, models: "list[Ollama]", backend: 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]]]:
559
- """
560
- This decorator is used to run Ollama APIs as Metaflow task sidecars.
561
-
562
- User code call
563
- -----------
564
- @ollama(
565
- models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
566
- backend='local'
567
- )
568
-
569
- Valid backend options
570
- ---------------------
571
- - 'local': Run as a separate process on the local task machine.
572
- - (TODO) 'managed': Outerbounds hosts and selects compute provider.
573
- - (TODO) 'remote': Spin up separate instance to serve Ollama models.
574
-
575
- Valid model options
576
- ----------------
577
- - 'llama3.2'
578
- - 'llama3.3'
579
- - any model here https://ollama.com/search
580
-
581
-
582
- Parameters
583
- ----------
584
- models: list[Ollama]
585
- List of Ollama containers running models in sidecars.
586
- backend: str
587
- Determines where and how to run the Ollama process.
588
- """
589
- ...
590
-
591
- @typing.overload
592
- 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]]]:
593
- """
594
- Creates a human-readable report, a Metaflow Card, after this step completes.
595
-
596
- Note that you may add multiple `@card` decorators in a step with different parameters.
597
-
598
-
599
- Parameters
600
- ----------
601
- type : str, default 'default'
602
- Card type.
603
- id : str, optional, default None
604
- If multiple cards are present, use this id to identify this card.
605
- options : Dict[str, Any], default {}
606
- Options passed to the card. The contents depend on the card type.
607
- timeout : int, default 45
608
- Interrupt reporting if it takes more than this many seconds.
609
- """
610
- ...
611
-
612
- @typing.overload
613
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
614
- ...
615
-
616
- @typing.overload
617
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
618
- ...
619
-
620
- 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):
621
- """
622
- Creates a human-readable report, a Metaflow Card, after this step completes.
623
-
624
- Note that you may add multiple `@card` decorators in a step with different parameters.
625
-
626
-
627
- Parameters
628
- ----------
629
- type : str, default 'default'
630
- Card type.
631
- id : str, optional, default None
632
- If multiple cards are present, use this id to identify this card.
633
- options : Dict[str, Any], default {}
634
- Options passed to the card. The contents depend on the card type.
635
- timeout : int, default 45
636
- Interrupt reporting if it takes more than this many seconds.
637
- """
638
- ...
639
-
640
- @typing.overload
641
- def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
642
- """
643
- Specifies the Conda environment for the step.
644
-
645
- Information in this decorator will augment any
646
- attributes set in the `@conda_base` flow-level decorator. Hence,
647
- you can use `@conda_base` to set packages required by all
648
- steps and use `@conda` to specify step-specific overrides.
649
-
650
-
651
- Parameters
652
- ----------
653
- packages : Dict[str, str], default {}
654
- Packages to use for this step. The key is the name of the package
655
- and the value is the version to use.
656
- libraries : Dict[str, str], default {}
657
- Supported for backward compatibility. When used with packages, packages will take precedence.
658
- python : str, optional, default None
659
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
660
- that the version used will correspond to the version of the Python interpreter used to start the run.
661
- disabled : bool, default False
662
- If set to True, disables @conda.
663
- """
664
- ...
665
-
666
- @typing.overload
667
- def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
668
- ...
669
-
670
- @typing.overload
671
- def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
672
- ...
673
-
674
- def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
675
- """
676
- Specifies the Conda environment for the step.
677
-
678
- Information in this decorator will augment any
679
- attributes set in the `@conda_base` flow-level decorator. Hence,
680
- you can use `@conda_base` to set packages required by all
681
- steps and use `@conda` to specify step-specific overrides.
682
-
683
-
684
- Parameters
685
- ----------
686
- packages : Dict[str, str], default {}
687
- Packages to use for this step. The key is the name of the package
688
- and the value is the version to use.
689
- libraries : Dict[str, str], default {}
690
- Supported for backward compatibility. When used with packages, packages will take precedence.
691
- python : str, optional, default None
692
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
693
- that the version used will correspond to the version of the Python interpreter used to start the run.
694
- disabled : bool, default False
695
- If set to True, disables @conda.
696
- """
697
- ...
698
-
699
264
  def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = 'KUBERNETES_IMAGE_PULL_POLICY', service_account: str = 'METAFLOW_KUBERNETES_SERVICE_ACCOUNT', secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = 'METAFLOW_KUBERNETES_NAMESPACE', gpu: typing.Optional[int] = None, gpu_vendor: str = 'KUBERNETES_GPU_VENDOR', tolerations: typing.List[str] = [], labels: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_LABELS', annotations: typing.Dict[str, str] = 'METAFLOW_KUBERNETES_ANNOTATIONS', use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = '/metaflow_temp', persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None, compute_pool: typing.Optional[str] = None, hostname_resolution_timeout: int = 600, qos: str = 'Burstable', security_context: typing.Optional[typing.Dict[str, typing.Any]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
700
265
  """
701
266
  Specifies that this step should execute on Kubernetes.
@@ -781,73 +346,418 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
781
346
  """
782
347
  ...
783
348
 
784
- 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]]]:
349
+ def ollama(*, models: "list[Ollama]", backend: 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]]]:
785
350
  """
786
- Specifies that this step should execute on DGX cloud.
351
+ This decorator is used to run Ollama APIs as Metaflow task sidecars.
352
+
353
+ User code call
354
+ -----------
355
+ @ollama(
356
+ models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
357
+ backend='local'
358
+ )
359
+
360
+ Valid backend options
361
+ ---------------------
362
+ - 'local': Run as a separate process on the local task machine.
363
+ - (TODO) 'managed': Outerbounds hosts and selects compute provider.
364
+ - (TODO) 'remote': Spin up separate instance to serve Ollama models.
365
+
366
+ Valid model options
367
+ ----------------
368
+ - 'llama3.2'
369
+ - 'llama3.3'
370
+ - any model here https://ollama.com/search
787
371
 
788
372
 
789
373
  Parameters
790
374
  ----------
791
- gpu : int
792
- Number of GPUs to use.
793
- gpu_type : str
794
- Type of Nvidia GPU to use.
375
+ models: list[Ollama]
376
+ List of Ollama containers running models in sidecars.
377
+ backend: str
378
+ Determines where and how to run the Ollama process.
379
+ """
380
+ ...
381
+
382
+ @typing.overload
383
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
384
+ """
385
+ Decorator prototype for all step decorators. This function gets specialized
386
+ and imported for all decorators types by _import_plugin_decorators().
387
+ """
388
+ ...
389
+
390
+ @typing.overload
391
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
392
+ ...
393
+
394
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
395
+ """
396
+ Decorator prototype for all step decorators. This function gets specialized
397
+ and imported for all decorators types by _import_plugin_decorators().
398
+ """
399
+ ...
400
+
401
+ def nim(*, models: "list[NIM]", backend: 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]]]:
402
+ """
403
+ This decorator is used to run NIM containers in Metaflow tasks as sidecars.
404
+
405
+ User code call
406
+ -----------
407
+ @nim(
408
+ models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
409
+ backend='managed'
410
+ )
411
+
412
+ Valid backend options
413
+ ---------------------
414
+ - 'managed': Outerbounds selects a compute provider based on the model.
415
+
416
+ Valid model options
417
+ ----------------
418
+ - 'meta/llama3-8b-instruct': 8B parameter model
419
+ - 'meta/llama3-70b-instruct': 70B parameter model
420
+ - any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
421
+
422
+
423
+ Parameters
424
+ ----------
425
+ models: list[NIM]
426
+ List of NIM containers running models in sidecars.
427
+ backend: str
428
+ Compute provider to run the NIM container.
795
429
  queue_timeout : int
796
430
  Time to keep the job in NVCF's queue.
797
431
  """
798
432
  ...
799
433
 
800
434
  @typing.overload
801
- def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> 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]]]:
435
+ 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]]]:
802
436
  """
803
- Specifies secrets to be retrieved and injected as environment variables prior to
804
- the execution of a step.
437
+ Enables checkpointing for a step.
438
+
805
439
 
806
440
 
807
441
  Parameters
808
442
  ----------
809
- sources : List[Union[str, Dict[str, Any]]], default: []
810
- List of secret specs, defining how the secrets are to be retrieved
443
+ load_policy : str, default: "fresh"
444
+ The policy for loading the checkpoint. The following policies are supported:
445
+ - "eager": Loads the the latest available checkpoint within the namespace.
446
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
447
+ will be loaded at the start of the task.
448
+ - "none": Do not load any checkpoint
449
+ - "fresh": Loads the lastest checkpoint created within the running Task.
450
+ This mode helps loading checkpoints across various retry attempts of the same task.
451
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
452
+ created within the task will be loaded when the task is retries execution on failure.
453
+
454
+ temp_dir_root : str, default: None
455
+ The root directory under which `current.checkpoint.directory` will be created.
811
456
  """
812
457
  ...
813
458
 
814
459
  @typing.overload
815
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
460
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
816
461
  ...
817
462
 
818
463
  @typing.overload
819
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
464
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
820
465
  ...
821
466
 
822
- def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
467
+ 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):
823
468
  """
824
- Specifies secrets to be retrieved and injected as environment variables prior to
825
- the execution of a step.
469
+ Enables checkpointing for a step.
470
+
826
471
 
827
472
 
828
473
  Parameters
829
474
  ----------
830
- sources : List[Union[str, Dict[str, Any]]], default: []
831
- List of secret specs, defining how the secrets are to be retrieved
475
+ load_policy : str, default: "fresh"
476
+ The policy for loading the checkpoint. The following policies are supported:
477
+ - "eager": Loads the the latest available checkpoint within the namespace.
478
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
479
+ will be loaded at the start of the task.
480
+ - "none": Do not load any checkpoint
481
+ - "fresh": Loads the lastest checkpoint created within the running Task.
482
+ This mode helps loading checkpoints across various retry attempts of the same task.
483
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
484
+ created within the task will be loaded when the task is retries execution on failure.
485
+
486
+ temp_dir_root : str, default: None
487
+ The root directory under which `current.checkpoint.directory` will be created.
832
488
  """
833
489
  ...
834
490
 
835
491
  @typing.overload
836
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
492
+ 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]]]:
837
493
  """
838
- Decorator prototype for all step decorators. This function gets specialized
839
- and imported for all decorators types by _import_plugin_decorators().
494
+ Specifies that the step will success under all circumstances.
495
+
496
+ The decorator will create an optional artifact, specified by `var`, which
497
+ contains the exception raised. You can use it to detect the presence
498
+ of errors, indicating that all happy-path artifacts produced by the step
499
+ are missing.
500
+
501
+
502
+ Parameters
503
+ ----------
504
+ var : str, optional, default None
505
+ Name of the artifact in which to store the caught exception.
506
+ If not specified, the exception is not stored.
507
+ print_exception : bool, default True
508
+ Determines whether or not the exception is printed to
509
+ stdout when caught.
840
510
  """
841
511
  ...
842
512
 
843
513
  @typing.overload
844
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
514
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
845
515
  ...
846
516
 
847
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
517
+ @typing.overload
518
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
519
+ ...
520
+
521
+ 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):
848
522
  """
849
- Decorator prototype for all step decorators. This function gets specialized
850
- and imported for all decorators types by _import_plugin_decorators().
523
+ Specifies that the step will success under all circumstances.
524
+
525
+ The decorator will create an optional artifact, specified by `var`, which
526
+ contains the exception raised. You can use it to detect the presence
527
+ of errors, indicating that all happy-path artifacts produced by the step
528
+ are missing.
529
+
530
+
531
+ Parameters
532
+ ----------
533
+ var : str, optional, default None
534
+ Name of the artifact in which to store the caught exception.
535
+ If not specified, the exception is not stored.
536
+ print_exception : bool, default True
537
+ Determines whether or not the exception is printed to
538
+ stdout when caught.
539
+ """
540
+ ...
541
+
542
+ @typing.overload
543
+ 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]]]:
544
+ """
545
+ Specifies the number of times the task corresponding
546
+ to a step needs to be retried.
547
+
548
+ This decorator is useful for handling transient errors, such as networking issues.
549
+ If your task contains operations that can't be retried safely, e.g. database updates,
550
+ it is advisable to annotate it with `@retry(times=0)`.
551
+
552
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
553
+ decorator will execute a no-op task after all retries have been exhausted,
554
+ ensuring that the flow execution can continue.
555
+
556
+
557
+ Parameters
558
+ ----------
559
+ times : int, default 3
560
+ Number of times to retry this task.
561
+ minutes_between_retries : int, default 2
562
+ Number of minutes between retries.
563
+ """
564
+ ...
565
+
566
+ @typing.overload
567
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
568
+ ...
569
+
570
+ @typing.overload
571
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
572
+ ...
573
+
574
+ 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):
575
+ """
576
+ Specifies the number of times the task corresponding
577
+ to a step needs to be retried.
578
+
579
+ This decorator is useful for handling transient errors, such as networking issues.
580
+ If your task contains operations that can't be retried safely, e.g. database updates,
581
+ it is advisable to annotate it with `@retry(times=0)`.
582
+
583
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
584
+ decorator will execute a no-op task after all retries have been exhausted,
585
+ ensuring that the flow execution can continue.
586
+
587
+
588
+ Parameters
589
+ ----------
590
+ times : int, default 3
591
+ Number of times to retry this task.
592
+ minutes_between_retries : int, default 2
593
+ Number of minutes between retries.
594
+ """
595
+ ...
596
+
597
+ @typing.overload
598
+ 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]]]:
599
+ """
600
+ Creates a human-readable report, a Metaflow Card, after this step completes.
601
+
602
+ Note that you may add multiple `@card` decorators in a step with different parameters.
603
+
604
+
605
+ Parameters
606
+ ----------
607
+ type : str, default 'default'
608
+ Card type.
609
+ id : str, optional, default None
610
+ If multiple cards are present, use this id to identify this card.
611
+ options : Dict[str, Any], default {}
612
+ Options passed to the card. The contents depend on the card type.
613
+ timeout : int, default 45
614
+ Interrupt reporting if it takes more than this many seconds.
615
+ """
616
+ ...
617
+
618
+ @typing.overload
619
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
620
+ ...
621
+
622
+ @typing.overload
623
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
624
+ ...
625
+
626
+ 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):
627
+ """
628
+ Creates a human-readable report, a Metaflow Card, after this step completes.
629
+
630
+ Note that you may add multiple `@card` decorators in a step with different parameters.
631
+
632
+
633
+ Parameters
634
+ ----------
635
+ type : str, default 'default'
636
+ Card type.
637
+ id : str, optional, default None
638
+ If multiple cards are present, use this id to identify this card.
639
+ options : Dict[str, Any], default {}
640
+ Options passed to the card. The contents depend on the card type.
641
+ timeout : int, default 45
642
+ Interrupt reporting if it takes more than this many seconds.
643
+ """
644
+ ...
645
+
646
+ @typing.overload
647
+ def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
648
+ """
649
+ Specifies the Conda environment for the step.
650
+
651
+ Information in this decorator will augment any
652
+ attributes set in the `@conda_base` flow-level decorator. Hence,
653
+ you can use `@conda_base` to set packages required by all
654
+ steps and use `@conda` to specify step-specific overrides.
655
+
656
+
657
+ Parameters
658
+ ----------
659
+ packages : Dict[str, str], default {}
660
+ Packages to use for this step. The key is the name of the package
661
+ and the value is the version to use.
662
+ libraries : Dict[str, str], default {}
663
+ Supported for backward compatibility. When used with packages, packages will take precedence.
664
+ python : str, optional, default None
665
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
666
+ that the version used will correspond to the version of the Python interpreter used to start the run.
667
+ disabled : bool, default False
668
+ If set to True, disables @conda.
669
+ """
670
+ ...
671
+
672
+ @typing.overload
673
+ def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
674
+ ...
675
+
676
+ @typing.overload
677
+ def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
678
+ ...
679
+
680
+ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
681
+ """
682
+ Specifies the Conda environment for the step.
683
+
684
+ Information in this decorator will augment any
685
+ attributes set in the `@conda_base` flow-level decorator. Hence,
686
+ you can use `@conda_base` to set packages required by all
687
+ steps and use `@conda` to specify step-specific overrides.
688
+
689
+
690
+ Parameters
691
+ ----------
692
+ packages : Dict[str, str], default {}
693
+ Packages to use for this step. The key is the name of the package
694
+ and the value is the version to use.
695
+ libraries : Dict[str, str], default {}
696
+ Supported for backward compatibility. When used with packages, packages will take precedence.
697
+ python : str, optional, default None
698
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
699
+ that the version used will correspond to the version of the Python interpreter used to start the run.
700
+ disabled : bool, default False
701
+ If set to True, disables @conda.
702
+ """
703
+ ...
704
+
705
+ @typing.overload
706
+ 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]]]:
707
+ """
708
+ Specifies a timeout for your step.
709
+
710
+ This decorator is useful if this step may hang indefinitely.
711
+
712
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
713
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
714
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
715
+
716
+ Note that all the values specified in parameters are added together so if you specify
717
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
718
+
719
+
720
+ Parameters
721
+ ----------
722
+ seconds : int, default 0
723
+ Number of seconds to wait prior to timing out.
724
+ minutes : int, default 0
725
+ Number of minutes to wait prior to timing out.
726
+ hours : int, default 0
727
+ Number of hours to wait prior to timing out.
728
+ """
729
+ ...
730
+
731
+ @typing.overload
732
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
733
+ ...
734
+
735
+ @typing.overload
736
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
737
+ ...
738
+
739
+ 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):
740
+ """
741
+ Specifies a timeout for your step.
742
+
743
+ This decorator is useful if this step may hang indefinitely.
744
+
745
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
746
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
747
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
748
+
749
+ Note that all the values specified in parameters are added together so if you specify
750
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
751
+
752
+
753
+ Parameters
754
+ ----------
755
+ seconds : int, default 0
756
+ Number of seconds to wait prior to timing out.
757
+ minutes : int, default 0
758
+ Number of minutes to wait prior to timing out.
759
+ hours : int, default 0
760
+ Number of hours to wait prior to timing out.
851
761
  """
852
762
  ...
853
763
 
@@ -930,6 +840,39 @@ def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None]
930
840
  """
931
841
  ...
932
842
 
843
+ @typing.overload
844
+ 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]]]:
845
+ """
846
+ Specifies environment variables to be set prior to the execution of a step.
847
+
848
+
849
+ Parameters
850
+ ----------
851
+ vars : Dict[str, str], default {}
852
+ Dictionary of environment variables to set.
853
+ """
854
+ ...
855
+
856
+ @typing.overload
857
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
858
+ ...
859
+
860
+ @typing.overload
861
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
862
+ ...
863
+
864
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
865
+ """
866
+ Specifies environment variables to be set prior to the execution of a step.
867
+
868
+
869
+ Parameters
870
+ ----------
871
+ vars : Dict[str, str], default {}
872
+ Dictionary of environment variables to set.
873
+ """
874
+ ...
875
+
933
876
  @typing.overload
934
877
  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]]]:
935
878
  """
@@ -982,95 +925,59 @@ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
982
925
  ...
983
926
 
984
927
  @typing.overload
985
- def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
928
+ 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]]]:
986
929
  """
987
- Specifies the event(s) that this flow depends on.
988
-
989
- ```
990
- @trigger(event='foo')
991
- ```
992
- or
993
- ```
994
- @trigger(events=['foo', 'bar'])
995
- ```
930
+ Enables loading / saving of models within a step.
996
931
 
997
- Additionally, you can specify the parameter mappings
998
- to map event payload to Metaflow parameters for the flow.
999
- ```
1000
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1001
- ```
1002
- or
1003
- ```
1004
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1005
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1006
- ```
1007
-
1008
- 'parameters' can also be a list of strings and tuples like so:
1009
- ```
1010
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1011
- ```
1012
- This is equivalent to:
1013
- ```
1014
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1015
- ```
1016
932
 
1017
933
 
1018
934
  Parameters
1019
935
  ----------
1020
- event : Union[str, Dict[str, Any]], optional, default None
1021
- Event dependency for this flow.
1022
- events : List[Union[str, Dict[str, Any]]], default []
1023
- Events dependency for this flow.
1024
- options : Dict[str, Any], default {}
1025
- Backend-specific configuration for tuning eventing behavior.
936
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
937
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
938
+ These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
939
+ - `current.checkpoint`
940
+ - `current.model`
941
+ - `current.huggingface_hub`
942
+
943
+ 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
944
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
945
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
946
+
947
+ temp_dir_root : str, default: None
948
+ The root directory under which `current.model.loaded` will store loaded models
1026
949
  """
1027
950
  ...
1028
951
 
1029
952
  @typing.overload
1030
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
953
+ def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1031
954
  ...
1032
955
 
1033
- def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
956
+ @typing.overload
957
+ def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
958
+ ...
959
+
960
+ 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):
1034
961
  """
1035
- Specifies the event(s) that this flow depends on.
1036
-
1037
- ```
1038
- @trigger(event='foo')
1039
- ```
1040
- or
1041
- ```
1042
- @trigger(events=['foo', 'bar'])
1043
- ```
1044
-
1045
- Additionally, you can specify the parameter mappings
1046
- to map event payload to Metaflow parameters for the flow.
1047
- ```
1048
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1049
- ```
1050
- or
1051
- ```
1052
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1053
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1054
- ```
962
+ Enables loading / saving of models within a step.
1055
963
 
1056
- 'parameters' can also be a list of strings and tuples like so:
1057
- ```
1058
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1059
- ```
1060
- This is equivalent to:
1061
- ```
1062
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1063
- ```
1064
964
 
1065
965
 
1066
966
  Parameters
1067
967
  ----------
1068
- event : Union[str, Dict[str, Any]], optional, default None
1069
- Event dependency for this flow.
1070
- events : List[Union[str, Dict[str, Any]]], default []
1071
- Events dependency for this flow.
1072
- options : Dict[str, Any], default {}
1073
- Backend-specific configuration for tuning eventing behavior.
968
+ load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
969
+ Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
970
+ These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
971
+ - `current.checkpoint`
972
+ - `current.model`
973
+ - `current.huggingface_hub`
974
+
975
+ 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
976
+ the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
977
+ If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
978
+
979
+ temp_dir_root : str, default: None
980
+ The root directory under which `current.model.loaded` will store loaded models
1074
981
  """
1075
982
  ...
1076
983
 
@@ -1109,171 +1016,6 @@ def project(*, name: str, branch: typing.Optional[str] = None, production: bool
1109
1016
  """
1110
1017
  ...
1111
1018
 
1112
- def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1113
- """
1114
- Allows setting external datastores to save data for the
1115
- `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1116
-
1117
- This decorator is useful when users wish to save data to a different datastore
1118
- than what is configured in Metaflow. This can be for variety of reasons:
1119
-
1120
- 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1121
- 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1122
- - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1123
- 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1124
- - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1125
-
1126
- Usage:
1127
- ----------
1128
-
1129
- - Using a custom IAM role to access the datastore.
1130
-
1131
- ```python
1132
- @with_artifact_store(
1133
- type="s3",
1134
- config=lambda: {
1135
- "root": "s3://my-bucket-foo/path/to/root",
1136
- "role_arn": ROLE,
1137
- },
1138
- )
1139
- class MyFlow(FlowSpec):
1140
-
1141
- @checkpoint
1142
- @step
1143
- def start(self):
1144
- with open("my_file.txt", "w") as f:
1145
- f.write("Hello, World!")
1146
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1147
- self.next(self.end)
1148
-
1149
- ```
1150
-
1151
- - Using credentials to access the s3-compatible datastore.
1152
-
1153
- ```python
1154
- @with_artifact_store(
1155
- type="s3",
1156
- config=lambda: {
1157
- "root": "s3://my-bucket-foo/path/to/root",
1158
- "client_params": {
1159
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1160
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1161
- },
1162
- },
1163
- )
1164
- class MyFlow(FlowSpec):
1165
-
1166
- @checkpoint
1167
- @step
1168
- def start(self):
1169
- with open("my_file.txt", "w") as f:
1170
- f.write("Hello, World!")
1171
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1172
- self.next(self.end)
1173
-
1174
- ```
1175
-
1176
- - Accessing objects stored in external datastores after task execution.
1177
-
1178
- ```python
1179
- run = Run("CheckpointsTestsFlow/8992")
1180
- with artifact_store_from(run=run, config={
1181
- "client_params": {
1182
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1183
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1184
- },
1185
- }):
1186
- with Checkpoint() as cp:
1187
- latest = cp.list(
1188
- task=run["start"].task
1189
- )[0]
1190
- print(latest)
1191
- cp.load(
1192
- latest,
1193
- "test-checkpoints"
1194
- )
1195
-
1196
- task = Task("TorchTuneFlow/8484/train/53673")
1197
- with artifact_store_from(run=run, config={
1198
- "client_params": {
1199
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1200
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1201
- },
1202
- }):
1203
- load_model(
1204
- task.data.model_ref,
1205
- "test-models"
1206
- )
1207
- ```
1208
- Parameters:
1209
- ----------
1210
-
1211
- type: str
1212
- The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1213
-
1214
- config: dict or Callable
1215
- Dictionary of configuration options for the datastore. The following keys are required:
1216
- - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1217
- - example: 's3://bucket-name/path/to/root'
1218
- - example: 'gs://bucket-name/path/to/root'
1219
- - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1220
- - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1221
- - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1222
- - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1223
- """
1224
- ...
1225
-
1226
- @typing.overload
1227
- 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]]:
1228
- """
1229
- Specifies the Conda environment for all steps of the flow.
1230
-
1231
- Use `@conda_base` to set common libraries required by all
1232
- steps and use `@conda` to specify step-specific additions.
1233
-
1234
-
1235
- Parameters
1236
- ----------
1237
- packages : Dict[str, str], default {}
1238
- Packages to use for this flow. The key is the name of the package
1239
- and the value is the version to use.
1240
- libraries : Dict[str, str], default {}
1241
- Supported for backward compatibility. When used with packages, packages will take precedence.
1242
- python : str, optional, default None
1243
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1244
- that the version used will correspond to the version of the Python interpreter used to start the run.
1245
- disabled : bool, default False
1246
- If set to True, disables Conda.
1247
- """
1248
- ...
1249
-
1250
- @typing.overload
1251
- def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1252
- ...
1253
-
1254
- 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):
1255
- """
1256
- Specifies the Conda environment for all steps of the flow.
1257
-
1258
- Use `@conda_base` to set common libraries required by all
1259
- steps and use `@conda` to specify step-specific additions.
1260
-
1261
-
1262
- Parameters
1263
- ----------
1264
- packages : Dict[str, str], default {}
1265
- Packages to use for this flow. The key is the name of the package
1266
- and the value is the version to use.
1267
- libraries : Dict[str, str], default {}
1268
- Supported for backward compatibility. When used with packages, packages will take precedence.
1269
- python : str, optional, default None
1270
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1271
- that the version used will correspond to the version of the Python interpreter used to start the run.
1272
- disabled : bool, default False
1273
- If set to True, disables Conda.
1274
- """
1275
- ...
1276
-
1277
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]]:
1278
1020
  """
1279
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)
@@ -1317,49 +1059,6 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
1317
1059
  """
1318
1060
  ...
1319
1061
 
1320
- 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]]:
1321
- """
1322
- 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.
1323
- 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.
1324
-
1325
-
1326
- Parameters
1327
- ----------
1328
- timeout : int
1329
- Time, in seconds before the task times out and fails. (Default: 3600)
1330
- poke_interval : int
1331
- Time in seconds that the job should wait in between each try. (Default: 60)
1332
- mode : str
1333
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1334
- exponential_backoff : bool
1335
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1336
- pool : str
1337
- the slot pool this task should run in,
1338
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1339
- soft_fail : bool
1340
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1341
- name : str
1342
- Name of the sensor on Airflow
1343
- description : str
1344
- Description of sensor in the Airflow UI
1345
- external_dag_id : str
1346
- The dag_id that contains the task you want to wait for.
1347
- external_task_ids : List[str]
1348
- The list of task_ids that you want to wait for.
1349
- If None (default value) the sensor waits for the DAG. (Default: None)
1350
- allowed_states : List[str]
1351
- Iterable of allowed states, (Default: ['success'])
1352
- failed_states : List[str]
1353
- Iterable of failed or dis-allowed states. (Default: None)
1354
- execution_delta : datetime.timedelta
1355
- time difference with the previous execution to look at,
1356
- the default is the same logical date as the current task or DAG. (Default: None)
1357
- check_existence: bool
1358
- Set to True to check if the external task exists or check if
1359
- the DAG to wait for exists. (Default: True)
1360
- """
1361
- ...
1362
-
1363
1062
  @typing.overload
1364
1063
  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]]:
1365
1064
  """
@@ -1461,6 +1160,57 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
1461
1160
  """
1462
1161
  ...
1463
1162
 
1163
+ @typing.overload
1164
+ 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]]:
1165
+ """
1166
+ Specifies the Conda environment for all steps of the flow.
1167
+
1168
+ Use `@conda_base` to set common libraries required by all
1169
+ steps and use `@conda` to specify step-specific additions.
1170
+
1171
+
1172
+ Parameters
1173
+ ----------
1174
+ packages : Dict[str, str], default {}
1175
+ Packages to use for this flow. The key is the name of the package
1176
+ and the value is the version to use.
1177
+ libraries : Dict[str, str], default {}
1178
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1179
+ python : str, optional, default None
1180
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1181
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1182
+ disabled : bool, default False
1183
+ If set to True, disables Conda.
1184
+ """
1185
+ ...
1186
+
1187
+ @typing.overload
1188
+ def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1189
+ ...
1190
+
1191
+ 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):
1192
+ """
1193
+ Specifies the Conda environment for all steps of the flow.
1194
+
1195
+ Use `@conda_base` to set common libraries required by all
1196
+ steps and use `@conda` to specify step-specific additions.
1197
+
1198
+
1199
+ Parameters
1200
+ ----------
1201
+ packages : Dict[str, str], default {}
1202
+ Packages to use for this flow. The key is the name of the package
1203
+ and the value is the version to use.
1204
+ libraries : Dict[str, str], default {}
1205
+ Supported for backward compatibility. When used with packages, packages will take precedence.
1206
+ python : str, optional, default None
1207
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1208
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1209
+ disabled : bool, default False
1210
+ If set to True, disables Conda.
1211
+ """
1212
+ ...
1213
+
1464
1214
  @typing.overload
1465
1215
  def schedule(*, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1466
1216
  """
@@ -1553,5 +1303,255 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
1553
1303
  """
1554
1304
  ...
1555
1305
 
1306
+ 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]]:
1307
+ """
1308
+ 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.
1309
+ 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.
1310
+
1311
+
1312
+ Parameters
1313
+ ----------
1314
+ timeout : int
1315
+ Time, in seconds before the task times out and fails. (Default: 3600)
1316
+ poke_interval : int
1317
+ Time in seconds that the job should wait in between each try. (Default: 60)
1318
+ mode : str
1319
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1320
+ exponential_backoff : bool
1321
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1322
+ pool : str
1323
+ the slot pool this task should run in,
1324
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1325
+ soft_fail : bool
1326
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1327
+ name : str
1328
+ Name of the sensor on Airflow
1329
+ description : str
1330
+ Description of sensor in the Airflow UI
1331
+ external_dag_id : str
1332
+ The dag_id that contains the task you want to wait for.
1333
+ external_task_ids : List[str]
1334
+ The list of task_ids that you want to wait for.
1335
+ If None (default value) the sensor waits for the DAG. (Default: None)
1336
+ allowed_states : List[str]
1337
+ Iterable of allowed states, (Default: ['success'])
1338
+ failed_states : List[str]
1339
+ Iterable of failed or dis-allowed states. (Default: None)
1340
+ execution_delta : datetime.timedelta
1341
+ time difference with the previous execution to look at,
1342
+ the default is the same logical date as the current task or DAG. (Default: None)
1343
+ check_existence: bool
1344
+ Set to True to check if the external task exists or check if
1345
+ the DAG to wait for exists. (Default: True)
1346
+ """
1347
+ ...
1348
+
1349
+ @typing.overload
1350
+ def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1351
+ """
1352
+ Specifies the event(s) that this flow depends on.
1353
+
1354
+ ```
1355
+ @trigger(event='foo')
1356
+ ```
1357
+ or
1358
+ ```
1359
+ @trigger(events=['foo', 'bar'])
1360
+ ```
1361
+
1362
+ Additionally, you can specify the parameter mappings
1363
+ to map event payload to Metaflow parameters for the flow.
1364
+ ```
1365
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1366
+ ```
1367
+ or
1368
+ ```
1369
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1370
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1371
+ ```
1372
+
1373
+ 'parameters' can also be a list of strings and tuples like so:
1374
+ ```
1375
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1376
+ ```
1377
+ This is equivalent to:
1378
+ ```
1379
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1380
+ ```
1381
+
1382
+
1383
+ Parameters
1384
+ ----------
1385
+ event : Union[str, Dict[str, Any]], optional, default None
1386
+ Event dependency for this flow.
1387
+ events : List[Union[str, Dict[str, Any]]], default []
1388
+ Events dependency for this flow.
1389
+ options : Dict[str, Any], default {}
1390
+ Backend-specific configuration for tuning eventing behavior.
1391
+ """
1392
+ ...
1393
+
1394
+ @typing.overload
1395
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1396
+ ...
1397
+
1398
+ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
1399
+ """
1400
+ Specifies the event(s) that this flow depends on.
1401
+
1402
+ ```
1403
+ @trigger(event='foo')
1404
+ ```
1405
+ or
1406
+ ```
1407
+ @trigger(events=['foo', 'bar'])
1408
+ ```
1409
+
1410
+ Additionally, you can specify the parameter mappings
1411
+ to map event payload to Metaflow parameters for the flow.
1412
+ ```
1413
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1414
+ ```
1415
+ or
1416
+ ```
1417
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1418
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1419
+ ```
1420
+
1421
+ 'parameters' can also be a list of strings and tuples like so:
1422
+ ```
1423
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1424
+ ```
1425
+ This is equivalent to:
1426
+ ```
1427
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1428
+ ```
1429
+
1430
+
1431
+ Parameters
1432
+ ----------
1433
+ event : Union[str, Dict[str, Any]], optional, default None
1434
+ Event dependency for this flow.
1435
+ events : List[Union[str, Dict[str, Any]]], default []
1436
+ Events dependency for this flow.
1437
+ options : Dict[str, Any], default {}
1438
+ Backend-specific configuration for tuning eventing behavior.
1439
+ """
1440
+ ...
1441
+
1442
+ def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1443
+ """
1444
+ Allows setting external datastores to save data for the
1445
+ `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1446
+
1447
+ This decorator is useful when users wish to save data to a different datastore
1448
+ than what is configured in Metaflow. This can be for variety of reasons:
1449
+
1450
+ 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1451
+ 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1452
+ - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1453
+ 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1454
+ - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1455
+
1456
+ Usage:
1457
+ ----------
1458
+
1459
+ - Using a custom IAM role to access the datastore.
1460
+
1461
+ ```python
1462
+ @with_artifact_store(
1463
+ type="s3",
1464
+ config=lambda: {
1465
+ "root": "s3://my-bucket-foo/path/to/root",
1466
+ "role_arn": ROLE,
1467
+ },
1468
+ )
1469
+ class MyFlow(FlowSpec):
1470
+
1471
+ @checkpoint
1472
+ @step
1473
+ def start(self):
1474
+ with open("my_file.txt", "w") as f:
1475
+ f.write("Hello, World!")
1476
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1477
+ self.next(self.end)
1478
+
1479
+ ```
1480
+
1481
+ - Using credentials to access the s3-compatible datastore.
1482
+
1483
+ ```python
1484
+ @with_artifact_store(
1485
+ type="s3",
1486
+ config=lambda: {
1487
+ "root": "s3://my-bucket-foo/path/to/root",
1488
+ "client_params": {
1489
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1490
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1491
+ },
1492
+ },
1493
+ )
1494
+ class MyFlow(FlowSpec):
1495
+
1496
+ @checkpoint
1497
+ @step
1498
+ def start(self):
1499
+ with open("my_file.txt", "w") as f:
1500
+ f.write("Hello, World!")
1501
+ self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1502
+ self.next(self.end)
1503
+
1504
+ ```
1505
+
1506
+ - Accessing objects stored in external datastores after task execution.
1507
+
1508
+ ```python
1509
+ run = Run("CheckpointsTestsFlow/8992")
1510
+ with artifact_store_from(run=run, config={
1511
+ "client_params": {
1512
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1513
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1514
+ },
1515
+ }):
1516
+ with Checkpoint() as cp:
1517
+ latest = cp.list(
1518
+ task=run["start"].task
1519
+ )[0]
1520
+ print(latest)
1521
+ cp.load(
1522
+ latest,
1523
+ "test-checkpoints"
1524
+ )
1525
+
1526
+ task = Task("TorchTuneFlow/8484/train/53673")
1527
+ with artifact_store_from(run=run, config={
1528
+ "client_params": {
1529
+ "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1530
+ "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1531
+ },
1532
+ }):
1533
+ load_model(
1534
+ task.data.model_ref,
1535
+ "test-models"
1536
+ )
1537
+ ```
1538
+ Parameters:
1539
+ ----------
1540
+
1541
+ type: str
1542
+ The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1543
+
1544
+ config: dict or Callable
1545
+ Dictionary of configuration options for the datastore. The following keys are required:
1546
+ - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1547
+ - example: 's3://bucket-name/path/to/root'
1548
+ - example: 'gs://bucket-name/path/to/root'
1549
+ - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1550
+ - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1551
+ - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1552
+ - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1553
+ """
1554
+ ...
1555
+
1556
1556
  pkg_name: str
1557
1557