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