ob-metaflow-stubs 6.0.3.159__py2.py3-none-any.whl → 6.0.3.161__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 +761 -750
  2. metaflow-stubs/cards.pyi +2 -2
  3. metaflow-stubs/cli.pyi +4 -2
  4. metaflow-stubs/cli_components/__init__.pyi +2 -2
  5. metaflow-stubs/cli_components/utils.pyi +2 -2
  6. metaflow-stubs/client/__init__.pyi +2 -2
  7. metaflow-stubs/client/core.pyi +5 -5
  8. metaflow-stubs/client/filecache.pyi +2 -2
  9. metaflow-stubs/events.pyi +3 -3
  10. metaflow-stubs/exception.pyi +2 -2
  11. metaflow-stubs/flowspec.pyi +6 -6
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +4 -4
  14. metaflow-stubs/info_file.pyi +2 -2
  15. metaflow-stubs/metadata_provider/__init__.pyi +2 -2
  16. metaflow-stubs/metadata_provider/heartbeat.pyi +2 -2
  17. metaflow-stubs/metadata_provider/metadata.pyi +3 -3
  18. metaflow-stubs/metadata_provider/util.pyi +2 -2
  19. metaflow-stubs/metaflow_config.pyi +4 -2
  20. metaflow-stubs/metaflow_current.pyi +38 -38
  21. metaflow-stubs/metaflow_git.pyi +26 -0
  22. metaflow-stubs/mf_extensions/__init__.pyi +2 -2
  23. metaflow-stubs/mf_extensions/obcheckpoint/__init__.pyi +2 -2
  24. metaflow-stubs/mf_extensions/obcheckpoint/plugins/__init__.pyi +2 -2
  25. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/__init__.pyi +2 -2
  26. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/__init__.pyi +2 -2
  27. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/async_cards.pyi +2 -2
  28. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/deco_injection_mixin.pyi +2 -2
  29. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/card_utils/extra_components.pyi +4 -4
  30. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/__init__.pyi +2 -2
  31. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/__init__.pyi +2 -2
  32. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/checkpoint_lister.pyi +3 -3
  33. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/cards/lineage_card.pyi +2 -2
  34. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/checkpoint_storage.pyi +4 -4
  35. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/constructors.pyi +2 -2
  36. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/core.pyi +3 -3
  37. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/decorator.pyi +4 -4
  38. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/exceptions.pyi +2 -2
  39. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/final_api.pyi +2 -2
  40. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/checkpoints/lineage.pyi +2 -2
  41. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/__init__.pyi +2 -2
  42. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/context.pyi +3 -3
  43. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/core.pyi +2 -2
  44. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/decorator.pyi +2 -2
  45. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/exceptions.pyi +2 -2
  46. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/task_utils.pyi +4 -4
  47. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastore/utils.pyi +2 -2
  48. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/datastructures.pyi +3 -3
  49. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/exceptions.pyi +2 -2
  50. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/__init__.pyi +2 -2
  51. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/hf_hub/decorator.pyi +2 -2
  52. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/__init__.pyi +2 -2
  53. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/core.pyi +3 -3
  54. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/exceptions.pyi +2 -2
  55. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/modeling_utils/model_storage.pyi +4 -4
  56. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/__init__.pyi +2 -2
  57. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/flowspec_utils.pyi +2 -2
  58. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/general.pyi +2 -2
  59. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/identity_utils.pyi +3 -3
  60. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/__init__.pyi +2 -2
  61. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/base.pyi +2 -2
  62. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/serialization_handler/tar.pyi +3 -3
  63. metaflow-stubs/mf_extensions/obcheckpoint/plugins/machine_learning_utilities/utils/tar_utils.pyi +3 -3
  64. metaflow-stubs/mf_extensions/outerbounds/__init__.pyi +2 -2
  65. metaflow-stubs/mf_extensions/outerbounds/plugins/__init__.pyi +2 -2
  66. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/__init__.pyi +2 -2
  67. metaflow-stubs/mf_extensions/outerbounds/plugins/card_utilities/injector.pyi +2 -2
  68. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/__init__.pyi +6 -0
  69. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/coreweave.pyi +58 -0
  70. metaflow-stubs/mf_extensions/outerbounds/plugins/checkpoint_datastores/nebius.pyi +64 -0
  71. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/__init__.pyi +2 -2
  72. metaflow-stubs/mf_extensions/outerbounds/plugins/ollama/ollama.pyi +2 -2
  73. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/__init__.pyi +2 -2
  74. metaflow-stubs/mf_extensions/outerbounds/plugins/snowflake/snowflake.pyi +2 -2
  75. metaflow-stubs/mf_extensions/outerbounds/profilers/__init__.pyi +2 -2
  76. metaflow-stubs/mf_extensions/outerbounds/profilers/gpu.pyi +2 -2
  77. metaflow-stubs/mf_extensions/outerbounds/remote_config.pyi +2 -2
  78. metaflow-stubs/mf_extensions/outerbounds/toplevel/__init__.pyi +2 -2
  79. metaflow-stubs/mf_extensions/outerbounds/toplevel/global_aliases_for_metaflow_package.pyi +4 -2
  80. metaflow-stubs/multicore_utils.pyi +2 -2
  81. metaflow-stubs/parameters.pyi +4 -4
  82. metaflow-stubs/plugins/__init__.pyi +14 -13
  83. metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
  84. metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
  85. metaflow-stubs/plugins/airflow/exception.pyi +2 -2
  86. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
  87. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
  88. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
  89. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
  90. metaflow-stubs/plugins/argo/__init__.pyi +2 -2
  91. metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
  92. metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
  93. metaflow-stubs/plugins/argo/argo_workflows.pyi +3 -3
  94. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
  95. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +5 -5
  96. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +4 -4
  97. metaflow-stubs/plugins/aws/__init__.pyi +2 -2
  98. metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
  99. metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
  100. metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
  101. metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
  102. metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
  103. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +2 -2
  104. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
  105. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +4 -4
  106. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
  107. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
  108. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
  109. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
  110. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
  111. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +4 -4
  112. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +3 -3
  113. metaflow-stubs/plugins/azure/__init__.pyi +2 -2
  114. metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
  115. metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
  116. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +4 -4
  117. metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
  118. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
  119. metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
  120. metaflow-stubs/plugins/cards/__init__.pyi +2 -2
  121. metaflow-stubs/plugins/cards/card_client.pyi +3 -3
  122. metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
  123. metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
  124. metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
  125. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
  126. metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
  127. metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
  128. metaflow-stubs/plugins/cards/card_modules/components.pyi +4 -4
  129. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
  130. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
  131. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
  132. metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
  133. metaflow-stubs/plugins/cards/component_serializer.pyi +2 -2
  134. metaflow-stubs/plugins/cards/exception.pyi +2 -2
  135. metaflow-stubs/plugins/catch_decorator.pyi +2 -2
  136. metaflow-stubs/plugins/datatools/__init__.pyi +2 -2
  137. metaflow-stubs/plugins/datatools/local.pyi +2 -2
  138. metaflow-stubs/plugins/datatools/s3/__init__.pyi +2 -2
  139. metaflow-stubs/plugins/datatools/s3/s3.pyi +9 -4
  140. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
  141. metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
  142. metaflow-stubs/plugins/debug_logger.pyi +2 -2
  143. metaflow-stubs/plugins/debug_monitor.pyi +2 -2
  144. metaflow-stubs/plugins/environment_decorator.pyi +2 -2
  145. metaflow-stubs/plugins/events_decorator.pyi +2 -2
  146. metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
  147. metaflow-stubs/plugins/frameworks/pytorch.pyi +2 -2
  148. metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
  149. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +4 -4
  150. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
  151. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
  152. metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
  153. metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
  154. metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
  155. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +3 -3
  156. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +4 -4
  157. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
  158. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +10 -2
  159. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
  160. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +2 -2
  161. metaflow-stubs/plugins/ollama/__init__.pyi +2 -2
  162. metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
  163. metaflow-stubs/plugins/perimeters.pyi +2 -2
  164. metaflow-stubs/plugins/project_decorator.pyi +2 -2
  165. metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
  166. metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
  167. metaflow-stubs/plugins/pypi/conda_environment.pyi +4 -4
  168. metaflow-stubs/plugins/pypi/parsers.pyi +2 -2
  169. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
  170. metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
  171. metaflow-stubs/plugins/pypi/utils.pyi +2 -2
  172. metaflow-stubs/plugins/resources_decorator.pyi +2 -2
  173. metaflow-stubs/plugins/retry_decorator.pyi +2 -2
  174. metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
  175. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +4 -4
  176. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
  177. metaflow-stubs/plugins/snowflake/__init__.pyi +2 -2
  178. metaflow-stubs/plugins/storage_executor.pyi +2 -2
  179. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
  180. metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
  181. metaflow-stubs/plugins/uv/__init__.pyi +11 -0
  182. metaflow-stubs/plugins/uv/uv_environment.pyi +36 -0
  183. metaflow-stubs/profilers/__init__.pyi +2 -2
  184. metaflow-stubs/pylint_wrapper.pyi +2 -2
  185. metaflow-stubs/runner/__init__.pyi +2 -2
  186. metaflow-stubs/runner/deployer.pyi +30 -30
  187. metaflow-stubs/runner/deployer_impl.pyi +4 -4
  188. metaflow-stubs/runner/metaflow_runner.pyi +6 -6
  189. metaflow-stubs/runner/nbdeploy.pyi +2 -2
  190. metaflow-stubs/runner/nbrun.pyi +2 -2
  191. metaflow-stubs/runner/subprocess_manager.pyi +2 -2
  192. metaflow-stubs/runner/utils.pyi +3 -3
  193. metaflow-stubs/system/__init__.pyi +2 -2
  194. metaflow-stubs/system/system_logger.pyi +3 -3
  195. metaflow-stubs/system/system_monitor.pyi +2 -2
  196. metaflow-stubs/tagging_util.pyi +2 -2
  197. metaflow-stubs/tuple_util.pyi +2 -2
  198. metaflow-stubs/user_configs/__init__.pyi +2 -2
  199. metaflow-stubs/user_configs/config_decorators.pyi +5 -5
  200. metaflow-stubs/user_configs/config_options.pyi +3 -3
  201. metaflow-stubs/user_configs/config_parameters.pyi +6 -6
  202. {ob_metaflow_stubs-6.0.3.159.dist-info → ob_metaflow_stubs-6.0.3.161.dist-info}/METADATA +1 -1
  203. ob_metaflow_stubs-6.0.3.161.dist-info/RECORD +206 -0
  204. ob_metaflow_stubs-6.0.3.159.dist-info/RECORD +0 -200
  205. {ob_metaflow_stubs-6.0.3.159.dist-info → ob_metaflow_stubs-6.0.3.161.dist-info}/WHEEL +0 -0
  206. {ob_metaflow_stubs-6.0.3.159.dist-info → ob_metaflow_stubs-6.0.3.161.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
- # MF version: 2.15.7.2+obcheckpoint(0.2.1);ob(v1) #
4
- # Generated on 2025-04-18T04:20:36.937065 #
3
+ # MF version: 2.15.10.1+obcheckpoint(0.2.1);ob(v1) #
4
+ # Generated on 2025-05-05T20:26:16.823529 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
@@ -35,17 +35,18 @@ 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 cards as cards
39
38
  from . import events as events
40
39
  from . import tuple_util as tuple_util
40
+ from . import cards as cards
41
+ from . import metaflow_git as metaflow_git
41
42
  from . import runner as runner
42
43
  from . import plugins as plugins
43
44
  from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import S3 as S3
44
45
  from . import includefile as includefile
45
46
  from .includefile import IncludeFile as IncludeFile
47
+ from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
46
48
  from .plugins.pypi.parsers import conda_environment_yml_parser as conda_environment_yml_parser
47
49
  from .plugins.pypi.parsers import pyproject_toml_parser as pyproject_toml_parser
48
- from .plugins.pypi.parsers import requirements_txt_parser as requirements_txt_parser
49
50
  from . import client as client
50
51
  from .client.core import namespace as namespace
51
52
  from .client.core import get_namespace as get_namespace
@@ -69,6 +70,8 @@ from .mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructur
69
70
  from .mf_extensions.obcheckpoint.plugins.machine_learning_utilities.datastore.context import artifact_store_from as artifact_store_from
70
71
  from .mf_extensions.outerbounds.toplevel.global_aliases_for_metaflow_package import get_aws_client as get_aws_client
71
72
  from .mf_extensions.outerbounds.plugins.snowflake.snowflake import Snowflake as Snowflake
73
+ from .mf_extensions.outerbounds.plugins.checkpoint_datastores.nebius import nebius_checkpoints as nebius_checkpoints
74
+ from .mf_extensions.outerbounds.plugins.checkpoint_datastores.coreweave import coreweave_checkpoints as coreweave_checkpoints
72
75
  from . import cli_components as cli_components
73
76
  from . import system as system
74
77
  from . import pylint_wrapper as pylint_wrapper
@@ -150,301 +153,267 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
150
153
  """
151
154
  ...
152
155
 
153
- 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]]]:
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]]]:
154
158
  """
155
- Specifies that this step is used to deploy an instance of the app.
156
- Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
159
+ Enables loading / saving of models within a step.
160
+
157
161
 
158
162
 
159
163
  Parameters
160
164
  ----------
161
- app_port : int
162
- Number of GPUs to use.
163
- app_name : str
164
- Name of the app to deploy.
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
165
178
  """
166
179
  ...
167
180
 
168
- 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]]]:
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):
169
190
  """
170
- This decorator is used to run Ollama APIs as Metaflow task sidecars.
171
-
172
- User code call
173
- -----------
174
- @ollama(
175
- models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
176
- backend='local'
177
- )
178
-
179
- Valid backend options
180
- ---------------------
181
- - 'local': Run as a separate process on the local task machine.
182
- - (TODO) 'managed': Outerbounds hosts and selects compute provider.
183
- - (TODO) 'remote': Spin up separate instance to serve Ollama models.
191
+ Enables loading / saving of models within a step.
184
192
 
185
- Valid model options
186
- ----------------
187
- - 'llama3.2'
188
- - 'llama3.3'
189
- - any model here https://ollama.com/search
190
193
 
191
194
 
192
195
  Parameters
193
196
  ----------
194
- models: list[Ollama]
195
- List of Ollama containers running models in sidecars.
196
- backend: str
197
- Determines where and how to run the Ollama process.
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
198
210
  """
199
211
  ...
200
212
 
201
213
  @typing.overload
202
- 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]]]:
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]]]:
203
215
  """
204
- Specifies secrets to be retrieved and injected as environment variables prior to
205
- the execution of a step.
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.
206
226
 
207
227
 
208
228
  Parameters
209
229
  ----------
210
- sources : List[Union[str, Dict[str, Any]]], default: []
211
- List of secret specs, defining how the secrets are to be retrieved
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.
212
236
  """
213
237
  ...
214
238
 
215
239
  @typing.overload
216
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
240
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
217
241
  ...
218
242
 
219
243
  @typing.overload
220
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
244
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
221
245
  ...
222
246
 
223
- 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]]] = []):
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):
224
248
  """
225
- Specifies secrets to be retrieved and injected as environment variables prior to
226
- the execution of a step.
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.
227
259
 
228
260
 
229
261
  Parameters
230
262
  ----------
231
- sources : List[Union[str, Dict[str, Any]]], default: []
232
- List of secret specs, defining how the secrets are to be retrieved
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
+ 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
+ """
274
+ Specifies that this step is used to deploy an instance of the app.
275
+ Requires that self.app_name, self.app_port, self.entrypoint and self.deployDir is set.
276
+
277
+
278
+ Parameters
279
+ ----------
280
+ app_port : int
281
+ Number of GPUs to use.
282
+ app_name : str
283
+ Name of the app to deploy.
233
284
  """
234
285
  ...
235
286
 
236
287
  @typing.overload
237
- 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]]]:
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]]]:
238
289
  """
239
- Specifies the Conda environment for the step.
290
+ Specifies that the step will success under all circumstances.
240
291
 
241
- Information in this decorator will augment any
242
- attributes set in the `@conda_base` flow-level decorator. Hence,
243
- you can use `@conda_base` to set packages required by all
244
- steps and use `@conda` to specify step-specific overrides.
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.
245
296
 
246
297
 
247
298
  Parameters
248
299
  ----------
249
- packages : Dict[str, str], default {}
250
- Packages to use for this step. The key is the name of the package
251
- and the value is the version to use.
252
- libraries : Dict[str, str], default {}
253
- Supported for backward compatibility. When used with packages, packages will take precedence.
254
- python : str, optional, default None
255
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
256
- that the version used will correspond to the version of the Python interpreter used to start the run.
257
- disabled : bool, default False
258
- If set to True, disables @conda.
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.
259
306
  """
