metaflow-stubs 2.15.10__py2.py3-none-any.whl → 2.15.12__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 (149) hide show
  1. metaflow-stubs/__init__.pyi +650 -650
  2. metaflow-stubs/cards.pyi +2 -2
  3. metaflow-stubs/cli.pyi +2 -2
  4. metaflow-stubs/cli_components/__init__.pyi +2 -2
  5. metaflow-stubs/cli_components/utils.pyi +2 -2
  6. metaflow-stubs/client/__init__.pyi +2 -2
  7. metaflow-stubs/client/core.pyi +5 -5
  8. metaflow-stubs/client/filecache.pyi +3 -3
  9. metaflow-stubs/events.pyi +3 -3
  10. metaflow-stubs/exception.pyi +2 -2
  11. metaflow-stubs/flowspec.pyi +4 -4
  12. metaflow-stubs/generated_for.txt +1 -1
  13. metaflow-stubs/includefile.pyi +3 -3
  14. metaflow-stubs/info_file.pyi +2 -2
  15. metaflow-stubs/metadata_provider/__init__.pyi +2 -2
  16. metaflow-stubs/metadata_provider/heartbeat.pyi +2 -2
  17. metaflow-stubs/metadata_provider/metadata.pyi +2 -2
  18. metaflow-stubs/metadata_provider/util.pyi +2 -2
  19. metaflow-stubs/metaflow_config.pyi +4 -2
  20. metaflow-stubs/metaflow_current.pyi +6 -6
  21. metaflow-stubs/metaflow_git.pyi +2 -2
  22. metaflow-stubs/multicore_utils.pyi +2 -2
  23. metaflow-stubs/parameters.pyi +3 -3
  24. metaflow-stubs/plugins/__init__.pyi +11 -11
  25. metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
  26. metaflow-stubs/plugins/airflow/airflow_decorator.pyi +2 -2
  27. metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
  28. metaflow-stubs/plugins/airflow/exception.pyi +2 -2
  29. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
  30. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
  31. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
  32. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
  33. metaflow-stubs/plugins/argo/__init__.pyi +2 -2
  34. metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
  35. metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
  36. metaflow-stubs/plugins/argo/argo_workflows.pyi +2 -2
  37. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +3 -3
  38. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
  39. metaflow-stubs/plugins/argo/argo_workflows_deployer_objects.pyi +3 -3
  40. metaflow-stubs/plugins/aws/__init__.pyi +3 -3
  41. metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
  42. metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
  43. metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
  44. metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
  45. metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
  46. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +2 -2
  47. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
  48. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +4 -4
  49. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
  50. metaflow-stubs/plugins/aws/step_functions/dynamo_db_client.pyi +2 -2
  51. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
  52. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
  53. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
  54. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
  55. metaflow-stubs/plugins/aws/step_functions/step_functions_decorator.pyi +2 -2
  56. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +3 -3
  57. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer_objects.pyi +2 -2
  58. metaflow-stubs/plugins/azure/__init__.pyi +2 -2
  59. metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
  60. metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
  61. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +4 -4
  62. metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
  63. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
  64. metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
  65. metaflow-stubs/plugins/cards/__init__.pyi +2 -2
  66. metaflow-stubs/plugins/cards/card_client.pyi +3 -3
  67. metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
  68. metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
  69. metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
  70. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
  71. metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
  72. metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
  73. metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
  74. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
  75. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
  76. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
  77. metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
  78. metaflow-stubs/plugins/cards/component_serializer.pyi +2 -2
  79. metaflow-stubs/plugins/cards/exception.pyi +2 -2
  80. metaflow-stubs/plugins/catch_decorator.pyi +2 -2
  81. metaflow-stubs/plugins/datatools/__init__.pyi +2 -2
  82. metaflow-stubs/plugins/datatools/local.pyi +2 -2
  83. metaflow-stubs/plugins/datatools/s3/__init__.pyi +2 -2
  84. metaflow-stubs/plugins/datatools/s3/s3.pyi +4 -4
  85. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
  86. metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
  87. metaflow-stubs/plugins/debug_logger.pyi +2 -2
  88. metaflow-stubs/plugins/debug_monitor.pyi +2 -2
  89. metaflow-stubs/plugins/environment_decorator.pyi +2 -2
  90. metaflow-stubs/plugins/events_decorator.pyi +2 -2
  91. metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
  92. metaflow-stubs/plugins/frameworks/pytorch.pyi +2 -2
  93. metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
  94. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +4 -4
  95. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
  96. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
  97. metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
  98. metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
  99. metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
  100. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
  101. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +2 -2
  102. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
  103. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +2 -2
  104. metaflow-stubs/plugins/kubernetes/kubernetes_job.pyi +2 -2
  105. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
  106. metaflow-stubs/plugins/kubernetes/spot_monitor_sidecar.pyi +2 -2
  107. metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
  108. metaflow-stubs/plugins/project_decorator.pyi +2 -2
  109. metaflow-stubs/plugins/pypi/__init__.pyi +3 -3
  110. metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
  111. metaflow-stubs/plugins/pypi/conda_environment.pyi +6 -6
  112. metaflow-stubs/plugins/pypi/parsers.pyi +2 -2
  113. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
  114. metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
  115. metaflow-stubs/plugins/pypi/utils.pyi +2 -2
  116. metaflow-stubs/plugins/resources_decorator.pyi +2 -2
  117. metaflow-stubs/plugins/retry_decorator.pyi +2 -2
  118. metaflow-stubs/plugins/secrets/__init__.pyi +3 -3
  119. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +3 -3
  120. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
  121. metaflow-stubs/plugins/storage_executor.pyi +2 -2
  122. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +2 -2
  123. metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
  124. metaflow-stubs/plugins/uv/__init__.pyi +2 -2
  125. metaflow-stubs/plugins/uv/uv_environment.pyi +3 -3
  126. metaflow-stubs/pylint_wrapper.pyi +2 -2
  127. metaflow-stubs/runner/__init__.pyi +2 -2
  128. metaflow-stubs/runner/deployer.pyi +5 -5
  129. metaflow-stubs/runner/deployer_impl.pyi +3 -3
  130. metaflow-stubs/runner/metaflow_runner.pyi +3 -3
  131. metaflow-stubs/runner/nbdeploy.pyi +2 -2
  132. metaflow-stubs/runner/nbrun.pyi +2 -2
  133. metaflow-stubs/runner/subprocess_manager.pyi +3 -3
  134. metaflow-stubs/runner/utils.pyi +4 -4
  135. metaflow-stubs/system/__init__.pyi +2 -2
  136. metaflow-stubs/system/system_logger.pyi +3 -3
  137. metaflow-stubs/system/system_monitor.pyi +2 -2
  138. metaflow-stubs/tagging_util.pyi +2 -2
  139. metaflow-stubs/tuple_util.pyi +2 -2
  140. metaflow-stubs/user_configs/__init__.pyi +2 -2
  141. metaflow-stubs/user_configs/config_decorators.pyi +5 -5
  142. metaflow-stubs/user_configs/config_options.pyi +2 -2
  143. metaflow-stubs/user_configs/config_parameters.pyi +6 -6
  144. metaflow-stubs/version.pyi +2 -2
  145. {metaflow_stubs-2.15.10.dist-info → metaflow_stubs-2.15.12.dist-info}/METADATA +2 -2
  146. metaflow_stubs-2.15.12.dist-info/RECORD +149 -0
  147. {metaflow_stubs-2.15.10.dist-info → metaflow_stubs-2.15.12.dist-info}/WHEEL +1 -1
  148. metaflow_stubs-2.15.10.dist-info/RECORD +0 -149
  149. {metaflow_stubs-2.15.10.dist-info → metaflow_stubs-2.15.12.dist-info}/top_level.txt +0 -0
@@ -1,15 +1,15 @@
1
1
  ######################################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
- # MF version: 2.15.10 #
4
- # Generated on 2025-05-01T20:06:36.084744 #
3
+ # MF version: 2.15.12 #
4
+ # Generated on 2025-05-15T19:09:53.993231 #
5
5
  ######################################################################################################
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
9
  import typing
10
10
  if typing.TYPE_CHECKING:
11
- import typing
12
11
  import datetime
12
+ import typing
13
13
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
14
14
  StepFlag = typing.NewType("StepFlag", bool)
