metaflow-stubs 2.15.20__py2.py3-none-any.whl → 2.15.21__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.

Potentially problematic release.


This version of metaflow-stubs might be problematic. Click here for more details.

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