260
307
  ...
261
308
 
262
309
  @typing.overload
263
- def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
310
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
264
311
  ...
265
312
 
266
313
  @typing.overload
267
- def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
314
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
268
315
  ...
269
316
 
270
- 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):
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):
271
318
  """
272
- Specifies the Conda environment for the step.
319
+ Specifies that the step will success under all circumstances.
273
320
 
274
- Information in this decorator will augment any
275
- attributes set in the `@conda_base` flow-level decorator. Hence,
276
- you can use `@conda_base` to set packages required by all
277
- steps and use `@conda` to specify step-specific overrides.
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.
278
325
 
279
326
 
280
327
  Parameters
281
328
  ----------
282
- packages : Dict[str, str], default {}
283
- Packages to use for this step. The key is the name of the package
284
- and the value is the version to use.
285
- libraries : Dict[str, str], default {}
286
- Supported for backward compatibility. When used with packages, packages will take precedence.
287
- python : str, optional, default None
288
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
289
- that the version used will correspond to the version of the Python interpreter used to start the run.
290
- disabled : bool, default False
291
- If set to True, disables @conda.
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.
292
335
  """
293
336
  ...
294
337
 
295
- 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') -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
338
+ def 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]]]:
296
339
  """
297
- Specifies that this step should execute on Kubernetes.
340
+ Decorator that helps cache, version and store models/datasets from huggingface hub.
298
341
 
299
342
 
300
343
  Parameters
301
344
  ----------
302
- cpu : int, default 1
303
- Number of CPUs required for this step. If `@resources` is
304
- also present, the maximum value from all decorators is used.
305
- memory : int, default 4096
306
- Memory size (in MB) required for this step. If
307
- `@resources` is also present, the maximum value from all decorators is
308
- used.
309
- disk : int, default 10240
310
- Disk size (in MB) required for this step. If
311
- `@resources` is also present, the maximum value from all decorators is
312
- used.
313
- image : str, optional, default None
314
- Docker image to use when launching on Kubernetes. If not specified, and
315
- METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
316
- not, a default Docker image mapping to the current version of Python is used.
317
- image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
318
- If given, the imagePullPolicy to be applied to the Docker image of the step.
319
- service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
320
- Kubernetes service account to use when launching pod in Kubernetes.
321
- secrets : List[str], optional, default None
322
- Kubernetes secrets to use when launching pod in Kubernetes. These
323
- secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
324
- in Metaflow configuration.
325
- node_selector: Union[Dict[str,str], str], optional, default None
326
- Kubernetes node selector(s) to apply to the pod running the task.
327
- Can be passed in as a comma separated string of values e.g.
328
- 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
329
- {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
330
- namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
331
- Kubernetes namespace to use when launching pod in Kubernetes.
332
- gpu : int, optional, default None
333
- Number of GPUs required for this step. A value of zero implies that
334
- the scheduled node should not have GPUs.
335
- gpu_vendor : str, default KUBERNETES_GPU_VENDOR
336
- The vendor of the GPUs to be used for this step.
337
- tolerations : List[str], default []
338
- The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
339
- Kubernetes tolerations to use when launching pod in Kubernetes.
340
- labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
341
- Kubernetes labels to use when launching pod in Kubernetes.
342
- annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
343
- Kubernetes annotations to use when launching pod in Kubernetes.
344
- use_tmpfs : bool, default False
345
- This enables an explicit tmpfs mount for this step.
346
- tmpfs_tempdir : bool, default True
347
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
348
- tmpfs_size : int, optional, default: None
349
- The value for the size (in MiB) of the tmpfs mount for this step.
350
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
351
- memory allocated for this step.
352
- tmpfs_path : str, optional, default /metaflow_temp
353
- Path to tmpfs mount for this step.
354
- persistent_volume_claims : Dict[str, str], optional, default None
355
- A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
356
- volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
357
- shared_memory: int, optional
358
- Shared memory size (in MiB) required for this step
359
- port: int, optional
360
- Port number to specify in the Kubernetes job object
361
- compute_pool : str, optional, default None
362
- Compute pool to be used for for this step.
363
- If not specified, any accessible compute pool within the perimeter is used.
364
- hostname_resolution_timeout: int, default 10 * 60
365
- Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
366
- Only applicable when @parallel is used.
367
- qos: str, default: Burstable
368
- Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
345
+ temp_dir_root : str, optional
346
+ The root directory that will hold the temporary directory where objects will be downloaded.
347
+
348
+ load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
349
+ The list of repos (models/datasets) to load.
350
+
351
+ Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
352
+
353
+ - If repo (model/dataset) is not found in the datastore:
354
+ - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
355
+ - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
356
+ - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
357
+
358
+ - If repo is found in the datastore:
359
+ - Loads it directly from datastore to local path (can be temporary directory or specified path)
369
360
  """