15
15
 
@@ -36,8 +36,8 @@ from .user_configs.config_parameters import config_expr as config_expr
36
36
  from .user_configs.config_decorators import CustomFlowDecorator as CustomFlowDecorator
37
37
  from .user_configs.config_decorators import CustomStepDecorator as CustomStepDecorator
38
38
  from . import events as events
39
- from . import metaflow_git as metaflow_git
40
39
  from . import tuple_util as tuple_util
40
+ from . import metaflow_git as metaflow_git
41
41
  from . import runner as runner
42
42
  from . import plugins as plugins
43
43
  from .plugins.datatools.s3.s3 import S3 as S3
@@ -196,153 +196,293 @@ def card(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typ
196
196
  ...
197
197
 
198
198
  @typing.overload
199
- def pypi(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
199
+ def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
200
200
  """
201
- Specifies the PyPI packages for the step.
202
-
203
- Information in this decorator will augment any
204
- attributes set in the `@pyi_base` flow-level decorator. Hence,
205
- you can use `@pypi_base` to set packages required by all
206
- steps and use `@pypi` to specify step-specific overrides.
201
+ Specifies secrets to be retrieved and injected as environment variables prior to
202
+ the execution of a step.
207
203
 
208
204
 
209
205
  Parameters
210
206
  ----------
211
- packages : Dict[str, str], default: {}
212
- Packages to use for this step. The key is the name of the package
213
- and the value is the version to use.
214
- python : str, optional, default: None
215
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
216
- that the version used will correspond to the version of the Python interpreter used to start the run.
207
+ sources : List[Union[str, Dict[str, Any]]], default: []
208
+ List of secret specs, defining how the secrets are to be retrieved
217
209
  """
218
210
  ...
219
211
 
220
212
  @typing.overload
221
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
213
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
222
214
  ...
223
215
 
224
216
  @typing.overload
225
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
217
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
226
218
  ...
227
219
 
228
- def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
220
+ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
229
221
  """
230
- Specifies the PyPI packages for the step.
231
-
232
- Information in this decorator will augment any
233
- attributes set in the `@pyi_base` flow-level decorator. Hence,
234
- you can use `@pypi_base` to set packages required by all
235
- steps and use `@pypi` to specify step-specific overrides.
222
+ Specifies secrets to be retrieved and injected as environment variables prior to
223
+ the execution of a step.
236
224
 
237
225
 
238
226
  Parameters
239
227
  ----------
240
- packages : Dict[str, str], default: {}
241
- Packages to use for this step. The key is the name of the package
242
- and the value is the version to use.
243
- python : str, optional, default: None
244
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
245
- that the version used will correspond to the version of the Python interpreter used to start the run.
228
+ sources : List[Union[str, Dict[str, Any]]], default: []
229
+ List of secret specs, defining how the secrets are to be retrieved
246
230
  """
247
231
  ...
248
232
 
249
- @typing.overload
250
- 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]]]:
233
+ 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]]]:
251
234
  """
252
- Specifies a timeout for your step.
253
-
254
- This decorator is useful if this step may hang indefinitely.
255
-
256
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
257
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
258
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
259
-
260
- Note that all the values specified in parameters are added together so if you specify
261
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
235
+ Specifies that this step should execute on Kubernetes.
262
236
 
263
237
 
264
238
  Parameters
265
239
  ----------
266
- seconds : int, default 0
267
- Number of seconds to wait prior to timing out.
268
- minutes : int, default 0
269
- Number of minutes to wait prior to timing out.
270
- hours : int, default 0
271
- Number of hours to wait prior to timing out.
240
+ cpu : int, default 1
241
+ Number of CPUs required for this step. If `@resources` is
242
+ also present, the maximum value from all decorators is used.
243
+ memory : int, default 4096
244
+ Memory size (in MB) required for this step. If
245
+ `@resources` is also present, the maximum value from all decorators is
246
+ used.
247
+ disk : int, default 10240
248
+ Disk size (in MB) required for this step. If
249
+ `@resources` is also present, the maximum value from all decorators is
250
+ used.
251
+ image : str, optional, default None
252
+ Docker image to use when launching on Kubernetes. If not specified, and
253
+ METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
254
+ not, a default Docker image mapping to the current version of Python is used.
255
+ image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
256
+ If given, the imagePullPolicy to be applied to the Docker image of the step.
257
+ service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
258
+ Kubernetes service account to use when launching pod in Kubernetes.
259
+ secrets : List[str], optional, default None
260
+ Kubernetes secrets to use when launching pod in Kubernetes. These
261
+ secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
262
+ in Metaflow configuration.
263
+ node_selector: Union[Dict[str,str], str], optional, default None
264
+ Kubernetes node selector(s) to apply to the pod running the task.
265
+ Can be passed in as a comma separated string of values e.g.
266
+ 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
267
+ {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
268
+ namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
269
+ Kubernetes namespace to use when launching pod in Kubernetes.
270
+ gpu : int, optional, default None
271
+ Number of GPUs required for this step. A value of zero implies that
272
+ the scheduled node should not have GPUs.
273
+ gpu_vendor : str, default KUBERNETES_GPU_VENDOR
274
+ The vendor of the GPUs to be used for this step.
275
+ tolerations : List[str], default []
276
+ The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
277
+ Kubernetes tolerations to use when launching pod in Kubernetes.
278
+ labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
279
+ Kubernetes labels to use when launching pod in Kubernetes.
280
+ annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
281
+ Kubernetes annotations to use when launching pod in Kubernetes.
282
+ use_tmpfs : bool, default False
283
+ This enables an explicit tmpfs mount for this step.
284
+ tmpfs_tempdir : bool, default True
285
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
286
+ tmpfs_size : int, optional, default: None
287
+ The value for the size (in MiB) of the tmpfs mount for this step.
288
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
289
+ memory allocated for this step.
290
+ tmpfs_path : str, optional, default /metaflow_temp
291
+ Path to tmpfs mount for this step.
292
+ persistent_volume_claims : Dict[str, str], optional, default None
293
+ A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
294
+ volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
295
+ shared_memory: int, optional
296
+ Shared memory size (in MiB) required for this step
297
+ port: int, optional
298
+ Port number to specify in the Kubernetes job object
299
+ compute_pool : str, optional, default None
300
+ Compute pool to be used for for this step.
301
+ If not specified, any accessible compute pool within the perimeter is used.
302
+ hostname_resolution_timeout: int, default 10 * 60
303
+ Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
304
+ Only applicable when @parallel is used.
305
+ qos: str, default: Burstable
306
+ Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
307
+
308
+ security_context: Dict[str, Any], optional, default None
309
+ Container security context. Applies to the task container. Allows the following keys:
310
+ - privileged: bool, optional, default None
311
+ - allow_privilege_escalation: bool, optional, default None
312
+ - run_as_user: int, optional, default None
313
+ - run_as_group: int, optional, default None
314
+ - run_as_non_root: bool, optional, default None
272
315
  """
273
316
  ...
274
317
 
275
318
  @typing.overload
