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