370
361
  ...
371
362
 
372
363
  @typing.overload
373
- def resources(*, cpu: int = 1, gpu: typing.Optional[int] = None, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
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]]]:
374
365
  """
375
- Specifies the resources needed when executing this step.
376
-
377
- Use `@resources` to specify the resource requirements
378
- independently of the specific compute layer (`@batch`, `@kubernetes`).
366
+ Enables checkpointing for a step.
379
367
 
380
- You can choose the compute layer on the command line by executing e.g.
381
- ```
382
- python myflow.py run --with batch
383
- ```
384
- or
385
- ```
386
- python myflow.py run --with kubernetes
387
- ```
388
- which executes the flow on the desired system using the
389
- requirements specified in `@resources`.
390
368
 
391
369
 
392
370
  Parameters
393
371
  ----------
394
- cpu : int, default 1
395
- Number of CPUs required for this step.
396
- gpu : int, optional, default None
397
- Number of GPUs required for this step.
398
- disk : int, optional, default None
399
- Disk size (in MB) required for this step. Only applies on Kubernetes.
400
- memory : int, default 4096
401
- Memory size (in MB) required for this step.
402
- shared_memory : int, optional, default None
403
- The value for the size (in MiB) of the /dev/shm volume for this step.
404
- This parameter maps to the `--shm-size` option in Docker.
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.
405
385
  """