276
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
277
- ...
278
-
279
- @typing.overload
280
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
281
- ...
282
-
283
- 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):
319
+ def batch(*, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = 'METAFLOW_BATCH_JOB_QUEUE', iam_role: str = 'METAFLOW_ECS_S3_ACCESS_IAM_ROLE', execution_role: str = 'METAFLOW_ECS_FARGATE_EXECUTION_ROLE', shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[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]]]:
284
320
  """
285
- Specifies a timeout for your step.
286
-
287
- This decorator is useful if this step may hang indefinitely.
288
-
289
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
290
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
291
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
292
-
293
- Note that all the values specified in parameters are added together so if you specify
294
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
321
+ Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
295
322
 
296
323
 
297
324
  Parameters
298
325
  ----------
299
- seconds : int, default 0
300
- Number of seconds to wait prior to timing out.
301
- minutes : int, default 0
302
- Number of minutes to wait prior to timing out.
303
- hours : int, default 0
304
- Number of hours to wait prior to timing out.
326
+ cpu : int, default 1
327
+ Number of CPUs required for this step. If `@resources` is
328
+ also present, the maximum value from all decorators is used.
329
+ gpu : int, default 0
330
+ Number of GPUs required for this step. If `@resources` is
331
+ also present, the maximum value from all decorators is used.
332
+ memory : int, default 4096
333
+ Memory size (in MB) required for this step. If
334
+ `@resources` is also present, the maximum value from all decorators is
335
+ used.
336
+ image : str, optional, default None
337
+ Docker image to use when launching on AWS Batch. If not specified, and
338
+ METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
339
+ not, a default Docker image mapping to the current version of Python is used.
340
+ queue : str, default METAFLOW_BATCH_JOB_QUEUE
341
+ AWS Batch Job Queue to submit the job to.
342
+ iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
343
+ AWS IAM role that AWS Batch container uses to access AWS cloud resources.
344
+ execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
345
+ AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
346
+ (https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
347
+ shared_memory : int, optional, default None
348
+ The value for the size (in MiB) of the /dev/shm volume for this step.
349
+ This parameter maps to the `--shm-size` option in Docker.
350
+ max_swap : int, optional, default None
351
+ The total amount of swap memory (in MiB) a container can use for this
352
+ step. This parameter is translated to the `--memory-swap` option in
353
+ Docker where the value is the sum of the container memory plus the
354
+ `max_swap` value.
355
+ swappiness : int, optional, default None
356
+ This allows you to tune memory swappiness behavior for this step.
357
+ A swappiness value of 0 causes swapping not to happen unless absolutely
358
+ necessary. A swappiness value of 100 causes pages to be swapped very
359
+ aggressively. Accepted values are whole numbers between 0 and 100.
360
+ use_tmpfs : bool, default False
361
+ This enables an explicit tmpfs mount for this step. Note that tmpfs is
362
+ not available on Fargate compute environments
363
+ tmpfs_tempdir : bool, default True
364
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
365
+ tmpfs_size : int, optional, default None
366
+ The value for the size (in MiB) of the tmpfs mount for this step.
367
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
368
+ memory allocated for this step.
369
+ tmpfs_path : str, optional, default None
370
+ Path to tmpfs mount for this step. Defaults to /metaflow_temp.
371
+ inferentia : int, default 0
372
+ Number of Inferentia chips required for this step.
373
+ trainium : int, default None
374
+ Alias for inferentia. Use only one of the two.
375
+ efa : int, default 0
376
+ Number of elastic fabric adapter network devices to attach to container
377
+ ephemeral_storage : int, default None
378
+ The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
379
+ This is only relevant for Fargate compute environments
380
+ log_driver: str, optional, default None
381
+ The log driver to use for the Amazon ECS container.
382
+ log_options: List[str], optional, default None
383
+ List of strings containing options for the chosen log driver. The configurable values
384
+ depend on the `log driver` chosen. Validation of these options is not supported yet.
385
+ Example: [`awslogs-group:aws/batch/job`]
305
386
  """
306
387
  ...
307
388
 
308
389
  @typing.overload
309
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
310
- """
311
- Decorator prototype for all step decorators. This function gets specialized
312
- and imported for all decorators types by _import_plugin_decorators().
313
- """
390
+ def batch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
314
391
  ...
315
392
 
316
393
  @typing.overload
317
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
318
- ...
319
-
320
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
321
- """
322
- Decorator prototype for all step decorators. This function gets specialized
323
- and imported for all decorators types by _import_plugin_decorators().
324
- """
394
+ def batch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
325
395
  ...
326
396
 
327
- @typing.overload
328
- 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]]]:
397
+ def batch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = 'METAFLOW_BATCH_JOB_QUEUE', iam_role: str = 'METAFLOW_ECS_S3_ACCESS_IAM_ROLE', execution_role: str = 'METAFLOW_ECS_FARGATE_EXECUTION_ROLE', shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None):
329
398
  """
330
- Specifies the Conda environment for the step.
331
-
332
- Information in this decorator will augment any
333
- attributes set in the `@conda_base` flow-level decorator. Hence,
334
- you can use `@conda_base` to set packages required by all
335
- steps and use `@conda` to specify step-specific overrides.
399
+ Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
336
400
 
337
401
 
338
402
  Parameters
339
403
  ----------
340
- packages : Dict[str, str], default {}
341
- Packages to use for this step. The key is the name of the package
342
- and the value is the version to use.
343
- libraries : Dict[str, str], default {}
344
- Supported for backward compatibility. When used with packages, packages will take precedence.
345
- python : str, optional, default None
404
+ cpu : int, default 1
405
+ Number of CPUs required for this step. If `@resources` is
406
+ also present, the maximum value from all decorators is used.
407
+ gpu : int, default 0
408
+ Number of GPUs required for this step. If `@resources` is
409
+ also present, the maximum value from all decorators is used.
410
+ memory : int, default 4096
411
+ Memory size (in MB) required for this step. If
412
+ `@resources` is also present, the maximum value from all decorators is
413
+ used.
414
+ image : str, optional, default None
415
+ Docker image to use when launching on AWS Batch. If not specified, and
416
+ METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
417
+ not, a default Docker image mapping to the current version of Python is used.
418
+ queue : str, default METAFLOW_BATCH_JOB_QUEUE
419
+ AWS Batch Job Queue to submit the job to.
420
+ iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
421
+ AWS IAM role that AWS Batch container uses to access AWS cloud resources.
422
+ execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
423
+ AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
424
+ (https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
425
+ shared_memory : int, optional, default None
426
+ The value for the size (in MiB) of the /dev/shm volume for this step.
427
+ This parameter maps to the `--shm-size` option in Docker.
428
+ max_swap : int, optional, default None
429
+ The total amount of swap memory (in MiB) a container can use for this
430
+ step. This parameter is translated to the `--memory-swap` option in
431
+ Docker where the value is the sum of the container memory plus the
432
+ `max_swap` value.
433
+ swappiness : int, optional, default None
434
+ This allows you to tune memory swappiness behavior for this step.
435
+ A swappiness value of 0 causes swapping not to happen unless absolutely
436
+ necessary. A swappiness value of 100 causes pages to be swapped very
437
+ aggressively. Accepted values are whole numbers between 0 and 100.
438
+ use_tmpfs : bool, default False
439
+ This enables an explicit tmpfs mount for this step. Note that tmpfs is
440
+ not available on Fargate compute environments
441
+ tmpfs_tempdir : bool, default True
442
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
443
+ tmpfs_size : int, optional, default None
444
+ The value for the size (in MiB) of the tmpfs mount for this step.
445
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
446
+ memory allocated for this step.
447
+ tmpfs_path : str, optional, default None
448
+ Path to tmpfs mount for this step. Defaults to /metaflow_temp.
449
+ inferentia : int, default 0
450
+ Number of Inferentia chips required for this step.
451
+ trainium : int, default None
452
+ Alias for inferentia. Use only one of the two.
453
+ efa : int, default 0
454
+ Number of elastic fabric adapter network devices to attach to container
455
+ ephemeral_storage : int, default None
456
+ The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
457
+ This is only relevant for Fargate compute environments
458
+ log_driver: str, optional, default None
459
+ The log driver to use for the Amazon ECS container.
460
+ log_options: List[str], optional, default None
461
+ List of strings containing options for the chosen log driver. The configurable values
462
+ depend on the `log driver` chosen. Validation of these options is not supported yet.
463
+ Example: [`awslogs-group:aws/batch/job`]
464
+ """
465
+ ...
466
+
467
+ @typing.overload
468
+ 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]]]:
469
+ """
470
+ Specifies the Conda environment for the step.
471
+
472
+ Information in this decorator will augment any
473
+ attributes set in the `@conda_base` flow-level decorator. Hence,
474
+ you can use `@conda_base` to set packages required by all
475
+ steps and use `@conda` to specify step-specific overrides.
476
+
477
+
478
+ Parameters
479
+ ----------
480
+ packages : Dict[str, str], default {}
481
+ Packages to use for this step. The key is the name of the package
482
+ and the value is the version to use.
483
+ libraries : Dict[str, str], default {}
484
+ Supported for backward compatibility. When used with packages, packages will take precedence.
485
+ python : str, optional, default None
346
486
  Version of Python to use, e.g. '3.7.4'. A default value of None implies
347
487
  that the version used will correspond to the version of the Python interpreter used to start the run.
348
488
  disabled : bool, default False
@@ -384,286 +524,167 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
384
524
  ...
385
525
 
386
526
  @typing.overload
387
- 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]]]:
527
+ def pypi(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
388
528
  """
