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