406
386
  ...
407
387
 
408
388
  @typing.overload
409
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
389
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
410
390
  ...
411
391
 
412
392
  @typing.overload
413
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
393
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
414
394
  ...
415
395
 
416
- def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: typing.Optional[int] = None, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None):
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):
417
397
  """
418
- Specifies the resources needed when executing this step.
419
-
420
- Use `@resources` to specify the resource requirements
421
- independently of the specific compute layer (`@batch`, `@kubernetes`).
398
+ Enables checkpointing for a step.
422
399
 
423
- You can choose the compute layer on the command line by executing e.g.
424
- ```
425
- python myflow.py run --with batch
426
- ```
427
- or
428
- ```
429
- python myflow.py run --with kubernetes
430
- ```
431
- which executes the flow on the desired system using the
432
- requirements specified in `@resources`.
433
400
 
434
401
 
435
402
  Parameters
436
403
  ----------
437
- cpu : int, default 1
438
- Number of CPUs required for this step.
439
- gpu : int, optional, default None
440
- Number of GPUs required for this step.
441
- disk : int, optional, default None
442
- Disk size (in MB) required for this step. Only applies on Kubernetes.
443
- memory : int, default 4096
444
- Memory size (in MB) required for this step.
445
- shared_memory : int, optional, default None
446
- The value for the size (in MiB) of the /dev/shm volume for this step.
447
- This parameter maps to the `--shm-size` option in Docker.
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.
448
417
  """
449
418
  ...
450
419
 
@@ -537,169 +506,278 @@ def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
537
506
  ...
538
507
 
539
508
  @typing.overload
540
- 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]]]:
509
+ def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
541
510
  """
542
- Specifies a timeout for your step.
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.
543
528
 
544
- This decorator is useful if this step may hang indefinitely.
529
+ User code call
530
+ -----------
531
+ @nim(
532
+ models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
533
+ backend='managed'
534
+ )
545
535
 
546
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
547
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
548
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
536
+ Valid backend options
537
+ ---------------------
538
+ - 'managed': Outerbounds selects a compute provider based on the model.
549
539
 
550
- Note that all the values specified in parameters are added together so if you specify
551
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
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
552
545
 
553
546
 
554
547
  Parameters
555
548
  ----------
556
- seconds : int, default 0
557
- Number of seconds to wait prior to timing out.
558
- minutes : int, default 0
559
- Number of minutes to wait prior to timing out.
560
- hours : int, default 0
561
- Number of hours to wait prior to timing out.
549
+ models: list[NIM]
550
+ List of NIM containers running models in sidecars.
551
+ backend: str
552
+ Compute provider to run the NIM container.
553
+ queue_timeout : int
554
+ Time to keep the job in NVCF's queue.
562
555
  """
563
556
  ...
564
557
 
565
- @typing.overload
566
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
567
- ...
568
-
569
- @typing.overload
570
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
571
- ...
572
-
573
- 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):
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]]]:
574
559
  """
575
- Specifies a timeout for your step.
560
+ This decorator is used to run Ollama APIs as Metaflow task sidecars.
576
561
 
577
- This decorator is useful if this step may hang indefinitely.
562
+ User code call
563
+ -----------
564
+ @ollama(
565
+ models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
566
+ backend='local'
567
+ )
578
568
 
579
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
580
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
581
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
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.
582
574
 
583
- Note that all the values specified in parameters are added together so if you specify
584
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
575
+ Valid model options
576
+ ----------------
577
+ - 'llama3.2'
578
+ - 'llama3.3'
579
+ - any model here https://ollama.com/search
585
580
 
586
581
 
587
582
  Parameters
588
583
  ----------
589
- seconds : int, default 0
590
- Number of seconds to wait prior to timing out.
591
- minutes : int, default 0
592
- Number of minutes to wait prior to timing out.
593
- hours : int, default 0
594
- Number of hours to wait prior to timing out.
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.
595
588
  """
596
589
  ...
597
590
 
598
591
  @typing.overload
599
- 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]]]:
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]]]:
600
593
  """
601
- Specifies that the step will success under all circumstances.
594
+ Creates a human-readable report, a Metaflow Card, after this step completes.
602
595
 
603
- The decorator will create an optional artifact, specified by `var`, which
604
- contains the exception raised. You can use it to detect the presence
605
- of errors, indicating that all happy-path artifacts produced by the step
606
- are missing.
596
+ Note that you may add multiple `@card` decorators in a step with different parameters.
607
597
 
608
598
 
609
599
  Parameters
610
600
  ----------
611
- var : str, optional, default None
612
- Name of the artifact in which to store the caught exception.
613
- If not specified, the exception is not stored.
614
- print_exception : bool, default True
615
- Determines whether or not the exception is printed to
616
- stdout when caught.
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.
617
609
  """
618
610
  ...
619
611
 
620
612
  @typing.overload
621
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
613
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
622
614
  ...
623
615
 
624
616
  @typing.overload
625
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
617
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
626
618
  ...
627
619
 
628
- 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):
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):
629
621
  """
630
- Specifies that the step will success under all circumstances.
622
+ Creates a human-readable report, a Metaflow Card, after this step completes.
631
623
 
632
- The decorator will create an optional artifact, specified by `var`, which
633
- contains the exception raised. You can use it to detect the presence
634
- of errors, indicating that all happy-path artifacts produced by the step
635
- are missing.
624
+ Note that you may add multiple `@card` decorators in a step with different parameters.
636
625
 
637
626
 
638
627
  Parameters
639
628
  ----------
640
- var : str, optional, default None
641
- Name of the artifact in which to store the caught exception.
642
- If not specified, the exception is not stored.
643
- print_exception : bool, default True
644
- Determines whether or not the exception is printed to
645
- stdout when caught.
646
- """
647
- ...
648
-
649
- @typing.overload
650
- 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]]]:
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.
651
637
  """
652
- Enables loading / saving of models within a step.
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.
653
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.
654
649
 
655
650
 
656
651
  Parameters
657
652
  ----------
658
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
659
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
660
- These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
661
- - `current.checkpoint`
662
- - `current.model`
663
- - `current.huggingface_hub`
664
-
665
- 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
666
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
667
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
668
-
669
- temp_dir_root : str, default: None
670
- The root directory under which `current.model.loaded` will store loaded models
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.
671
663
  """