389
- Specifies the resources needed when executing this step.
390
-
391
- Use `@resources` to specify the resource requirements
392
- independently of the specific compute layer (`@batch`, `@kubernetes`).
529
+ Specifies the PyPI packages for the step.
393
530
 
394
- You can choose the compute layer on the command line by executing e.g.
395
- ```
396
- python myflow.py run --with batch
397
- ```
398
- or
399
- ```
400
- python myflow.py run --with kubernetes
401
- ```
402
- which executes the flow on the desired system using the
403
- requirements specified in `@resources`.
531
+ Information in this decorator will augment any
532
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
533
+ you can use `@pypi_base` to set packages required by all
534
+ steps and use `@pypi` to specify step-specific overrides.
404
535
 
405
536
 
406
537
  Parameters
407
538
  ----------
408
- cpu : int, default 1
409
- Number of CPUs required for this step.
410
- gpu : int, optional, default None
411
- Number of GPUs required for this step.
412
- disk : int, optional, default None
413
- Disk size (in MB) required for this step. Only applies on Kubernetes.
414
- memory : int, default 4096
415
- Memory size (in MB) required for this step.
416
- shared_memory : int, optional, default None
417
- The value for the size (in MiB) of the /dev/shm volume for this step.
418
- This parameter maps to the `--shm-size` option in Docker.
539
+ packages : Dict[str, str], default: {}
540
+ Packages to use for this step. The key is the name of the package
541
+ and the value is the version to use.
542
+ python : str, optional, default: None
543
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
544
+ that the version used will correspond to the version of the Python interpreter used to start the run.
419
545
  """
420
546
  ...
421
547
 
422
548
  @typing.overload
423
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
549
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
424
550
  ...
425
551
 
426
552
  @typing.overload
427
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
553
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
428
554
  ...
429
555
 
430
- 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):
556
+ def pypi(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
431
557
  """
432
- Specifies the resources needed when executing this step.
433
-
434
- Use `@resources` to specify the resource requirements
435
- independently of the specific compute layer (`@batch`, `@kubernetes`).
558
+ Specifies the PyPI packages for the step.
436
559
 
437
- You can choose the compute layer on the command line by executing e.g.
438
- ```
439
- python myflow.py run --with batch
440
- ```
441
- or
442
- ```
443
- python myflow.py run --with kubernetes
444
- ```
445
- which executes the flow on the desired system using the
446
- requirements specified in `@resources`.
560
+ Information in this decorator will augment any
561
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
562
+ you can use `@pypi_base` to set packages required by all
563
+ steps and use `@pypi` to specify step-specific overrides.
447
564
 
448
565
 
449
566
  Parameters
450
567
  ----------
451
- cpu : int, default 1
452
- Number of CPUs required for this step.
453
- gpu : int, optional, default None
454
- Number of GPUs required for this step.
455
- disk : int, optional, default None
456
- Disk size (in MB) required for this step. Only applies on Kubernetes.
457
- memory : int, default 4096
458
- Memory size (in MB) required for this step.
459
- shared_memory : int, optional, default None
460
- The value for the size (in MiB) of the /dev/shm volume for this step.
461
- This parameter maps to the `--shm-size` option in Docker.
568
+ packages : Dict[str, str], default: {}
569
+ Packages to use for this step. The key is the name of the package
570
+ and the value is the version to use.
571
+ python : str, optional, default: None
572
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
573
+ that the version used will correspond to the version of the Python interpreter used to start the run.
462
574
  """
463
575
  ...
464
576
 
465
577
  @typing.overload
466
- 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]]]:
578
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
467
579
  """
468
- Specifies that the step will success under all circumstances.
580
+ Decorator prototype for all step decorators. This function gets specialized
581
+ and imported for all decorators types by _import_plugin_decorators().
582
+ """
583
+ ...
584
+
585
+ @typing.overload
586
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
587
+ ...
588
+
589
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
590
+ """
591
+ Decorator prototype for all step decorators. This function gets specialized
592
+ and imported for all decorators types by _import_plugin_decorators().
593
+ """
594
+ ...
595
+
596
+ @typing.overload
597
+ 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]]]:
598
+ """
599
+ Specifies a timeout for your step.
469
600
 
470
- The decorator will create an optional artifact, specified by `var`, which
471
- contains the exception raised. You can use it to detect the presence
472
- of errors, indicating that all happy-path artifacts produced by the step
473
- are missing.
601
+ This decorator is useful if this step may hang indefinitely.
602
+
603
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
604
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
605
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
606
+
607
+ Note that all the values specified in parameters are added together so if you specify
608
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
474
609
 
475
610
 
476
611
  Parameters
477
612
  ----------
478
- var : str, optional, default None
479
- Name of the artifact in which to store the caught exception.
480
- If not specified, the exception is not stored.
481
- print_exception : bool, default True
482
- Determines whether or not the exception is printed to
483
- stdout when caught.
613
+ seconds : int, default 0
614
+ Number of seconds to wait prior to timing out.
615
+ minutes : int, default 0
616
+ Number of minutes to wait prior to timing out.
617
+ hours : int, default 0
618
+ Number of hours to wait prior to timing out.
484
619
  """
485
620
  ...
486
621
 
487
622
  @typing.overload
488
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
623
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
489
624
  ...
490
625
 
491
626
  @typing.overload
492
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
627
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
493
628
  ...
494
629
 
495
- 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):
630
+ 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):
496
631
  """
497
- Specifies that the step will success under all circumstances.
632
+ Specifies a timeout for your step.
498
633
 
499
- The decorator will create an optional artifact, specified by `var`, which
500
- contains the exception raised. You can use it to detect the presence
501
- of errors, indicating that all happy-path artifacts produced by the step
502
- are missing.
634
+ This decorator is useful if this step may hang indefinitely.
635
+
636
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
637
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
638
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
639
+
640
+ Note that all the values specified in parameters are added together so if you specify
641
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
503
642
 
504
643
 
505
644
  Parameters
506
645
  ----------
507
- var : str, optional, default None
508
- Name of the artifact in which to store the caught exception.
509
- If not specified, the exception is not stored.
510
- print_exception : bool, default True
511
- Determines whether or not the exception is printed to
512
- stdout when caught.
646
+ seconds : int, default 0
647
+ Number of seconds to wait prior to timing out.
648
+ minutes : int, default 0
649
+ Number of minutes to wait prior to timing out.
650
+ hours : int, default 0
651
+ Number of hours to wait prior to timing out.
513
652
  """
514
653
  ...
515
654
 
516
655
  @typing.overload
517
- def batch(*, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = 'METAFLOW_BATCH_JOB_QUEUE', iam_role: str = 'METAFLOW_ECS_S3_ACCESS_IAM_ROLE', execution_role: str = 'METAFLOW_ECS_FARGATE_EXECUTION_ROLE', shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[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]]]:
656
+ 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]]]:
518
657
  """
519
- Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
658
+ Specifies the number of times the task corresponding
659
+ to a step needs to be retried.
660
+
661
+ This decorator is useful for handling transient errors, such as networking issues.
662
+ If your task contains operations that can't be retried safely, e.g. database updates,
663
+ it is advisable to annotate it with `@retry(times=0)`.
664
+
665
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
666
+ decorator will execute a no-op task after all retries have been exhausted,
667
+ ensuring that the flow execution can continue.
520
668
 
521
669
 
522
670
  Parameters
523
671
  ----------
524
- cpu : int, default 1
525
- Number of CPUs required for this step. If `@resources` is
526
- also present, the maximum value from all decorators is used.
527
- gpu : int, default 0
528
- Number of GPUs required for this step. If `@resources` is
529
- also present, the maximum value from all decorators is used.
530
- memory : int, default 4096
531
- Memory size (in MB) required for this step. If
532
- `@resources` is also present, the maximum value from all decorators is
533
- used.
534
- image : str, optional, default None
535
- Docker image to use when launching on AWS Batch. If not specified, and
536
- METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
537
- not, a default Docker image mapping to the current version of Python is used.
538
- queue : str, default METAFLOW_BATCH_JOB_QUEUE
539
- AWS Batch Job Queue to submit the job to.
540
- iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
541
- AWS IAM role that AWS Batch container uses to access AWS cloud resources.
542
- execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
543
- AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
544
- (https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
545
- shared_memory : int, optional, default None
546
- The value for the size (in MiB) of the /dev/shm volume for this step.
547
- This parameter maps to the `--shm-size` option in Docker.
548
- max_swap : int, optional, default None
549
- The total amount of swap memory (in MiB) a container can use for this
550
- step. This parameter is translated to the `--memory-swap` option in
551
- Docker where the value is the sum of the container memory plus the
552
- `max_swap` value.
553
- swappiness : int, optional, default None
554
- This allows you to tune memory swappiness behavior for this step.
555
- A swappiness value of 0 causes swapping not to happen unless absolutely
556
- necessary. A swappiness value of 100 causes pages to be swapped very
557
- aggressively. Accepted values are whole numbers between 0 and 100.
558
- use_tmpfs : bool, default False
559
- This enables an explicit tmpfs mount for this step. Note that tmpfs is
560
- not available on Fargate compute environments
561
- tmpfs_tempdir : bool, default True
562
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
563
- tmpfs_size : int, optional, default None
564
- The value for the size (in MiB) of the tmpfs mount for this step.
565
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
566
- memory allocated for this step.
567
- tmpfs_path : str, optional, default None
568
- Path to tmpfs mount for this step. Defaults to /metaflow_temp.
569
- inferentia : int, default 0
570
- Number of Inferentia chips required for this step.
571
- trainium : int, default None
572
- Alias for inferentia. Use only one of the two.
573
- efa : int, default 0
574
- Number of elastic fabric adapter network devices to attach to container
575
- ephemeral_storage : int, default None
576
- The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
577
- This is only relevant for Fargate compute environments
578
- log_driver: str, optional, default None
579
- The log driver to use for the Amazon ECS container.
580
- log_options: List[str], optional, default None
581
- List of strings containing options for the chosen log driver. The configurable values
582
- depend on the `log driver` chosen. Validation of these options is not supported yet.
583
- Example: [`awslogs-group:aws/batch/job`]
672
+ times : int, default 3
673
+ Number of times to retry this task.
674
+ minutes_between_retries : int, default 2
675
+ Number of minutes between retries.
584
676
  """
585
677
  ...
586
678
 
587
679
  @typing.overload
588
- def batch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
680
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
589
681
  ...
590
682
 
591
683
  @typing.overload
592
- def batch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
593
- ...
594
-
595
- def batch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = 'METAFLOW_BATCH_JOB_QUEUE', iam_role: str = 'METAFLOW_ECS_S3_ACCESS_IAM_ROLE', execution_role: str = 'METAFLOW_ECS_FARGATE_EXECUTION_ROLE', shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None):
596
- """
597
- Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
598
-
599
-
600
- Parameters
601
- ----------
602
- cpu : int, default 1
603
- Number of CPUs required for this step. If `@resources` is
604
- also present, the maximum value from all decorators is used.
605
- gpu : int, default 0
606
- Number of GPUs required for this step. If `@resources` is
607
- also present, the maximum value from all decorators is used.
608
- memory : int, default 4096
609
- Memory size (in MB) required for this step. If
610
- `@resources` is also present, the maximum value from all decorators is
611
- used.
612
- image : str, optional, default None
613
- Docker image to use when launching on AWS Batch. If not specified, and
614
- METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
615
- not, a default Docker image mapping to the current version of Python is used.
616
- queue : str, default METAFLOW_BATCH_JOB_QUEUE
617
- AWS Batch Job Queue to submit the job to.
618
- iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
619
- AWS IAM role that AWS Batch container uses to access AWS cloud resources.
620
- execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
621
- AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
622
- (https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
623
- shared_memory : int, optional, default None
624
- The value for the size (in MiB) of the /dev/shm volume for this step.
625
- This parameter maps to the `--shm-size` option in Docker.
626
- max_swap : int, optional, default None
627
- The total amount of swap memory (in MiB) a container can use for this
628
- step. This parameter is translated to the `--memory-swap` option in
629
- Docker where the value is the sum of the container memory plus the
630
- `max_swap` value.
631
- swappiness : int, optional, default None
632
- This allows you to tune memory swappiness behavior for this step.
633
- A swappiness value of 0 causes swapping not to happen unless absolutely
634
- necessary. A swappiness value of 100 causes pages to be swapped very
635
- aggressively. Accepted values are whole numbers between 0 and 100.
636
- use_tmpfs : bool, default False
637
- This enables an explicit tmpfs mount for this step. Note that tmpfs is
638
- not available on Fargate compute environments
639
- tmpfs_tempdir : bool, default True
640
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
641
- tmpfs_size : int, optional, default None
642
- The value for the size (in MiB) of the tmpfs mount for this step.
643
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
644
- memory allocated for this step.
645
- tmpfs_path : str, optional, default None
646
- Path to tmpfs mount for this step. Defaults to /metaflow_temp.
647
- inferentia : int, default 0
648
- Number of Inferentia chips required for this step.
649
- trainium : int, default None
650
- Alias for inferentia. Use only one of the two.
651
- efa : int, default 0
652
- Number of elastic fabric adapter network devices to attach to container
653
- ephemeral_storage : int, default None
654
- The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
655
- This is only relevant for Fargate compute environments
656
- log_driver: str, optional, default None
657
- The log driver to use for the Amazon ECS container.
658
- log_options: List[str], optional, default None
659
- List of strings containing options for the chosen log driver. The configurable values
660
- depend on the `log driver` chosen. Validation of these options is not supported yet.
661
- Example: [`awslogs-group:aws/batch/job`]
662
- """
684
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
663
685
  ...
664
686
 
665
- @typing.overload
666
- 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]]]:
687
+ 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):
667
688
  """
668
689
  Specifies the number of times the task corresponding
669
690
  to a step needs to be retried.
@@ -687,277 +708,350 @@ def retry(*, times: int = 3, minutes_between_retries: int = 2) -> typing.Callabl
687
708
  ...
688
709
 
689
710
  @typing.overload
690
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
711
+ 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]]]:
712
+ """
713
+ Specifies environment variables to be set prior to the execution of a step.
714
+
715
+
716
+ Parameters
717
+ ----------
718
+ vars : Dict[str, str], default {}
719
+ Dictionary of environment variables to set.
720
+ """
691
721
  ...
692
722
 
693
723
  @typing.overload
694
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
724
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
695
725
  ...
696
726
 
697
- 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):
727
+ @typing.overload
728
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
729
+ ...
730
+
731
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
698
732
  """
699
- Specifies the number of times the task corresponding
700
- to a step needs to be retried.
701
-
702
- This decorator is useful for handling transient errors, such as networking issues.
703
- If your task contains operations that can't be retried safely, e.g. database updates,
704
- it is advisable to annotate it with `@retry(times=0)`.
705
-
706
- This can be used in conjunction with the `@catch` decorator. The `@catch`
707
- decorator will execute a no-op task after all retries have been exhausted,
708
- ensuring that the flow execution can continue.
733
+ Specifies environment variables to be set prior to the execution of a step.
709
734
 
710
735
 
711
736
  Parameters
712
737
  ----------
713
- times : int, default 3
714
- Number of times to retry this task.
715
- minutes_between_retries : int, default 2
716
- Number of minutes between retries.
738
+ vars : Dict[str, str], default {}
739
+ Dictionary of environment variables to set.
717
740
  """
718
741
  ...
719
742
 