672
664
  ...
673
665
 
674
666
  @typing.overload
675
- def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
667
+ def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
676
668
  ...
677
669
 
678
670
  @typing.overload
679
- def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
671
+ def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
680
672
  ...
681
673
 
682
- 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):
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):
683
675
  """
684
- Enables loading / saving of models within a step.
676
+ Specifies the Conda environment for the step.
685
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.
686
682
 
687
683
 
688
684
  Parameters
689
685
  ----------
690
- load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
691
- Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
692
- These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
693
- - `current.checkpoint`
694
- - `current.model`
695
- - `current.huggingface_hub`
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
+ 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
+ """
701
+ Specifies that this step should execute on Kubernetes.
696
702
 
697
- 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
698
- the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
699
- If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
700
703
 
701
- temp_dir_root : str, default: None
702
- The root directory under which `current.model.loaded` will store loaded models
704
+ Parameters
705
+ ----------
706
+ cpu : int, default 1
707
+ Number of CPUs required for this step. If `@resources` is
708
+ also present, the maximum value from all decorators is used.
709
+ memory : int, default 4096
710
+ Memory size (in MB) required for this step. If
711
+ `@resources` is also present, the maximum value from all decorators is
712
+ used.
713
+ disk : int, default 10240
714
+ Disk size (in MB) required for this step. If
715
+ `@resources` is also present, the maximum value from all decorators is
716
+ used.
717
+ image : str, optional, default None
718
+ Docker image to use when launching on Kubernetes. If not specified, and
719
+ METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
720
+ not, a default Docker image mapping to the current version of Python is used.
721
+ image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
722
+ If given, the imagePullPolicy to be applied to the Docker image of the step.
723
+ service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
724
+ Kubernetes service account to use when launching pod in Kubernetes.
725
+ secrets : List[str], optional, default None
726
+ Kubernetes secrets to use when launching pod in Kubernetes. These
727
+ secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
728
+ in Metaflow configuration.
729
+ node_selector: Union[Dict[str,str], str], optional, default None
730
+ Kubernetes node selector(s) to apply to the pod running the task.
731
+ Can be passed in as a comma separated string of values e.g.
732
+ 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
733
+ {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
734
+ namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
735
+ Kubernetes namespace to use when launching pod in Kubernetes.
736
+ gpu : int, optional, default None
737
+ Number of GPUs required for this step. A value of zero implies that
738
+ the scheduled node should not have GPUs.
739
+ gpu_vendor : str, default KUBERNETES_GPU_VENDOR
740
+ The vendor of the GPUs to be used for this step.
741
+ tolerations : List[str], default []
742
+ The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
743
+ Kubernetes tolerations to use when launching pod in Kubernetes.
744
+ labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
745
+ Kubernetes labels to use when launching pod in Kubernetes.
746
+ annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
747
+ Kubernetes annotations to use when launching pod in Kubernetes.
748
+ use_tmpfs : bool, default False
749
+ This enables an explicit tmpfs mount for this step.
750
+ tmpfs_tempdir : bool, default True
751
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
752
+ tmpfs_size : int, optional, default: None
753
+ The value for the size (in MiB) of the tmpfs mount for this step.
754
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
755
+ memory allocated for this step.
756
+ tmpfs_path : str, optional, default /metaflow_temp
757
+ Path to tmpfs mount for this step.
758
+ persistent_volume_claims : Dict[str, str], optional, default None
759
+ A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
760
+ volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
761
+ shared_memory: int, optional
762
+ Shared memory size (in MiB) required for this step
763
+ port: int, optional
764
+ Port number to specify in the Kubernetes job object
765
+ compute_pool : str, optional, default None
766
+ Compute pool to be used for for this step.
767
+ If not specified, any accessible compute pool within the perimeter is used.
768
+ hostname_resolution_timeout: int, default 10 * 60
769
+ Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
770
+ Only applicable when @parallel is used.
771
+ qos: str, default: Burstable
772
+ Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
773
+
774
+ security_context: Dict[str, Any], optional, default None
775
+ Container security context. Applies to the task container. Allows the following keys:
776
+ - privileged: bool, optional, default None
777
+ - allow_privilege_escalation: bool, optional, default None
778
+ - run_as_user: int, optional, default None
779
+ - run_as_group: int, optional, default None
780
+ - run_as_non_root: bool, optional, default None
703
781
  """
704
782
  ...
705
783
 
@@ -719,167 +797,38 @@ def nvidia(*, gpu: int, gpu_type: str, queue_timeout: int) -> typing.Callable[[t
719
797
  """
720
798
  ...
721
799
 
722
- 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]]]:
723
- """
724
- Decorator that helps cache, version and store models/datasets from huggingface hub.
725
-
726
-
727
- Parameters
728
- ----------
729
- temp_dir_root : str, optional
730
- The root directory that will hold the temporary directory where objects will be downloaded.
731
-
732
- load: Union[List[str], List[Tuple[Dict, str]], List[Tuple[str, str]], List[Dict], None]
733
- The list of repos (models/datasets) to load.
734
-
735
- Loaded repos can be accessed via `current.huggingface_hub.loaded`. If load is set, then the following happens:
736
-
737
- - If repo (model/dataset) is not found in the datastore:
738
- - Downloads the repo from Hugging Face Hub to a temporary directory (or uses specified path) for local access
739
- - Stores it in Metaflow's datastore (s3/gcs/azure etc.) with a unique name based on repo_type/repo_id
740
- - All HF models loaded for a `@step` will be cached separately under flow/step/namespace.
741
-
742
- - If repo is found in the datastore:
743
- - Loads it directly from datastore to local path (can be temporary directory or specified path)
744
- """
745
- ...
746
-
747
- @typing.overload
748
- 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]]]:
749
- """
750
- Creates a human-readable report, a Metaflow Card, after this step completes.
751
-
752
- Note that you may add multiple `@card` decorators in a step with different parameters.
753
-
754
-
755
- Parameters
756
- ----------
757
- type : str, default 'default'
758
- Card type.
759
- id : str, optional, default None
760
- If multiple cards are present, use this id to identify this card.
761
- options : Dict[str, Any], default {}
762
- Options passed to the card. The contents depend on the card type.
763
- timeout : int, default 45
764
- Interrupt reporting if it takes more than this many seconds.
765
- """
766
- ...
767
-
768
- @typing.overload
769
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
770
- ...
771
-
772
800
  @typing.overload
773
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
774
- ...
775
-
776
- 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):
777
- """
778
- Creates a human-readable report, a Metaflow Card, after this step completes.
779
-
780
- Note that you may add multiple `@card` decorators in a step with different parameters.
781
-
782
-
783
- Parameters
784
- ----------
785
- type : str, default 'default'
786
- Card type.
787
- id : str, optional, default None
788
- If multiple cards are present, use this id to identify this card.
789
- options : Dict[str, Any], default {}
790
- Options passed to the card. The contents depend on the card type.
791
- timeout : int, default 45
792
- Interrupt reporting if it takes more than this many seconds.
793
- """
794
- ...
795
-
796
- @typing.overload
797
- 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]]]:
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]]]:
798
802
  """
799
- Enables checkpointing for a step.
800
-
803
+ Specifies secrets to be retrieved and injected as environment variables prior to
804
+ the execution of a step.
801
805
 
802
806
 
803
807
  Parameters
804
808
  ----------
805
- load_policy : str, default: "fresh"
806
- The policy for loading the checkpoint. The following policies are supported:
807
- - "eager": Loads the the latest available checkpoint within the namespace.
808
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
809
- will be loaded at the start of the task.
810
- - "none": Do not load any checkpoint
811
- - "fresh": Loads the lastest checkpoint created within the running Task.
812
- This mode helps loading checkpoints across various retry attempts of the same task.
813
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
814
- created within the task will be loaded when the task is retries execution on failure.
815
-
816
- temp_dir_root : str, default: None
817
- The root directory under which `current.checkpoint.directory` will be created.
809
+ sources : List[Union[str, Dict[str, Any]]], default: []
810
+ List of secret specs, defining how the secrets are to be retrieved
818
811
  """
819
812
  ...
820
813
 
821
814
  @typing.overload
822
- def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
815
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
823
816
  ...
824
817
 
825
818
  @typing.overload
826
- def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
827
- ...
828
-
829
- 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):
830
- """
831
- Enables checkpointing for a step.
832
-
833
-
834
-
835
- Parameters
836
- ----------
837
- load_policy : str, default: "fresh"
838
- The policy for loading the checkpoint. The following policies are supported:
839
- - "eager": Loads the the latest available checkpoint within the namespace.
840
- With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
841
- will be loaded at the start of the task.
842
- - "none": Do not load any checkpoint
843
- - "fresh": Loads the lastest checkpoint created within the running Task.
844
- This mode helps loading checkpoints across various retry attempts of the same task.
845
- With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
846
- created within the task will be loaded when the task is retries execution on failure.
847
-
848
- temp_dir_root : str, default: None
849
- The root directory under which `current.checkpoint.directory` will be created.
850
- """
819
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
851
820
  ...
852
821
 
853
- 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]]]:
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]]] = []):
854
823
  """
855
- This decorator is used to run NIM containers in Metaflow tasks as sidecars.
856
-
857
- User code call
858
- -----------
859
- @nim(
860
- models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
861
- backend='managed'
862
- )
863
-
864
- Valid backend options
865
- ---------------------
866
- - 'managed': Outerbounds selects a compute provider based on the model.
867
-
868
- Valid model options
869
- ----------------
870
- - 'meta/llama3-8b-instruct': 8B parameter model
871
- - 'meta/llama3-70b-instruct': 70B parameter model
872
- - any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
824
+ Specifies secrets to be retrieved and injected as environment variables prior to
825
+ the execution of a step.
873
826
 
874
827
 
875
828
  Parameters
876
829
  ----------
877
- models: list[NIM]
878
- List of NIM containers running models in sidecars.
879
- backend: str
880
- Compute provider to run the NIM container.
881
- queue_timeout : int
882
- Time to keep the job in NVCF's queue.
830
+ sources : List[Union[str, Dict[str, Any]]], default: []
831
+ List of secret specs, defining how the secrets are to be retrieved
883
832
  """
884
833
  ...
885
834
 
@@ -903,53 +852,86 @@ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
903
852
  ...
904
853
 
905
854
  @typing.overload
906
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
855
+ def resources(*, cpu: int = 1, gpu: typing.Optional[int] = None, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
907
856
  """
908
- Internal decorator to support Fast bakery
857
+ Specifies the resources needed when executing this step.
858
+
859
+ Use `@resources` to specify the resource requirements
860
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
861
+
862
+ You can choose the compute layer on the command line by executing e.g.
863
+ ```
864
+ python myflow.py run --with batch
865
+ ```
866
+ or
867
+ ```
868
+ python myflow.py run --with kubernetes
869
+ ```
870
+ which executes the flow on the desired system using the
871
+ requirements specified in `@resources`.
872
+
873
+
874
+ Parameters
875
+ ----------
876
+ cpu : int, default 1
877
+ Number of CPUs required for this step.
878
+ gpu : int, optional, default None
879
+ Number of GPUs required for this step.
880
+ disk : int, optional, default None
881
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
882
+ memory : int, default 4096
883
+ Memory size (in MB) required for this step.
884
+ shared_memory : int, optional, default None
885
+ The value for the size (in MiB) of the /dev/shm volume for this step.
886
+ This parameter maps to the `--shm-size` option in Docker.
909
887
  """
910
888
  ...
911
889
 
912
890
  @typing.overload
913
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
891
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
914
892
  ...
915
893
 
916
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
917
- """
918
- Internal decorator to support Fast bakery
919
- """
894
+ @typing.overload
895
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
920
896
  ...
921
897
 
922
- @typing.overload
923
- 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]]]:
898
+ def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: typing.Optional[int] = None, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None):
924
899
  """
925
- Specifies the PyPI packages for the step.
900
+ Specifies the resources needed when executing this step.
926
901
 
927
- Information in this decorator will augment any
928
- attributes set in the `@pyi_base` flow-level decorator. Hence,
929
- you can use `@pypi_base` to set packages required by all
930
- steps and use `@pypi` to specify step-specific overrides.
902
+ Use `@resources` to specify the resource requirements
903
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
904
+
905
+ You can choose the compute layer on the command line by executing e.g.
906
+ ```
907
+ python myflow.py run --with batch
908
+ ```
909
+ or
910
+ ```
911
+ python myflow.py run --with kubernetes
912
+ ```
913
+ which executes the flow on the desired system using the
914
+ requirements specified in `@resources`.
931
915
 
932
916
 
933
917
  Parameters
934
918
  ----------
935
- packages : Dict[str, str], default: {}
936
- Packages to use for this step. The key is the name of the package
937
- and the value is the version to use.
938
- python : str, optional, default: None
939
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
940
- that the version used will correspond to the version of the Python interpreter used to start the run.
919
+ cpu : int, default 1
920
+ Number of CPUs required for this step.
921
+ gpu : int, optional, default None
922
+ Number of GPUs required for this step.
923
+ disk : int, optional, default None
924
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
925
+ memory : int, default 4096
926
+ Memory size (in MB) required for this step.
927
+ shared_memory : int, optional, default None
928
+ The value for the size (in MiB) of the /dev/shm volume for this step.
929
+ This parameter maps to the `--shm-size` option in Docker.
941
930
  """
942
931
  ...
943
932
 
944
933
  @typing.overload
945
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
946
- ...
947
-
948
- @typing.overload
949
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
950
- ...
951
-
952
- def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
934
+ 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]]]:
953
935
  """
954
936
  Specifies the PyPI packages for the step.
955
937
 
@@ -970,89 +952,32 @@ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
970
952
  """
971
953
  ...
972
954
 
973
- def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
974
- """
975
- Specifies what flows belong to the same project.
976
-
977
- A project-specific namespace is created for all flows that
978
- use the same `@project(name)`.
979
-
980
-
981
- Parameters
982
- ----------
983
- name : str
984
- Project name. Make sure that the name is unique amongst all
985
- projects that use the same production scheduler. The name may
986
- contain only lowercase alphanumeric characters and underscores.
987
-
988
- branch : Optional[str], default None
989
- The branch to use. If not specified, the branch is set to
990
- `user.<username>` unless `production` is set to `True`. This can
991
- also be set on the command line using `--branch` as a top-level option.
992
- It is an error to specify `branch` in the decorator and on the command line.
993
-
994
- production : bool, default False
995
- Whether or not the branch is the production branch. This can also be set on the
996
- command line using `--production` as a top-level option. It is an error to specify
997
- `production` in the decorator and on the command line.
998
- The project branch name will be:
999
- - if `branch` is specified:
1000
- - if `production` is True: `prod.<branch>`
1001
- - if `production` is False: `test.<branch>`
1002
- - if `branch` is not specified:
1003
- - if `production` is True: `prod`
1004
- - if `production` is False: `user.<username>`
1005
- """
1006
- ...
1007
-
1008
955
  @typing.overload