720
- 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]]]:
743
+ @typing.overload
744
+ 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]]]:
721
745
  """
722
- Specifies that this step should execute on Kubernetes.
746
+ Specifies the resources needed when executing this step.
747
+
748
+ Use `@resources` to specify the resource requirements
749
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
750
+
751
+ You can choose the compute layer on the command line by executing e.g.
752
+ ```
753
+ python myflow.py run --with batch
754
+ ```
755
+ or
756
+ ```
757
+ python myflow.py run --with kubernetes
758
+ ```
759
+ which executes the flow on the desired system using the
760
+ requirements specified in `@resources`.
723
761
 
724
762
 
725
763
  Parameters
726
764
  ----------
727
765
  cpu : int, default 1
728
- Number of CPUs required for this step. If `@resources` is
729
- also present, the maximum value from all decorators is used.
730
- memory : int, default 4096
731
- Memory size (in MB) required for this step. If
732
- `@resources` is also present, the maximum value from all decorators is
733
- used.
734
- disk : int, default 10240
735
- Disk size (in MB) required for this step. If
736
- `@resources` is also present, the maximum value from all decorators is
737
- used.
738
- image : str, optional, default None
739
- Docker image to use when launching on Kubernetes. If not specified, and
740
- METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
741
- not, a default Docker image mapping to the current version of Python is used.
742
- image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
743
- If given, the imagePullPolicy to be applied to the Docker image of the step.
744
- service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
745
- Kubernetes service account to use when launching pod in Kubernetes.
746
- secrets : List[str], optional, default None
747
- Kubernetes secrets to use when launching pod in Kubernetes. These
748
- secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
749
- in Metaflow configuration.
750
- node_selector: Union[Dict[str,str], str], optional, default None
751
- Kubernetes node selector(s) to apply to the pod running the task.
752
- Can be passed in as a comma separated string of values e.g.
753
- 'kubernetes.io/os=linux,kubernetes.io/arch=amd64' or as a dictionary
754
- {'kubernetes.io/os': 'linux', 'kubernetes.io/arch': 'amd64'}
755
- namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
756
- Kubernetes namespace to use when launching pod in Kubernetes.
766
+ Number of CPUs required for this step.
757
767
  gpu : int, optional, default None
758
- Number of GPUs required for this step. A value of zero implies that
759
- the scheduled node should not have GPUs.
760
- gpu_vendor : str, default KUBERNETES_GPU_VENDOR
761
- The vendor of the GPUs to be used for this step.
762
- tolerations : List[str], default []
763
- The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
764
- Kubernetes tolerations to use when launching pod in Kubernetes.
765
- labels: Dict[str, str], default: METAFLOW_KUBERNETES_LABELS
766
- Kubernetes labels to use when launching pod in Kubernetes.
767
- annotations: Dict[str, str], default: METAFLOW_KUBERNETES_ANNOTATIONS
768
- Kubernetes annotations to use when launching pod in Kubernetes.
769
- use_tmpfs : bool, default False
770
- This enables an explicit tmpfs mount for this step.
771
- tmpfs_tempdir : bool, default True
772
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
773
- tmpfs_size : int, optional, default: None
774
- The value for the size (in MiB) of the tmpfs mount for this step.
775
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
776
- memory allocated for this step.
777
- tmpfs_path : str, optional, default /metaflow_temp
778
- Path to tmpfs mount for this step.
779
- persistent_volume_claims : Dict[str, str], optional, default None
780
- A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
781
- volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
782
- shared_memory: int, optional
783
- Shared memory size (in MiB) required for this step
784
- port: int, optional
785
- Port number to specify in the Kubernetes job object
786
- compute_pool : str, optional, default None
787
- Compute pool to be used for for this step.
788
- If not specified, any accessible compute pool within the perimeter is used.
789
- hostname_resolution_timeout: int, default 10 * 60
790
- Timeout in seconds for the workers tasks in the gang scheduled cluster to resolve the hostname of control task.
791
- Only applicable when @parallel is used.
792
- qos: str, default: Burstable
793
- Quality of Service class to assign to the pod. Supported values are: Guaranteed, Burstable, BestEffort
768
+ Number of GPUs required for this step.
769
+ disk : int, optional, default None
770
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
771
+ memory : int, default 4096
772
+ Memory size (in MB) required for this step.
773
+ shared_memory : int, optional, default None
774
+ The value for the size (in MiB) of the /dev/shm volume for this step.
775
+ This parameter maps to the `--shm-size` option in Docker.
776
+ """
777
+ ...
778
+
779
+ @typing.overload
780
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
781
+ ...
782
+
783
+ @typing.overload
784
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
785
+ ...
786
+
787
+ 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):
788
+ """
789
+ Specifies the resources needed when executing this step.
794
790
 
795
- security_context: Dict[str, Any], optional, default None
796
- Container security context. Applies to the task container. Allows the following keys:
797
- - privileged: bool, optional, default None
798
- - allow_privilege_escalation: bool, optional, default None
799
- - run_as_user: int, optional, default None
800
- - run_as_group: int, optional, default None
801
- - run_as_non_root: bool, optional, default None
791
+ Use `@resources` to specify the resource requirements
792
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
793
+
794
+ You can choose the compute layer on the command line by executing e.g.
795
+ ```
796
+ python myflow.py run --with batch
797
+ ```
798
+ or
799
+ ```
800
+ python myflow.py run --with kubernetes
801
+ ```
802
+ which executes the flow on the desired system using the
803
+ requirements specified in `@resources`.
804
+
805
+
806
+ Parameters
807
+ ----------
808
+ cpu : int, default 1
809
+ Number of CPUs required for this step.
810
+ gpu : int, optional, default None
811
+ Number of GPUs required for this step.
812
+ disk : int, optional, default None
813
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
814
+ memory : int, default 4096
815
+ Memory size (in MB) required for this step.
816
+ shared_memory : int, optional, default None
817
+ The value for the size (in MiB) of the /dev/shm volume for this step.
818
+ This parameter maps to the `--shm-size` option in Docker.
802
819
  """
803
820
  ...
804
821
 
805
822
  @typing.overload
806
- def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
823
+ 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]]]:
807
824
  """
808
- Specifies secrets to be retrieved and injected as environment variables prior to
809
- the execution of a step.
825
+ Specifies that the step will success under all circumstances.
826
+
827
+ The decorator will create an optional artifact, specified by `var`, which
828
+ contains the exception raised. You can use it to detect the presence
829
+ of errors, indicating that all happy-path artifacts produced by the step
830
+ are missing.
810
831
 
811
832
 
812
833
  Parameters
813
834
  ----------
814
- sources : List[Union[str, Dict[str, Any]]], default: []
815
- List of secret specs, defining how the secrets are to be retrieved
835
+ var : str, optional, default None
836
+ Name of the artifact in which to store the caught exception.
837
+ If not specified, the exception is not stored.
838
+ print_exception : bool, default True
839
+ Determines whether or not the exception is printed to
840
+ stdout when caught.
816
841
  """
817
842
  ...
818
843
 
819
844
  @typing.overload
820
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
845
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
821
846
  ...
822
847
 
823
848
  @typing.overload
824
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
849
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
825
850
  ...
826
851
 
827
- def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
852
+ 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):
828
853
  """
829
- Specifies secrets to be retrieved and injected as environment variables prior to
830
- the execution of a step.
854
+ Specifies that the step will success under all circumstances.
855
+
856
+ The decorator will create an optional artifact, specified by `var`, which
857
+ contains the exception raised. You can use it to detect the presence
858
+ of errors, indicating that all happy-path artifacts produced by the step
859
+ are missing.
831
860
 
832
861
 
833
862
  Parameters
834
863
  ----------
835
- sources : List[Union[str, Dict[str, Any]]], default: []
836
- List of secret specs, defining how the secrets are to be retrieved
864
+ var : str, optional, default None
865
+ Name of the artifact in which to store the caught exception.
866
+ If not specified, the exception is not stored.
867
+ print_exception : bool, default True
868
+ Determines whether or not the exception is printed to
869
+ stdout when caught.
837
870
  """
838
871
  ...
839
872
 
840
- @typing.overload
841
- 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]]]:
873
+ 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]]:
842
874
  """
843
- Specifies environment variables to be set prior to the execution of a step.
875
+ 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)
876
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
877
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
878
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
879
+ starts only after all sensors finish.
844
880
 
845
881
 
846
882
  Parameters
847
883
  ----------
848
- vars : Dict[str, str], default {}
849
- Dictionary of environment variables to set.
884
+ timeout : int
885
+ Time, in seconds before the task times out and fails. (Default: 3600)
886
+ poke_interval : int
887
+ Time in seconds that the job should wait in between each try. (Default: 60)
888
+ mode : str
889
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
890
+ exponential_backoff : bool
891
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
892
+ pool : str
893
+ the slot pool this task should run in,
894
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
895
+ soft_fail : bool
896
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
897
+ name : str
898
+ Name of the sensor on Airflow
899
+ description : str
900
+ Description of sensor in the Airflow UI
901
+ bucket_key : Union[str, List[str]]
902
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
903
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
904
+ bucket_name : str
905
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
906
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
907
+ wildcard_match : bool
908
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
909
+ aws_conn_id : str
910
+ a reference to the s3 connection on Airflow. (Default: None)
911
+ verify : bool
912
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
850
913
  """