1009
- 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]]:
1010
- """
1011
- Specifies the times when the flow should be run when running on a
1012
- production scheduler.
1013
-
1014
-
1015
- Parameters
1016
- ----------
1017
- hourly : bool, default False
1018
- Run the workflow hourly.
1019
- daily : bool, default True
1020
- Run the workflow daily.
1021
- weekly : bool, default False
1022
- Run the workflow weekly.
1023
- cron : str, optional, default None
1024
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1025
- specified by this expression.
1026
- timezone : str, optional, default None
1027
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1028
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1029
- """
956
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1030
957
  ...
1031
958
 
1032
959
  @typing.overload
1033
- def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
960
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1034
961
  ...
1035
962
 
1036
- def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
963
+ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1037
964
  """
1038
- Specifies the times when the flow should be run when running on a
1039
- production scheduler.
1040
-
965
+ Specifies the PyPI packages for the step.
1041
966
 
1042
- Parameters
1043
- ----------
1044
- hourly : bool, default False
1045
- Run the workflow hourly.
1046
- daily : bool, default True
1047
- Run the workflow daily.
1048
- weekly : bool, default False
1049
- Run the workflow weekly.
1050
- cron : str, optional, default None
1051
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1052
- specified by this expression.
1053
- timezone : str, optional, default None
1054
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1055
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
967
+ Information in this decorator will augment any
968
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
969
+ you can use `@pypi_base` to set packages required by all
970
+ steps and use `@pypi` to specify step-specific overrides.
971
+
972
+
973
+ Parameters
974
+ ----------
975
+ packages : Dict[str, str], default: {}
976
+ Packages to use for this step. The key is the name of the package
977
+ and the value is the version to use.
978
+ python : str, optional, default: None
979
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
980
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1056
981
  """
1057
982
  ...
1058
983
 
@@ -1149,13 +1074,253 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
1149
1074
  """
1150
1075
  ...
1151
1076
 
1152
- 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]]:
1077
+ def project(*, name: str, branch: typing.Optional[str] = None, production: bool = False) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1078
+ """
1079
+ Specifies what flows belong to the same project.
1080
+
1081
+ A project-specific namespace is created for all flows that
1082
+ use the same `@project(name)`.
1083
+
1084
+
1085
+ Parameters
1086
+ ----------
1087
+ name : str
1088
+ Project name. Make sure that the name is unique amongst all
1089
+ projects that use the same production scheduler. The name may
1090
+ contain only lowercase alphanumeric characters and underscores.
1091
+
1092
+ branch : Optional[str], default None
1093
+ The branch to use. If not specified, the branch is set to
1094
+ `user.<username>` unless `production` is set to `True`. This can
1095
+ also be set on the command line using `--branch` as a top-level option.
1096
+ It is an error to specify `branch` in the decorator and on the command line.
1097
+
1098
+ production : bool, default False
1099
+ Whether or not the branch is the production branch. This can also be set on the
1100
+ command line using `--production` as a top-level option. It is an error to specify
1101
+ `production` in the decorator and on the command line.
1102
+ The project branch name will be:
1103
+ - if `branch` is specified:
1104
+ - if `production` is True: `prod.<branch>`
1105
+ - if `production` is False: `test.<branch>`
1106
+ - if `branch` is not specified:
1107
+ - if `production` is True: `prod`
1108
+ - if `production` is False: `user.<username>`
1109
+ """
1110
+ ...
1111
+
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
+ 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
+ """
1279
+ 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)
1280
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1281
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1282
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1283
+ starts only after all sensors finish.
1284
+
1285
+
1286
+ Parameters
1287
+ ----------
1288
+ timeout : int
1289
+ Time, in seconds before the task times out and fails. (Default: 3600)
1290
+ poke_interval : int
1291
+ Time in seconds that the job should wait in between each try. (Default: 60)
1292
+ mode : str
1293
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1294
+ exponential_backoff : bool
1295
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1296
+ pool : str
1297
+ the slot pool this task should run in,
1298
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1299
+ soft_fail : bool
1300
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1301
+ name : str
1302
+ Name of the sensor on Airflow
1303
+ description : str
1304
+ Description of sensor in the Airflow UI
1305
+ bucket_key : Union[str, List[str]]
1306
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1307
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1308
+ bucket_name : str
1309
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1310
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1311
+ wildcard_match : bool
1312
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1313
+ aws_conn_id : str
1314
+ a reference to the s3 connection on Airflow. (Default: None)
1315
+ verify : bool
1316
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1317
+ """
1318
+ ...
1319
+
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]]:
1153
1321
  """
1154
- 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)
1155
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1156
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1157
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1158
- starts only after all sensors finish.
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.
1159
1324
 
1160
1325
 
1161
1326
  Parameters
@@ -1177,18 +1342,21 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
1177
1342
  Name of the sensor on Airflow
1178
1343
  description : str
1179
1344
  Description of sensor in the Airflow UI
1180
- bucket_key : Union[str, List[str]]
1181
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1182
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1183
- bucket_name : str
1184
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1185
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1186
- wildcard_match : bool
1187
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1188
- aws_conn_id : str
1189
- a reference to the s3 connection on Airflow. (Default: None)
1190
- verify : bool
1191
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
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)
1192
1360
  """
1193
1361
  ...
1194
1362
 
@@ -1294,53 +1462,53 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
1294
1462
  ...
1295
1463
 
1296
1464
  @typing.overload
1297
- 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]]:
1465
+ 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]]:
1298
1466
  """
1299
- Specifies the Conda environment for all steps of the flow.
1300
-
1301
- Use `@conda_base` to set common libraries required by all
1302
- steps and use `@conda` to specify step-specific additions.
1467
+ Specifies the times when the flow should be run when running on a
1468
+ production scheduler.
1303
1469
 
1304
1470
 
1305
1471
  Parameters
1306
1472
  ----------
1307
- packages : Dict[str, str], default {}
1308
- Packages to use for this flow. The key is the name of the package
1309
- and the value is the version to use.
1310
- libraries : Dict[str, str], default {}
1311
- Supported for backward compatibility. When used with packages, packages will take precedence.
1312
- python : str, optional, default None
1313
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1314
- that the version used will correspond to the version of the Python interpreter used to start the run.
1315
- disabled : bool, default False
1316
- If set to True, disables Conda.
1473
+ hourly : bool, default False
1474
+ Run the workflow hourly.
1475
+ daily : bool, default True
1476
+ Run the workflow daily.
1477
+ weekly : bool, default False
1478
+ Run the workflow weekly.
1479
+ cron : str, optional, default None
1480
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1481
+ specified by this expression.
1482
+ timezone : str, optional, default None
1483
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1484
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1317
1485
  """
1318
1486
  ...
1319
1487
 
1320
1488
  @typing.overload
1321
- def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1489
+ def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1322
1490
  ...
1323
1491
 
1324
- 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):
1492
+ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
1325
1493
  """
1326
- Specifies the Conda environment for all steps of the flow.
1327
-
1328
- Use `@conda_base` to set common libraries required by all
1329
- steps and use `@conda` to specify step-specific additions.
1494
+ Specifies the times when the flow should be run when running on a
1495
+ production scheduler.
1330
1496
 
1331
1497
 
1332
1498
  Parameters
1333
1499
  ----------
1334
- packages : Dict[str, str], default {}
1335
- Packages to use for this flow. The key is the name of the package
1336
- and the value is the version to use.
1337
- libraries : Dict[str, str], default {}
1338
- Supported for backward compatibility. When used with packages, packages will take precedence.
1339
- python : str, optional, default None
1340
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1341
- that the version used will correspond to the version of the Python interpreter used to start the run.
1342
- disabled : bool, default False
1343
- If set to True, disables Conda.
1500
+ hourly : bool, default False
1501
+ Run the workflow hourly.
1502
+ daily : bool, default True
1503
+ Run the workflow daily.
1504
+ weekly : bool, default False
1505
+ Run the workflow weekly.
1506
+ cron : str, optional, default None
1507
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1508
+ specified by this expression.
1509
+ timezone : str, optional, default None
1510
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1511
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1344
1512
  """
1345
1513
  ...
1346
1514
 
@@ -1385,162 +1553,5 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
1385
1553
  """
1386
1554
  ...
1387
1555
 
1388
- 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]]:
1389
- """
1390
- 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.
1391
- 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.
1392
-
1393
-
1394
- Parameters
1395
- ----------
1396
- timeout : int
1397
- Time, in seconds before the task times out and fails. (Default: 3600)
1398
- poke_interval : int
1399
- Time in seconds that the job should wait in between each try. (Default: 60)
1400
- mode : str
1401
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1402
- exponential_backoff : bool
1403
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1404
- pool : str
1405
- the slot pool this task should run in,
1406
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1407
- soft_fail : bool
1408
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1409
- name : str
1410
- Name of the sensor on Airflow
1411
- description : str
1412
- Description of sensor in the Airflow UI
1413
- external_dag_id : str
1414
- The dag_id that contains the task you want to wait for.
1415
- external_task_ids : List[str]
1416
- The list of task_ids that you want to wait for.
1417
- If None (default value) the sensor waits for the DAG. (Default: None)
1418
- allowed_states : List[str]
1419
- Iterable of allowed states, (Default: ['success'])
1420
- failed_states : List[str]
1421
- Iterable of failed or dis-allowed states. (Default: None)
1422
- execution_delta : datetime.timedelta
1423
- time difference with the previous execution to look at,
1424
- the default is the same logical date as the current task or DAG. (Default: None)
1425
- check_existence: bool
1426
- Set to True to check if the external task exists or check if
1427
- the DAG to wait for exists. (Default: True)
1428
- """
1429
- ...
1430
-
1431
- def with_artifact_store(f: typing.Optional[typing.Type[FlowSpecDerived]] = None):
1432
- """
1433
- Allows setting external datastores to save data for the
1434
- `@checkpoint`/`@model`/`@huggingface_hub` decorators.
1435
-
1436
- This decorator is useful when users wish to save data to a different datastore
1437
- than what is configured in Metaflow. This can be for variety of reasons:
1438
-
1439
- 1. Data security: The objects needs to be stored in a bucket (object storage) that is not accessible by other flows.
1440
- 2. Data Locality: The location where the task is executing is not located in the same region as the datastore.
1441
- - Example: Metaflow datastore lives in US East, but the task is executing in Finland datacenters.
1442
- 3. Data Lifecycle Policies: The objects need to be archived / managed separately from the Metaflow managed objects.
1443
- - Example: Flow is training very large models that need to be stored separately and will be deleted more aggressively than the Metaflow managed objects.
1444
-
1445
- Usage:
1446
- ----------
1447
-
1448
- - Using a custom IAM role to access the datastore.
1449
-
1450
- ```python
1451
- @with_artifact_store(
1452
- type="s3",
1453
- config=lambda: {
1454
- "root": "s3://my-bucket-foo/path/to/root",
1455
- "role_arn": ROLE,
1456
- },
1457
- )
1458
- class MyFlow(FlowSpec):
1459
-
1460
- @checkpoint
1461
- @step
1462
- def start(self):
1463
- with open("my_file.txt", "w") as f:
1464
- f.write("Hello, World!")
1465
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1466
- self.next(self.end)
1467
-
1468
- ```
1469
-
1470
- - Using credentials to access the s3-compatible datastore.
1471
-
1472
- ```python
1473
- @with_artifact_store(
1474
- type="s3",
1475
- config=lambda: {
1476
- "root": "s3://my-bucket-foo/path/to/root",
1477
- "client_params": {
1478
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1479
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1480
- },
1481
- },
1482
- )
1483
- class MyFlow(FlowSpec):
1484
-
1485
- @checkpoint
1486
- @step
1487
- def start(self):
1488
- with open("my_file.txt", "w") as f:
1489
- f.write("Hello, World!")
1490
- self.external_bucket_checkpoint = current.checkpoint.save("my_file.txt")
1491
- self.next(self.end)
1492
-
1493
- ```
1494
-
1495
- - Accessing objects stored in external datastores after task execution.
1496
-
1497
- ```python
1498
- run = Run("CheckpointsTestsFlow/8992")
1499
- with artifact_store_from(run=run, config={
1500
- "client_params": {
1501
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1502
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1503
- },
1504
- }):
1505
- with Checkpoint() as cp:
1506
- latest = cp.list(
1507
- task=run["start"].task
1508
- )[0]
1509
- print(latest)
1510
- cp.load(
1511
- latest,
1512
- "test-checkpoints"
1513
- )
1514
-
1515
- task = Task("TorchTuneFlow/8484/train/53673")
1516
- with artifact_store_from(run=run, config={
1517
- "client_params": {
1518
- "aws_access_key_id": os.environ.get("MY_CUSTOM_ACCESS_KEY"),
1519
- "aws_secret_access_key": os.environ.get("MY_CUSTOM_SECRET_KEY"),
1520
- },
1521
- }):
1522
- load_model(
1523
- task.data.model_ref,
1524
- "test-models"
1525
- )
1526
- ```
1527
- Parameters:
1528
- ----------
1529
-
1530
- type: str
1531
- The type of the datastore. Can be one of 's3', 'gcs', 'azure' or any other supported metaflow Datastore.
1532
-
1533
- config: dict or Callable
1534
- Dictionary of configuration options for the datastore. The following keys are required:
1535
- - root: The root path in the datastore where the data will be saved. (needs to be in the format expected by the datastore)
1536
- - example: 's3://bucket-name/path/to/root'
1537
- - example: 'gs://bucket-name/path/to/root'
1538
- - example: 'https://myblockacc.blob.core.windows.net/metaflow/'
1539
- - role_arn (optional): AWS IAM role to access s3 bucket (only when `type` is 's3')
1540
- - session_vars (optional): AWS session variables to access s3 bucket (only when `type` is 's3')
1541
- - client_params (optional): AWS client parameters to access s3 bucket (only when `type` is 's3')
1542
- """
1543
- ...
1544
-
1545
1556
  pkg_name: str
1546
1557