851
914
  ...
852
915
 
853
- @typing.overload
854
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
855
- ...
856
-
857
- @typing.overload
858
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
859
- ...
860
-
861
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
916
+ 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]]:
862
917
  """
863
- Specifies environment variables to be set prior to the execution of a step.
918
+ 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.
919
+ 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.
864
920
 
865
921
 
866
922
  Parameters
867
923
  ----------
868
- vars : Dict[str, str], default {}
869
- Dictionary of environment variables to set.
924
+ timeout : int
925
+ Time, in seconds before the task times out and fails. (Default: 3600)
926
+ poke_interval : int
927
+ Time in seconds that the job should wait in between each try. (Default: 60)
928
+ mode : str
929
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
930
+ exponential_backoff : bool
931
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
932
+ pool : str
933
+ the slot pool this task should run in,
934
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
935
+ soft_fail : bool
936
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
937
+ name : str
938
+ Name of the sensor on Airflow
939
+ description : str
940
+ Description of sensor in the Airflow UI
941
+ external_dag_id : str
942
+ The dag_id that contains the task you want to wait for.
943
+ external_task_ids : List[str]
944
+ The list of task_ids that you want to wait for.
945
+ If None (default value) the sensor waits for the DAG. (Default: None)
946
+ allowed_states : List[str]
947
+ Iterable of allowed states, (Default: ['success'])
948
+ failed_states : List[str]
949
+ Iterable of failed or dis-allowed states. (Default: None)
950
+ execution_delta : datetime.timedelta
951
+ time difference with the previous execution to look at,
952
+ the default is the same logical date as the current task or DAG. (Default: None)
953
+ check_existence: bool
954
+ Set to True to check if the external task exists or check if
955
+ the DAG to wait for exists. (Default: True)
870
956
  """
871
957
  ...
872
958
 
873
959
  @typing.overload
874
- 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]]:
960
+ 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]]:
875
961
  """
876
- Specifies the event(s) that this flow depends on.
962
+ Specifies the flow(s) that this flow depends on.
877
963
 
878
964
  ```
879
- @trigger(event='foo')
965
+ @trigger_on_finish(flow='FooFlow')
880
966
  ```
881
967
  or
882
968
  ```
883
- @trigger(events=['foo', 'bar'])
969
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
884
970
  ```
971
+ This decorator respects the @project decorator and triggers the flow
972
+ when upstream runs within the same namespace complete successfully
885
973
 
886
- Additionally, you can specify the parameter mappings
887
- to map event payload to Metaflow parameters for the flow.
974
+ Additionally, you can specify project aware upstream flow dependencies
975
+ by specifying the fully qualified project_flow_name.
888
976
  ```
889
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
977
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
890
978
  ```
891
979
  or
892
980
  ```
893
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
894
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
981
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
895
982
  ```
896
983
 
897
- 'parameters' can also be a list of strings and tuples like so:
898
- ```
899
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
900
- ```
901
- This is equivalent to:
984
+ You can also specify just the project or project branch (other values will be
985
+ inferred from the current project or project branch):
902
986
  ```
903
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
987
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
904
988
  ```
905
989
 
990
+ Note that `branch` is typically one of:
991
+ - `prod`
992
+ - `user.bob`
993
+ - `test.my_experiment`
994
+ - `prod.staging`
995
+
906
996
 
907
997
  Parameters
908
998
  ----------
909
- event : Union[str, Dict[str, Any]], optional, default None
910
- Event dependency for this flow.
911
- events : List[Union[str, Dict[str, Any]]], default []
912
- Events dependency for this flow.
999
+ flow : Union[str, Dict[str, str]], optional, default None
1000
+ Upstream flow dependency for this flow.
1001
+ flows : List[Union[str, Dict[str, str]]], default []
1002
+ Upstream flow dependencies for this flow.
913
1003
  options : Dict[str, Any], default {}
914
1004
  Backend-specific configuration for tuning eventing behavior.
915
1005
  """
916
1006
  ...
917
1007
 
918
1008
  @typing.overload
919
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1009
+ def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
920
1010
  ...
921
1011
 
922
- def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
1012
+ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
923
1013
  """
924
- Specifies the event(s) that this flow depends on.
1014
+ Specifies the flow(s) that this flow depends on.
925
1015
 
926
1016
  ```
927
- @trigger(event='foo')
1017
+ @trigger_on_finish(flow='FooFlow')
928
1018
  ```
929
1019
  or
930
1020
  ```
931
- @trigger(events=['foo', 'bar'])
1021
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
932
1022
  ```
1023
+ This decorator respects the @project decorator and triggers the flow
1024
+ when upstream runs within the same namespace complete successfully
933
1025
 
934
- Additionally, you can specify the parameter mappings
935
- to map event payload to Metaflow parameters for the flow.
1026
+ Additionally, you can specify project aware upstream flow dependencies
1027
+ by specifying the fully qualified project_flow_name.
936
1028
  ```
937
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1029
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
938
1030
  ```
939
1031
  or
940
1032
  ```
941
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
942
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1033
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
943
1034
  ```
944
1035
 
945
- 'parameters' can also be a list of strings and tuples like so:
946
- ```
947
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
948
- ```
949
- This is equivalent to:
1036
+ You can also specify just the project or project branch (other values will be
1037
+ inferred from the current project or project branch):
950
1038
  ```
951
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1039
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
952
1040
  ```
953
1041
 
1042
+ Note that `branch` is typically one of:
1043
+ - `prod`
1044
+ - `user.bob`
1045
+ - `test.my_experiment`
1046
+ - `prod.staging`
1047
+
954
1048
 
955
1049
  Parameters
956
1050
  ----------
957
- event : Union[str, Dict[str, Any]], optional, default None
958
- Event dependency for this flow.
959
- events : List[Union[str, Dict[str, Any]]], default []
960
- Events dependency for this flow.
1051
+ flow : Union[str, Dict[str, str]], optional, default None
1052
+ Upstream flow dependency for this flow.
1053
+ flows : List[Union[str, Dict[str, str]]], default []
1054
+ Upstream flow dependencies for this flow.
961
1055
  options : Dict[str, Any], default {}
962
1056
  Backend-specific configuration for tuning eventing behavior.
963
1057
  """
@@ -1015,101 +1109,134 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
1015
1109
  ...
1016
1110
 
1017
1111
  @typing.overload
1018
- 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]]:
1112
+ def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1019
1113
  """
1020
- Specifies the flow(s) that this flow depends on.
1114
+ Specifies the PyPI packages for all steps of the flow.
1115
+
1116
+ Use `@pypi_base` to set common packages required by all
1117
+ steps and use `@pypi` to specify step-specific overrides.
1118
+
1119
+ Parameters
1120
+ ----------
1121
+ packages : Dict[str, str], default: {}
1122
+ Packages to use for this flow. The key is the name of the package
1123
+ and the value is the version to use.
1124
+ python : str, optional, default: None
1125
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1126
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1127
+ """
1128
+ ...
1129
+
1130
+ @typing.overload
1131
+ def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1132
+ ...
1133
+
1134
+ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1135
+ """
1136
+ Specifies the PyPI packages for all steps of the flow.
1137
+
1138
+ Use `@pypi_base` to set common packages required by all
1139
+ steps and use `@pypi` to specify step-specific overrides.
1140
+
1141
+ Parameters
1142
+ ----------
1143
+ packages : Dict[str, str], default: {}
1144
+ Packages to use for this flow. The key is the name of the package
1145
+ and the value is the version to use.
1146
+ python : str, optional, default: None
1147
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1148
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1149
+ """
1150
+ ...
1151
+
1152
+ @typing.overload
1153
+ 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]]:
1154
+ """
1155
+ Specifies the event(s) that this flow depends on.
1021
1156
 
1022
1157
  ```
1023
- @trigger_on_finish(flow='FooFlow')
1158
+ @trigger(event='foo')
1024
1159
  ```
1025
1160
  or
1026
1161
  ```
1027
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1162
+ @trigger(events=['foo', 'bar'])
1028
1163
  ```
1029
- This decorator respects the @project decorator and triggers the flow
1030
- when upstream runs within the same namespace complete successfully
1031
1164
 
1032
- Additionally, you can specify project aware upstream flow dependencies
1033
- by specifying the fully qualified project_flow_name.
1165
+ Additionally, you can specify the parameter mappings
1166
+ to map event payload to Metaflow parameters for the flow.
1034
1167
  ```
1035
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1168
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1036
1169
  ```
1037
1170
  or
1038
1171
  ```
1039
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1172
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1173
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1040
1174
  ```
1041
1175
 
1042
- You can also specify just the project or project branch (other values will be
1043
- inferred from the current project or project branch):
1176
+ 'parameters' can also be a list of strings and tuples like so:
1044
1177
  ```
1045
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1178
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1179
+ ```
1180
+ This is equivalent to:
1181
+ ```
1182
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1046
1183
  ```
1047
-
1048
- Note that `branch` is typically one of:
1049
- - `prod`
1050
- - `user.bob`
1051
- - `test.my_experiment`
1052
- - `prod.staging`
1053
1184
 
1054
1185
 
1055
1186
  Parameters
1056
1187
  ----------
1057
- flow : Union[str, Dict[str, str]], optional, default None
1058
- Upstream flow dependency for this flow.
1059
- flows : List[Union[str, Dict[str, str]]], default []
1060
- Upstream flow dependencies for this flow.
1188
+ event : Union[str, Dict[str, Any]], optional, default None
1189
+ Event dependency for this flow.
1190
+ events : List[Union[str, Dict[str, Any]]], default []
1191
+ Events dependency for this flow.
1061
1192
  options : Dict[str, Any], default {}
1062
1193
  Backend-specific configuration for tuning eventing behavior.
1063
1194
  """
1064
1195
  ...
1065
1196
 
1066
1197
  @typing.overload
1067
- def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1198
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1068
1199
  ...
1069
1200
 
1070
- def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[typing.Dict[str, str], str, None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1201
+ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
1071
1202
  """
1072
- Specifies the flow(s) that this flow depends on.
1203
+ Specifies the event(s) that this flow depends on.
1073
1204
 
1074
1205
  ```
1075
- @trigger_on_finish(flow='FooFlow')
1206
+ @trigger(event='foo')
1076
1207
  ```
1077
1208
  or
1078
1209
  ```
1079
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1210
+ @trigger(events=['foo', 'bar'])
1080
1211
  ```
1081
- This decorator respects the @project decorator and triggers the flow
1082
- when upstream runs within the same namespace complete successfully
1083
1212
 
1084
- Additionally, you can specify project aware upstream flow dependencies
1085
- by specifying the fully qualified project_flow_name.
1213
+ Additionally, you can specify the parameter mappings
1214
+ to map event payload to Metaflow parameters for the flow.
1086
1215
  ```
1087
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1216
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1088
1217
  ```
1089
1218
  or
1090
1219
  ```
1091
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1220
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1221
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1092
1222
  ```
1093
1223
 
1094
- You can also specify just the project or project branch (other values will be
1095
- inferred from the current project or project branch):
1224
+ 'parameters' can also be a list of strings and tuples like so:
1096
1225
  ```
1097
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1226
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1227
+ ```
1228
+ This is equivalent to:
1229
+ ```
1230
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1098
1231
  ```
1099
-
1100
- Note that `branch` is typically one of:
1101
- - `prod`
1102
- - `user.bob`
1103
- - `test.my_experiment`
1104
- - `prod.staging`
1105
1232
 
1106
1233
 
1107
1234
  Parameters
1108
1235
  ----------
1109
- flow : Union[str, Dict[str, str]], optional, default None
1110
- Upstream flow dependency for this flow.
1111
- flows : List[Union[str, Dict[str, str]]], default []
1112
- Upstream flow dependencies for this flow.
1236
+ event : Union[str, Dict[str, Any]], optional, default None
1237
+ Event dependency for this flow.
1238
+ events : List[Union[str, Dict[str, Any]]], default []
1239
+ Events dependency for this flow.
1113
1240
  options : Dict[str, Any], default {}
1114
1241
  Backend-specific configuration for tuning eventing behavior.
1115
1242
  """
@@ -1150,133 +1277,6 @@ def project(*, name: str, branch: typing.Optional[str] = None, production: bool
1150
1277
  """
1151
1278
  ...
1152
1279
 
1153
- 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]]:
1154
- """
1155
- 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.
1156
- 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.
1157
-
1158
-
1159
- Parameters
1160
- ----------
1161
- timeout : int
1162
- Time, in seconds before the task times out and fails. (Default: 3600)
1163
- poke_interval : int
1164
- Time in seconds that the job should wait in between each try. (Default: 60)
1165
- mode : str
1166
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1167
- exponential_backoff : bool
1168
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1169
- pool : str
1170
- the slot pool this task should run in,
1171
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1172
- soft_fail : bool
1173
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1174
- name : str
1175
- Name of the sensor on Airflow
1176
- description : str
1177
- Description of sensor in the Airflow UI
1178
- external_dag_id : str
1179
- The dag_id that contains the task you want to wait for.
1180
- external_task_ids : List[str]
1181
- The list of task_ids that you want to wait for.
1182
- If None (default value) the sensor waits for the DAG. (Default: None)
1183
- allowed_states : List[str]
1184
- Iterable of allowed states, (Default: ['success'])
1185
- failed_states : List[str]
1186
- Iterable of failed or dis-allowed states. (Default: None)
1187
- execution_delta : datetime.timedelta
1188
- time difference with the previous execution to look at,
1189
- the default is the same logical date as the current task or DAG. (Default: None)
1190
- check_existence: bool
1191
- Set to True to check if the external task exists or check if
1192
- the DAG to wait for exists. (Default: True)
1193
- """
1194
- ...
1195
-
1196
- 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]]:
1197
- """
1198
- 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)
1199
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1200
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1201
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1202
- starts only after all sensors finish.
1203
-
1204
-
1205
- Parameters
1206
- ----------
1207
- timeout : int
1208
- Time, in seconds before the task times out and fails. (Default: 3600)
1209
- poke_interval : int
1210
- Time in seconds that the job should wait in between each try. (Default: 60)
1211
- mode : str
1212
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1213
- exponential_backoff : bool
1214
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1215
- pool : str
1216
- the slot pool this task should run in,
1217
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1218
- soft_fail : bool
1219
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1220
- name : str
1221
- Name of the sensor on Airflow
1222
- description : str
1223
- Description of sensor in the Airflow UI
1224
- bucket_key : Union[str, List[str]]
1225
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1226
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1227
- bucket_name : str
1228
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1229
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1230
- wildcard_match : bool
1231
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1232
- aws_conn_id : str
1233
- a reference to the s3 connection on Airflow. (Default: None)
1234
- verify : bool
1235
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1236
- """
1237
- ...
1238
-
1239
- @typing.overload
1240
- def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1241
- """
1242
- Specifies the PyPI packages for all steps of the flow.
1243
-
1244
- Use `@pypi_base` to set common packages required by all
1245
- steps and use `@pypi` to specify step-specific overrides.
1246
-
1247
- Parameters
1248
- ----------
1249
- packages : Dict[str, str], default: {}
1250
- Packages to use for this flow. The key is the name of the package
1251
- and the value is the version to use.
1252
- python : str, optional, default: None
1253
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1254
- that the version used will correspond to the version of the Python interpreter used to start the run.
1255
- """
1256
- ...
1257
-
1258
- @typing.overload
1259
- def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1260
- ...
1261
-
1262
- def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1263
- """
1264
- Specifies the PyPI packages for all steps of the flow.
1265
-
1266
- Use `@pypi_base` to set common packages required by all
1267
- steps and use `@pypi` to specify step-specific overrides.
1268
-
1269
- Parameters
1270
- ----------
1271
- packages : Dict[str, str], default: {}
1272
- Packages to use for this flow. The key is the name of the package
1273
- and the value is the version to use.
1274
- python : str, optional, default: None
1275
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1276
- that the version used will correspond to the version of the Python interpreter used to start the run.
1277
- """
1278
- ...
1279
-
1280
1280
  @typing.overload
1281
1281
  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]]:
1282
1282
  """