metaflow-stubs 2.12.21__py2.py3-none-any.whl → 2.12.23__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.
- metaflow-stubs/__init__.pyi +1047 -656
- metaflow-stubs/cards.pyi +209 -3
- metaflow-stubs/cli.pyi +23 -3
- metaflow-stubs/client/__init__.pyi +128 -3
- metaflow-stubs/client/core.pyi +225 -5
- metaflow-stubs/client/filecache.pyi +3 -3
- metaflow-stubs/clone_util.pyi +5 -2
- metaflow-stubs/events.pyi +21 -3
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +70 -4
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +157 -4
- metaflow-stubs/info_file.pyi +2 -2
- metaflow-stubs/metadata/metadata.pyi +9 -3
- metaflow-stubs/metadata/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +2 -2
- metaflow-stubs/metaflow_current.pyi +8 -5
- metaflow-stubs/mflog/mflog.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/parameters.pyi +69 -3
- metaflow-stubs/plugins/__init__.pyi +13 -2
- metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow.pyi +15 -3
- metaflow-stubs/plugins/airflow/airflow_cli.pyi +66 -3
- metaflow-stubs/plugins/airflow/airflow_decorator.pyi +5 -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 +80 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +5 -2
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +45 -3
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +45 -3
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +16 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +6 -4
- metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +98 -7
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +34 -6
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +49 -4
- metaflow-stubs/plugins/aws/__init__.pyi +2 -2
- 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_cli.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +103 -3
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +16 -4
- 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/production_token.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +21 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_cli.pyi +70 -4
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_decorator.pyi +5 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +49 -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 +22 -4
- 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_cli.pyi +62 -4
- metaflow-stubs/plugins/cards/card_client.pyi +33 -2
- metaflow-stubs/plugins/cards/card_creator.pyi +5 -2
- metaflow-stubs/plugins/cards/card_datastore.pyi +8 -2
- metaflow-stubs/plugins/cards/card_decorator.pyi +53 -3
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +28 -2
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +42 -3
- metaflow-stubs/plugins/cards/card_modules/card.pyi +28 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/main.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/metadata.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/renderer.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/chevron/tokenizer.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/components.pyi +183 -3
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +5 -2
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +36 -3
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +56 -3
- metaflow-stubs/plugins/cards/exception.pyi +8 -2
- metaflow-stubs/plugins/catch_decorator.pyi +20 -3
- metaflow-stubs/plugins/datatools/__init__.pyi +63 -3
- metaflow-stubs/plugins/datatools/local.pyi +16 -2
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +72 -3
- metaflow-stubs/plugins/datatools/s3/s3.pyi +82 -5
- 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 +10 -2
- metaflow-stubs/plugins/events_decorator.pyi +107 -3
- metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
- metaflow-stubs/plugins/frameworks/pytorch.pyi +24 -3
- metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +16 -4
- 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 +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes.pyi +3 -3
- metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +66 -3
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +100 -3
- metaflow-stubs/plugins/kubernetes/kubernetes_job.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +5 -2
- metaflow-stubs/plugins/logs_cli.pyi +2 -2
- metaflow-stubs/plugins/package_cli.pyi +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +30 -3
- metaflow-stubs/plugins/project_decorator.pyi +60 -3
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +45 -2
- metaflow-stubs/plugins/pypi/conda_environment.pyi +4 -4
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +33 -2
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +3 -3
- metaflow-stubs/plugins/pypi/utils.pyi +2 -2
- metaflow-stubs/plugins/resources_decorator.pyi +33 -2
- metaflow-stubs/plugins/retry_decorator.pyi +21 -2
- metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +3 -3
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +11 -2
- metaflow-stubs/plugins/storage_executor.pyi +6 -2
- metaflow-stubs/plugins/tag_cli.pyi +35 -4
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +9 -2
- metaflow-stubs/plugins/timeout_decorator.pyi +23 -2
- metaflow-stubs/procpoll.pyi +2 -2
- metaflow-stubs/pylint_wrapper.pyi +2 -2
- metaflow-stubs/runner/__init__.pyi +2 -2
- metaflow-stubs/runner/deployer.pyi +70 -131
- metaflow-stubs/runner/metaflow_runner.pyi +116 -8
- metaflow-stubs/runner/nbdeploy.pyi +66 -2
- metaflow-stubs/runner/nbrun.pyi +79 -2
- metaflow-stubs/runner/subprocess_manager.pyi +16 -4
- metaflow-stubs/runner/utils.pyi +32 -2
- 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/version.pyi +2 -2
- {metaflow_stubs-2.12.21.dist-info → metaflow_stubs-2.12.23.dist-info}/METADATA +2 -2
- metaflow_stubs-2.12.23.dist-info/RECORD +152 -0
- metaflow_stubs-2.12.21.dist-info/RECORD +0 -152
- {metaflow_stubs-2.12.21.dist-info → metaflow_stubs-2.12.23.dist-info}/WHEEL +0 -0
- {metaflow_stubs-2.12.21.dist-info → metaflow_stubs-2.12.23.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
##################################################################################
|
2
2
|
# Auto-generated Metaflow stub file #
|
3
|
-
# MF version: 2.12.
|
4
|
-
# Generated on 2024-
|
3
|
+
# MF version: 2.12.23 #
|
4
|
+
# Generated on 2024-10-01T14:32:39.945734 #
|
5
5
|
##################################################################################
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
9
|
import typing
|
10
10
|
if typing.TYPE_CHECKING:
|
11
|
-
import metaflow.datastore.inputs
|
12
|
-
import datetime
|
13
11
|
import metaflow.plugins.datatools.s3.s3
|
14
|
-
import metaflow.runner.metaflow_runner
|
15
|
-
import metaflow.client.core
|
16
12
|
import metaflow.events
|
13
|
+
import metaflow._vendor.click.types
|
14
|
+
import io
|
15
|
+
import datetime
|
16
|
+
import metaflow.parameters
|
17
|
+
import metaflow.runner.metaflow_runner
|
18
|
+
import metaflow.datastore.inputs
|
17
19
|
import metaflow.metaflow_current
|
20
|
+
import metaflow.client.core
|
18
21
|
import metaflow.flowspec
|
19
|
-
import metaflow.parameters
|
20
|
-
import metaflow._vendor.click.types
|
21
22
|
import typing
|
22
|
-
import io
|
23
23
|
FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
|
24
24
|
StepFlag = typing.NewType("StepFlag", bool)
|
25
25
|
|
@@ -103,6 +103,14 @@ def metadata(ms: str) -> str:
|
|
103
103
|
...
|
104
104
|
|
105
105
|
class FlowSpec(object, metaclass=metaflow.flowspec._FlowSpecMeta):
|
106
|
+
"""
|
107
|
+
Main class from which all Flows should inherit.
|
108
|
+
|
109
|
+
Attributes
|
110
|
+
----------
|
111
|
+
index
|
112
|
+
input
|
113
|
+
"""
|
106
114
|
def __init__(self, use_cli = True):
|
107
115
|
"""
|
108
116
|
Construct a FlowSpec
|
@@ -324,6 +332,49 @@ class FlowSpec(object, metaclass=metaflow.flowspec._FlowSpecMeta):
|
|
324
332
|
...
|
325
333
|
|
326
334
|
class Parameter(object, metaclass=type):
|
335
|
+
"""
|
336
|
+
Defines a parameter for a flow.
|
337
|
+
|
338
|
+
Parameters must be instantiated as class variables in flow classes, e.g.
|
339
|
+
```
|
340
|
+
class MyFlow(FlowSpec):
|
341
|
+
param = Parameter('myparam')
|
342
|
+
```
|
343
|
+
in this case, the parameter is specified on the command line as
|
344
|
+
```
|
345
|
+
python myflow.py run --myparam=5
|
346
|
+
```
|
347
|
+
and its value is accessible through a read-only artifact like this:
|
348
|
+
```
|
349
|
+
print(self.param == 5)
|
350
|
+
```
|
351
|
+
Note that the user-visible parameter name, `myparam` above, can be
|
352
|
+
different from the artifact name, `param` above.
|
353
|
+
|
354
|
+
The parameter value is converted to a Python type based on the `type`
|
355
|
+
argument or to match the type of `default`, if it is set.
|
356
|
+
|
357
|
+
Parameters
|
358
|
+
----------
|
359
|
+
name : str
|
360
|
+
User-visible parameter name.
|
361
|
+
default : str or float or int or bool or `JSONType` or a function.
|
362
|
+
Default value for the parameter. Use a special `JSONType` class to
|
363
|
+
indicate that the value must be a valid JSON object. A function
|
364
|
+
implies that the parameter corresponds to a *deploy-time parameter*.
|
365
|
+
The type of the default value is used as the parameter `type`.
|
366
|
+
type : Type, default None
|
367
|
+
If `default` is not specified, define the parameter type. Specify
|
368
|
+
one of `str`, `float`, `int`, `bool`, or `JSONType`. If None, defaults
|
369
|
+
to the type of `default` or `str` if none specified.
|
370
|
+
help : str, optional
|
371
|
+
Help text to show in `run --help`.
|
372
|
+
required : bool, default False
|
373
|
+
Require that the user specified a value for the parameter.
|
374
|
+
`required=True` implies that the `default` is not used.
|
375
|
+
show_default : bool, default True
|
376
|
+
If True, show the default value in the help text.
|
377
|
+
"""
|
327
378
|
def __init__(self, name: str, default: typing.Union[str, float, int, bool, typing.Dict[str, typing.Any], typing.Callable[[], typing.Union[str, float, int, bool, typing.Dict[str, typing.Any]]], None] = None, type: typing.Union[typing.Type[str], typing.Type[float], typing.Type[int], typing.Type[bool], metaflow.parameters.JSONTypeClass, None] = None, help: typing.Optional[str] = None, required: bool = False, show_default: bool = True, **kwargs: typing.Dict[str, typing.Any]):
|
328
379
|
...
|
329
380
|
def __repr__(self):
|
@@ -353,6 +404,59 @@ class JSONTypeClass(metaflow._vendor.click.types.ParamType, metaclass=type):
|
|
353
404
|
JSONType: metaflow.parameters.JSONTypeClass
|
354
405
|
|
355
406
|
class S3(object, metaclass=type):
|
407
|
+
"""
|
408
|
+
The Metaflow S3 client.
|
409
|
+
|
410
|
+
This object manages the connection to S3 and a temporary diretory that is used
|
411
|
+
to download objects. Note that in most cases when the data fits in memory, no local
|
412
|
+
disk IO is needed as operations are cached by the operating system, which makes
|
413
|
+
operations fast as long as there is enough memory available.
|
414
|
+
|
415
|
+
The easiest way is to use this object as a context manager:
|
416
|
+
```
|
417
|
+
with S3() as s3:
|
418
|
+
data = [obj.blob for obj in s3.get_many(urls)]
|
419
|
+
print(data)
|
420
|
+
```
|
421
|
+
The context manager takes care of creating and deleting a temporary directory
|
422
|
+
automatically. Without a context manager, you must call `.close()` to delete
|
423
|
+
the directory explicitly:
|
424
|
+
```
|
425
|
+
s3 = S3()
|
426
|
+
data = [obj.blob for obj in s3.get_many(urls)]
|
427
|
+
s3.close()
|
428
|
+
```
|
429
|
+
You can customize the location of the temporary directory with `tmproot`. It
|
430
|
+
defaults to the current working directory.
|
431
|
+
|
432
|
+
To make it easier to deal with object locations, the client can be initialized
|
433
|
+
with an S3 path prefix. There are three ways to handle locations:
|
434
|
+
|
435
|
+
1. Use a `metaflow.Run` object or `self`, e.g. `S3(run=self)` which
|
436
|
+
initializes the prefix with the global `DATATOOLS_S3ROOT` path, combined
|
437
|
+
with the current run ID. This mode makes it easy to version data based
|
438
|
+
on the run ID consistently. You can use the `bucket` and `prefix` to
|
439
|
+
override parts of `DATATOOLS_S3ROOT`.
|
440
|
+
|
441
|
+
2. Specify an S3 prefix explicitly with `s3root`,
|
442
|
+
e.g. `S3(s3root='s3://mybucket/some/path')`.
|
443
|
+
|
444
|
+
3. Specify nothing, i.e. `S3()`, in which case all operations require
|
445
|
+
a full S3 url prefixed with `s3://`.
|
446
|
+
|
447
|
+
Parameters
|
448
|
+
----------
|
449
|
+
tmproot : str, default: '.'
|
450
|
+
Where to store the temporary directory.
|
451
|
+
bucket : str, optional
|
452
|
+
Override the bucket from `DATATOOLS_S3ROOT` when `run` is specified.
|
453
|
+
prefix : str, optional
|
454
|
+
Override the path from `DATATOOLS_S3ROOT` when `run` is specified.
|
455
|
+
run : FlowSpec or Run, optional
|
456
|
+
Derive path prefix from the current or a past run ID, e.g. S3(run=self).
|
457
|
+
s3root : str, optional
|
458
|
+
If `run` is not specified, use this as the S3 prefix.
|
459
|
+
"""
|
356
460
|
@classmethod
|
357
461
|
def get_root_from_config(cls, echo, create_on_absent = True):
|
358
462
|
...
|
@@ -644,6 +748,33 @@ class S3(object, metaclass=type):
|
|
644
748
|
...
|
645
749
|
|
646
750
|
class IncludeFile(metaflow.parameters.Parameter, metaclass=type):
|
751
|
+
"""
|
752
|
+
Includes a local file as a parameter for the flow.
|
753
|
+
|
754
|
+
`IncludeFile` behaves like `Parameter` except that it reads its value from a file instead of
|
755
|
+
the command line. The user provides a path to a file on the command line. The file contents
|
756
|
+
are saved as a read-only artifact which is available in all steps of the flow.
|
757
|
+
|
758
|
+
Parameters
|
759
|
+
----------
|
760
|
+
name : str
|
761
|
+
User-visible parameter name.
|
762
|
+
default : Union[str, Callable[ParameterContext, str]]
|
763
|
+
Default path to a local file. A function
|
764
|
+
implies that the parameter corresponds to a *deploy-time parameter*.
|
765
|
+
is_text : bool, default True
|
766
|
+
Convert the file contents to a string using the provided `encoding`.
|
767
|
+
If False, the artifact is stored in `bytes`.
|
768
|
+
encoding : str, optional, default 'utf-8'
|
769
|
+
Use this encoding to decode the file contexts if `is_text=True`.
|
770
|
+
required : bool, default False
|
771
|
+
Require that the user specified a value for the parameter.
|
772
|
+
`required=True` implies that the `default` is not used.
|
773
|
+
help : str, optional
|
774
|
+
Help text to show in `run --help`.
|
775
|
+
show_default : bool, default True
|
776
|
+
If True, show the default value in the help text.
|
777
|
+
"""
|
647
778
|
def __init__(self, name: str, required: bool = False, is_text: bool = True, encoding: str = "utf-8", help: typing.Optional[str] = None, **kwargs: typing.Dict[str, str]):
|
648
779
|
...
|
649
780
|
def load_parameter(self, v):
|
@@ -724,35 +855,149 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
724
855
|
...
|
725
856
|
|
726
857
|
@typing.overload
|
727
|
-
def
|
858
|
+
def batch(*, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = "METAFLOW_BATCH_JOB_QUEUE", iam_role: str = "METAFLOW_ECS_S3_ACCESS_IAM_ROLE", execution_role: str = "METAFLOW_ECS_FARGATE_EXECUTION_ROLE", shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
728
859
|
"""
|
729
|
-
Specifies
|
730
|
-
the execution of a step.
|
860
|
+
Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
|
731
861
|
|
732
862
|
Parameters
|
733
863
|
----------
|
734
|
-
|
735
|
-
|
864
|
+
cpu : int, default 1
|
865
|
+
Number of CPUs required for this step. If `@resources` is
|
866
|
+
also present, the maximum value from all decorators is used.
|
867
|
+
gpu : int, default 0
|
868
|
+
Number of GPUs required for this step. If `@resources` is
|
869
|
+
also present, the maximum value from all decorators is used.
|
870
|
+
memory : int, default 4096
|
871
|
+
Memory size (in MB) required for this step. If
|
872
|
+
`@resources` is also present, the maximum value from all decorators is
|
873
|
+
used.
|
874
|
+
image : str, optional, default None
|
875
|
+
Docker image to use when launching on AWS Batch. If not specified, and
|
876
|
+
METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
|
877
|
+
not, a default Docker image mapping to the current version of Python is used.
|
878
|
+
queue : str, default METAFLOW_BATCH_JOB_QUEUE
|
879
|
+
AWS Batch Job Queue to submit the job to.
|
880
|
+
iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
|
881
|
+
AWS IAM role that AWS Batch container uses to access AWS cloud resources.
|
882
|
+
execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
|
883
|
+
AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
|
884
|
+
(https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
|
885
|
+
shared_memory : int, optional, default None
|
886
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
887
|
+
This parameter maps to the `--shm-size` option in Docker.
|
888
|
+
max_swap : int, optional, default None
|
889
|
+
The total amount of swap memory (in MiB) a container can use for this
|
890
|
+
step. This parameter is translated to the `--memory-swap` option in
|
891
|
+
Docker where the value is the sum of the container memory plus the
|
892
|
+
`max_swap` value.
|
893
|
+
swappiness : int, optional, default None
|
894
|
+
This allows you to tune memory swappiness behavior for this step.
|
895
|
+
A swappiness value of 0 causes swapping not to happen unless absolutely
|
896
|
+
necessary. A swappiness value of 100 causes pages to be swapped very
|
897
|
+
aggressively. Accepted values are whole numbers between 0 and 100.
|
898
|
+
use_tmpfs : bool, default False
|
899
|
+
This enables an explicit tmpfs mount for this step. Note that tmpfs is
|
900
|
+
not available on Fargate compute environments
|
901
|
+
tmpfs_tempdir : bool, default True
|
902
|
+
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
903
|
+
tmpfs_size : int, optional, default None
|
904
|
+
The value for the size (in MiB) of the tmpfs mount for this step.
|
905
|
+
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
906
|
+
memory allocated for this step.
|
907
|
+
tmpfs_path : str, optional, default None
|
908
|
+
Path to tmpfs mount for this step. Defaults to /metaflow_temp.
|
909
|
+
inferentia : int, default 0
|
910
|
+
Number of Inferentia chips required for this step.
|
911
|
+
trainium : int, default None
|
912
|
+
Alias for inferentia. Use only one of the two.
|
913
|
+
efa : int, default 0
|
914
|
+
Number of elastic fabric adapter network devices to attach to container
|
915
|
+
ephemeral_storage : int, default None
|
916
|
+
The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
|
917
|
+
This is only relevant for Fargate compute environments
|
918
|
+
log_driver: str, optional, default None
|
919
|
+
The log driver to use for the Amazon ECS container.
|
920
|
+
log_options: List[str], optional, default None
|
921
|
+
List of strings containing options for the chosen log driver. The configurable values
|
922
|
+
depend on the `log driver` chosen. Validation of these options is not supported yet.
|
923
|
+
Example: [`awslogs-group:aws/batch/job`]
|
736
924
|
"""
|
737
925
|
...
|
738
926
|
|
739
927
|
@typing.overload
|
740
|
-
def
|
928
|
+
def batch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
741
929
|
...
|
742
930
|
|
743
931
|
@typing.overload
|
744
|
-
def
|
932
|
+
def batch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
745
933
|
...
|
746
934
|
|
747
|
-
def
|
935
|
+
def batch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = "METAFLOW_BATCH_JOB_QUEUE", iam_role: str = "METAFLOW_ECS_S3_ACCESS_IAM_ROLE", execution_role: str = "METAFLOW_ECS_FARGATE_EXECUTION_ROLE", shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None):
|
748
936
|
"""
|
749
|
-
Specifies
|
750
|
-
the execution of a step.
|
937
|
+
Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
|
751
938
|
|
752
939
|
Parameters
|
753
940
|
----------
|
754
|
-
|
755
|
-
|
941
|
+
cpu : int, default 1
|
942
|
+
Number of CPUs required for this step. If `@resources` is
|
943
|
+
also present, the maximum value from all decorators is used.
|
944
|
+
gpu : int, default 0
|
945
|
+
Number of GPUs required for this step. If `@resources` is
|
946
|
+
also present, the maximum value from all decorators is used.
|
947
|
+
memory : int, default 4096
|
948
|
+
Memory size (in MB) required for this step. If
|
949
|
+
`@resources` is also present, the maximum value from all decorators is
|
950
|
+
used.
|
951
|
+
image : str, optional, default None
|
952
|
+
Docker image to use when launching on AWS Batch. If not specified, and
|
953
|
+
METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
|
954
|
+
not, a default Docker image mapping to the current version of Python is used.
|
955
|
+
queue : str, default METAFLOW_BATCH_JOB_QUEUE
|
956
|
+
AWS Batch Job Queue to submit the job to.
|
957
|
+
iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
|
958
|
+
AWS IAM role that AWS Batch container uses to access AWS cloud resources.
|
959
|
+
execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
|
960
|
+
AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
|
961
|
+
(https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
|
962
|
+
shared_memory : int, optional, default None
|
963
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
964
|
+
This parameter maps to the `--shm-size` option in Docker.
|
965
|
+
max_swap : int, optional, default None
|
966
|
+
The total amount of swap memory (in MiB) a container can use for this
|
967
|
+
step. This parameter is translated to the `--memory-swap` option in
|
968
|
+
Docker where the value is the sum of the container memory plus the
|
969
|
+
`max_swap` value.
|
970
|
+
swappiness : int, optional, default None
|
971
|
+
This allows you to tune memory swappiness behavior for this step.
|
972
|
+
A swappiness value of 0 causes swapping not to happen unless absolutely
|
973
|
+
necessary. A swappiness value of 100 causes pages to be swapped very
|
974
|
+
aggressively. Accepted values are whole numbers between 0 and 100.
|
975
|
+
use_tmpfs : bool, default False
|
976
|
+
This enables an explicit tmpfs mount for this step. Note that tmpfs is
|
977
|
+
not available on Fargate compute environments
|
978
|
+
tmpfs_tempdir : bool, default True
|
979
|
+
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
980
|
+
tmpfs_size : int, optional, default None
|
981
|
+
The value for the size (in MiB) of the tmpfs mount for this step.
|
982
|
+
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
983
|
+
memory allocated for this step.
|
984
|
+
tmpfs_path : str, optional, default None
|
985
|
+
Path to tmpfs mount for this step. Defaults to /metaflow_temp.
|
986
|
+
inferentia : int, default 0
|
987
|
+
Number of Inferentia chips required for this step.
|
988
|
+
trainium : int, default None
|
989
|
+
Alias for inferentia. Use only one of the two.
|
990
|
+
efa : int, default 0
|
991
|
+
Number of elastic fabric adapter network devices to attach to container
|
992
|
+
ephemeral_storage : int, default None
|
993
|
+
The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
|
994
|
+
This is only relevant for Fargate compute environments
|
995
|
+
log_driver: str, optional, default None
|
996
|
+
The log driver to use for the Amazon ECS container.
|
997
|
+
log_options: List[str], optional, default None
|
998
|
+
List of strings containing options for the chosen log driver. The configurable values
|
999
|
+
depend on the `log driver` chosen. Validation of these options is not supported yet.
|
1000
|
+
Example: [`awslogs-group:aws/batch/job`]
|
756
1001
|
"""
|
757
1002
|
...
|
758
1003
|
|
@@ -814,135 +1059,82 @@ def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
814
1059
|
...
|
815
1060
|
|
816
1061
|
@typing.overload
|
817
|
-
def
|
1062
|
+
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]]]:
|
818
1063
|
"""
|
819
|
-
Specifies
|
1064
|
+
Specifies the PyPI packages for the step.
|
1065
|
+
|
1066
|
+
Information in this decorator will augment any
|
1067
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
1068
|
+
you can use `@pypi_base` to set packages required by all
|
1069
|
+
steps and use `@pypi` to specify step-specific overrides.
|
820
1070
|
|
821
1071
|
Parameters
|
822
1072
|
----------
|
823
|
-
|
824
|
-
|
1073
|
+
packages : Dict[str, str], default: {}
|
1074
|
+
Packages to use for this step. The key is the name of the package
|
1075
|
+
and the value is the version to use.
|
1076
|
+
python : str, optional, default: None
|
1077
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1078
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
825
1079
|
"""
|
826
1080
|
...
|
827
1081
|
|
828
1082
|
@typing.overload
|
829
|
-
def
|
1083
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
830
1084
|
...
|
831
1085
|
|
832
1086
|
@typing.overload
|
833
|
-
def
|
1087
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
834
1088
|
...
|
835
1089
|
|
836
|
-
def
|
1090
|
+
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):
|
837
1091
|
"""
|
838
|
-
Specifies
|
1092
|
+
Specifies the PyPI packages for the step.
|
1093
|
+
|
1094
|
+
Information in this decorator will augment any
|
1095
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
1096
|
+
you can use `@pypi_base` to set packages required by all
|
1097
|
+
steps and use `@pypi` to specify step-specific overrides.
|
839
1098
|
|
840
1099
|
Parameters
|
841
1100
|
----------
|
842
|
-
|
843
|
-
|
1101
|
+
packages : Dict[str, str], default: {}
|
1102
|
+
Packages to use for this step. The key is the name of the package
|
1103
|
+
and the value is the version to use.
|
1104
|
+
python : str, optional, default: None
|
1105
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1106
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
844
1107
|
"""
|
845
1108
|
...
|
846
1109
|
|
847
1110
|
@typing.overload
|
848
|
-
def
|
1111
|
+
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]]]:
|
849
1112
|
"""
|
850
|
-
Specifies
|
851
|
-
|
852
|
-
The decorator will create an optional artifact, specified by `var`, which
|
853
|
-
contains the exception raised. You can use it to detect the presence
|
854
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
855
|
-
are missing.
|
1113
|
+
Specifies environment variables to be set prior to the execution of a step.
|
856
1114
|
|
857
1115
|
Parameters
|
858
1116
|
----------
|
859
|
-
|
860
|
-
|
861
|
-
If not specified, the exception is not stored.
|
862
|
-
print_exception : bool, default True
|
863
|
-
Determines whether or not the exception is printed to
|
864
|
-
stdout when caught.
|
1117
|
+
vars : Dict[str, str], default {}
|
1118
|
+
Dictionary of environment variables to set.
|
865
1119
|
"""
|
866
1120
|
...
|
867
1121
|
|
868
1122
|
@typing.overload
|
869
|
-
def
|
1123
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
870
1124
|
...
|
871
1125
|
|
872
1126
|
@typing.overload
|
873
|
-
def
|
1127
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
874
1128
|
...
|
875
1129
|
|
876
|
-
def
|
1130
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
877
1131
|
"""
|
878
|
-
Specifies
|
879
|
-
|
880
|
-
The decorator will create an optional artifact, specified by `var`, which
|
881
|
-
contains the exception raised. You can use it to detect the presence
|
882
|
-
of errors, indicating that all happy-path artifacts produced by the step
|
883
|
-
are missing.
|
884
|
-
|
885
|
-
Parameters
|
886
|
-
----------
|
887
|
-
var : str, optional, default None
|
888
|
-
Name of the artifact in which to store the caught exception.
|
889
|
-
If not specified, the exception is not stored.
|
890
|
-
print_exception : bool, default True
|
891
|
-
Determines whether or not the exception is printed to
|
892
|
-
stdout when caught.
|
893
|
-
"""
|
894
|
-
...
|
895
|
-
|
896
|
-
@typing.overload
|
897
|
-
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]]]:
|
898
|
-
"""
|
899
|
-
Specifies the number of times the task corresponding
|
900
|
-
to a step needs to be retried.
|
901
|
-
|
902
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
903
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
904
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
905
|
-
|
906
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
907
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
908
|
-
ensuring that the flow execution can continue.
|
909
|
-
|
910
|
-
Parameters
|
911
|
-
----------
|
912
|
-
times : int, default 3
|
913
|
-
Number of times to retry this task.
|
914
|
-
minutes_between_retries : int, default 2
|
915
|
-
Number of minutes between retries.
|
916
|
-
"""
|
917
|
-
...
|
918
|
-
|
919
|
-
@typing.overload
|
920
|
-
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
921
|
-
...
|
922
|
-
|
923
|
-
@typing.overload
|
924
|
-
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
925
|
-
...
|
926
|
-
|
927
|
-
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):
|
928
|
-
"""
|
929
|
-
Specifies the number of times the task corresponding
|
930
|
-
to a step needs to be retried.
|
931
|
-
|
932
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
933
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
934
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
935
|
-
|
936
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
937
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
938
|
-
ensuring that the flow execution can continue.
|
1132
|
+
Specifies environment variables to be set prior to the execution of a step.
|
939
1133
|
|
940
1134
|
Parameters
|
941
1135
|
----------
|
942
|
-
|
943
|
-
|
944
|
-
minutes_between_retries : int, default 2
|
945
|
-
Number of minutes between retries.
|
1136
|
+
vars : Dict[str, str], default {}
|
1137
|
+
Dictionary of environment variables to set.
|
946
1138
|
"""
|
947
1139
|
...
|
948
1140
|
|
@@ -1023,604 +1215,331 @@ def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None]
|
|
1023
1215
|
"""
|
1024
1216
|
...
|
1025
1217
|
|
1026
|
-
|
1027
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1028
|
-
"""
|
1029
|
-
Decorator prototype for all step decorators. This function gets specialized
|
1030
|
-
and imported for all decorators types by _import_plugin_decorators().
|
1031
|
-
"""
|
1032
|
-
...
|
1033
|
-
|
1034
|
-
@typing.overload
|
1035
|
-
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1036
|
-
...
|
1037
|
-
|
1038
|
-
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
1039
|
-
"""
|
1040
|
-
Decorator prototype for all step decorators. This function gets specialized
|
1041
|
-
and imported for all decorators types by _import_plugin_decorators().
|
1042
|
-
"""
|
1043
|
-
...
|
1044
|
-
|
1045
|
-
@typing.overload
|
1046
|
-
def batch(*, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = "METAFLOW_BATCH_JOB_QUEUE", iam_role: str = "METAFLOW_ECS_S3_ACCESS_IAM_ROLE", execution_role: str = "METAFLOW_ECS_FARGATE_EXECUTION_ROLE", shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
1218
|
+
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = "KUBERNETES_IMAGE_PULL_POLICY", service_account: str = "METAFLOW_KUBERNETES_SERVICE_ACCOUNT", secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = "METAFLOW_KUBERNETES_NAMESPACE", gpu: typing.Optional[int] = None, gpu_vendor: str = "KUBERNETES_GPU_VENDOR", tolerations: typing.List[str] = [], 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) -> 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]]]:
|
1047
1219
|
"""
|
1048
|
-
Specifies that this step should execute on
|
1220
|
+
Specifies that this step should execute on Kubernetes.
|
1049
1221
|
|
1050
1222
|
Parameters
|
1051
1223
|
----------
|
1052
1224
|
cpu : int, default 1
|
1053
1225
|
Number of CPUs required for this step. If `@resources` is
|
1054
1226
|
also present, the maximum value from all decorators is used.
|
1055
|
-
gpu : int, default 0
|
1056
|
-
Number of GPUs required for this step. If `@resources` is
|
1057
|
-
also present, the maximum value from all decorators is used.
|
1058
1227
|
memory : int, default 4096
|
1059
1228
|
Memory size (in MB) required for this step. If
|
1060
1229
|
`@resources` is also present, the maximum value from all decorators is
|
1061
1230
|
used.
|
1231
|
+
disk : int, default 10240
|
1232
|
+
Disk size (in MB) required for this step. If
|
1233
|
+
`@resources` is also present, the maximum value from all decorators is
|
1234
|
+
used.
|
1062
1235
|
image : str, optional, default None
|
1063
|
-
Docker image to use when launching on
|
1064
|
-
|
1236
|
+
Docker image to use when launching on Kubernetes. If not specified, and
|
1237
|
+
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
1065
1238
|
not, a default Docker image mapping to the current version of Python is used.
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1239
|
+
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
1240
|
+
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
1241
|
+
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
1242
|
+
Kubernetes service account to use when launching pod in Kubernetes.
|
1243
|
+
secrets : List[str], optional, default None
|
1244
|
+
Kubernetes secrets to use when launching pod in Kubernetes. These
|
1245
|
+
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
1246
|
+
in Metaflow configuration.
|
1247
|
+
node_selector: Union[Dict[str,str], str], optional, default None
|
1248
|
+
Kubernetes node selector(s) to apply to the pod running the task.
|
1249
|
+
Can be passed in as a comma separated string of values e.g. "kubernetes.io/os=linux,kubernetes.io/arch=amd64"
|
1250
|
+
or as a dictionary {"kubernetes.io/os": "linux", "kubernetes.io/arch": "amd64"}
|
1251
|
+
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
1252
|
+
Kubernetes namespace to use when launching pod in Kubernetes.
|
1253
|
+
gpu : int, optional, default None
|
1254
|
+
Number of GPUs required for this step. A value of zero implies that
|
1255
|
+
the scheduled node should not have GPUs.
|
1256
|
+
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
1257
|
+
The vendor of the GPUs to be used for this step.
|
1258
|
+
tolerations : List[str], default []
|
1259
|
+
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
1260
|
+
Kubernetes tolerations to use when launching pod in Kubernetes.
|
1086
1261
|
use_tmpfs : bool, default False
|
1087
|
-
This enables an explicit tmpfs mount for this step.
|
1088
|
-
not available on Fargate compute environments
|
1262
|
+
This enables an explicit tmpfs mount for this step.
|
1089
1263
|
tmpfs_tempdir : bool, default True
|
1090
1264
|
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
1091
|
-
tmpfs_size : int, optional, default None
|
1265
|
+
tmpfs_size : int, optional, default: None
|
1092
1266
|
The value for the size (in MiB) of the tmpfs mount for this step.
|
1093
1267
|
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
1094
1268
|
memory allocated for this step.
|
1095
|
-
tmpfs_path : str, optional, default
|
1096
|
-
Path to tmpfs mount for this step.
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
The log driver to use for the Amazon ECS container.
|
1108
|
-
log_options: List[str], optional, default None
|
1109
|
-
List of strings containing options for the chosen log driver. The configurable values
|
1110
|
-
depend on the `log driver` chosen. Validation of these options is not supported yet.
|
1111
|
-
Example: [`awslogs-group:aws/batch/job`]
|
1269
|
+
tmpfs_path : str, optional, default /metaflow_temp
|
1270
|
+
Path to tmpfs mount for this step.
|
1271
|
+
persistent_volume_claims : Dict[str, str], optional, default None
|
1272
|
+
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
1273
|
+
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
1274
|
+
shared_memory: int, optional
|
1275
|
+
Shared memory size (in MiB) required for this step
|
1276
|
+
port: int, optional
|
1277
|
+
Port number to specify in the Kubernetes job object
|
1278
|
+
compute_pool : str, optional, default None
|
1279
|
+
Compute pool to be used for for this step.
|
1280
|
+
If not specified, any accessible compute pool within the perimeter is used.
|
1112
1281
|
"""
|
1113
1282
|
...
|
1114
1283
|
|
1115
1284
|
@typing.overload
|
1116
|
-
def
|
1285
|
+
def conda(*, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
1286
|
+
"""
|
1287
|
+
Specifies the Conda environment for the step.
|
1288
|
+
|
1289
|
+
Information in this decorator will augment any
|
1290
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
1291
|
+
you can use `@conda_base` to set packages required by all
|
1292
|
+
steps and use `@conda` to specify step-specific overrides.
|
1293
|
+
|
1294
|
+
Parameters
|
1295
|
+
----------
|
1296
|
+
packages : Dict[str, str], default {}
|
1297
|
+
Packages to use for this step. The key is the name of the package
|
1298
|
+
and the value is the version to use.
|
1299
|
+
libraries : Dict[str, str], default {}
|
1300
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1301
|
+
python : str, optional, default None
|
1302
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1303
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1304
|
+
disabled : bool, default False
|
1305
|
+
If set to True, disables @conda.
|
1306
|
+
"""
|
1117
1307
|
...
|
1118
1308
|
|
1119
1309
|
@typing.overload
|
1120
|
-
def
|
1310
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1121
1311
|
...
|
1122
1312
|
|
1123
|
-
|
1313
|
+
@typing.overload
|
1314
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1315
|
+
...
|
1316
|
+
|
1317
|
+
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
1124
1318
|
"""
|
1125
|
-
Specifies
|
1319
|
+
Specifies the Conda environment for the step.
|
1320
|
+
|
1321
|
+
Information in this decorator will augment any
|
1322
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
1323
|
+
you can use `@conda_base` to set packages required by all
|
1324
|
+
steps and use `@conda` to specify step-specific overrides.
|
1126
1325
|
|
1127
1326
|
Parameters
|
1128
1327
|
----------
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
image : str, optional, default None
|
1140
|
-
Docker image to use when launching on AWS Batch. If not specified, and
|
1141
|
-
METAFLOW_BATCH_CONTAINER_IMAGE is specified, that image is used. If
|
1142
|
-
not, a default Docker image mapping to the current version of Python is used.
|
1143
|
-
queue : str, default METAFLOW_BATCH_JOB_QUEUE
|
1144
|
-
AWS Batch Job Queue to submit the job to.
|
1145
|
-
iam_role : str, default METAFLOW_ECS_S3_ACCESS_IAM_ROLE
|
1146
|
-
AWS IAM role that AWS Batch container uses to access AWS cloud resources.
|
1147
|
-
execution_role : str, default METAFLOW_ECS_FARGATE_EXECUTION_ROLE
|
1148
|
-
AWS IAM role that AWS Batch can use [to trigger AWS Fargate tasks]
|
1149
|
-
(https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html).
|
1150
|
-
shared_memory : int, optional, default None
|
1151
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
1152
|
-
This parameter maps to the `--shm-size` option in Docker.
|
1153
|
-
max_swap : int, optional, default None
|
1154
|
-
The total amount of swap memory (in MiB) a container can use for this
|
1155
|
-
step. This parameter is translated to the `--memory-swap` option in
|
1156
|
-
Docker where the value is the sum of the container memory plus the
|
1157
|
-
`max_swap` value.
|
1158
|
-
swappiness : int, optional, default None
|
1159
|
-
This allows you to tune memory swappiness behavior for this step.
|
1160
|
-
A swappiness value of 0 causes swapping not to happen unless absolutely
|
1161
|
-
necessary. A swappiness value of 100 causes pages to be swapped very
|
1162
|
-
aggressively. Accepted values are whole numbers between 0 and 100.
|
1163
|
-
use_tmpfs : bool, default False
|
1164
|
-
This enables an explicit tmpfs mount for this step. Note that tmpfs is
|
1165
|
-
not available on Fargate compute environments
|
1166
|
-
tmpfs_tempdir : bool, default True
|
1167
|
-
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
1168
|
-
tmpfs_size : int, optional, default None
|
1169
|
-
The value for the size (in MiB) of the tmpfs mount for this step.
|
1170
|
-
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
1171
|
-
memory allocated for this step.
|
1172
|
-
tmpfs_path : str, optional, default None
|
1173
|
-
Path to tmpfs mount for this step. Defaults to /metaflow_temp.
|
1174
|
-
inferentia : int, default 0
|
1175
|
-
Number of Inferentia chips required for this step.
|
1176
|
-
trainium : int, default None
|
1177
|
-
Alias for inferentia. Use only one of the two.
|
1178
|
-
efa : int, default 0
|
1179
|
-
Number of elastic fabric adapter network devices to attach to container
|
1180
|
-
ephemeral_storage : int, default None
|
1181
|
-
The total amount, in GiB, of ephemeral storage to set for the task, 21-200GiB.
|
1182
|
-
This is only relevant for Fargate compute environments
|
1183
|
-
log_driver: str, optional, default None
|
1184
|
-
The log driver to use for the Amazon ECS container.
|
1185
|
-
log_options: List[str], optional, default None
|
1186
|
-
List of strings containing options for the chosen log driver. The configurable values
|
1187
|
-
depend on the `log driver` chosen. Validation of these options is not supported yet.
|
1188
|
-
Example: [`awslogs-group:aws/batch/job`]
|
1328
|
+
packages : Dict[str, str], default {}
|
1329
|
+
Packages to use for this step. The key is the name of the package
|
1330
|
+
and the value is the version to use.
|
1331
|
+
libraries : Dict[str, str], default {}
|
1332
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1333
|
+
python : str, optional, default None
|
1334
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1335
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1336
|
+
disabled : bool, default False
|
1337
|
+
If set to True, disables @conda.
|
1189
1338
|
"""
|
1190
1339
|
...
|
1191
1340
|
|
1192
1341
|
@typing.overload
|
1193
|
-
def
|
1342
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1194
1343
|
"""
|
1195
|
-
|
1196
|
-
|
1197
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
1198
|
-
|
1199
|
-
Parameters
|
1200
|
-
----------
|
1201
|
-
type : str, default 'default'
|
1202
|
-
Card type.
|
1203
|
-
id : str, optional, default None
|
1204
|
-
If multiple cards are present, use this id to identify this card.
|
1205
|
-
options : Dict[str, Any], default {}
|
1206
|
-
Options passed to the card. The contents depend on the card type.
|
1207
|
-
timeout : int, default 45
|
1208
|
-
Interrupt reporting if it takes more than this many seconds.
|
1209
|
-
|
1210
|
-
|
1344
|
+
Decorator prototype for all step decorators. This function gets specialized
|
1345
|
+
and imported for all decorators types by _import_plugin_decorators().
|
1211
1346
|
"""
|
1212
1347
|
...
|
1213
1348
|
|
1214
1349
|
@typing.overload
|
1215
|
-
def
|
1216
|
-
...
|
1217
|
-
|
1218
|
-
@typing.overload
|
1219
|
-
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1350
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1220
1351
|
...
|
1221
1352
|
|
1222
|
-
def
|
1353
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
1223
1354
|
"""
|
1224
|
-
|
1225
|
-
|
1226
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
1227
|
-
|
1228
|
-
Parameters
|
1229
|
-
----------
|
1230
|
-
type : str, default 'default'
|
1231
|
-
Card type.
|
1232
|
-
id : str, optional, default None
|
1233
|
-
If multiple cards are present, use this id to identify this card.
|
1234
|
-
options : Dict[str, Any], default {}
|
1235
|
-
Options passed to the card. The contents depend on the card type.
|
1236
|
-
timeout : int, default 45
|
1237
|
-
Interrupt reporting if it takes more than this many seconds.
|
1238
|
-
|
1239
|
-
|
1355
|
+
Decorator prototype for all step decorators. This function gets specialized
|
1356
|
+
and imported for all decorators types by _import_plugin_decorators().
|
1240
1357
|
"""
|
1241
1358
|
...
|
1242
1359
|
|
1243
1360
|
@typing.overload
|
1244
|
-
def
|
1361
|
+
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]]]:
|
1245
1362
|
"""
|
1246
|
-
Specifies the
|
1363
|
+
Specifies the number of times the task corresponding
|
1364
|
+
to a step needs to be retried.
|
1247
1365
|
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1366
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
1367
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
1368
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
1369
|
+
|
1370
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
1371
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
1372
|
+
ensuring that the flow execution can continue.
|
1252
1373
|
|
1253
1374
|
Parameters
|
1254
1375
|
----------
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1260
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1376
|
+
times : int, default 3
|
1377
|
+
Number of times to retry this task.
|
1378
|
+
minutes_between_retries : int, default 2
|
1379
|
+
Number of minutes between retries.
|
1261
1380
|
"""
|
1262
1381
|
...
|
1263
1382
|
|
1264
1383
|
@typing.overload
|
1265
|
-
def
|
1384
|
+
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1266
1385
|
...
|
1267
1386
|
|
1268
1387
|
@typing.overload
|
1269
|
-
def
|
1388
|
+
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1270
1389
|
...
|
1271
1390
|
|
1272
|
-
def
|
1391
|
+
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):
|
1273
1392
|
"""
|
1274
|
-
Specifies the
|
1393
|
+
Specifies the number of times the task corresponding
|
1394
|
+
to a step needs to be retried.
|
1275
1395
|
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1396
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
1397
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
1398
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
1399
|
+
|
1400
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
1401
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
1402
|
+
ensuring that the flow execution can continue.
|
1280
1403
|
|
1281
1404
|
Parameters
|
1282
1405
|
----------
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1288
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1406
|
+
times : int, default 3
|
1407
|
+
Number of times to retry this task.
|
1408
|
+
minutes_between_retries : int, default 2
|
1409
|
+
Number of minutes between retries.
|
1289
1410
|
"""
|
1290
1411
|
...
|
1291
1412
|
|
1292
1413
|
@typing.overload
|
1293
|
-
def
|
1414
|
+
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]]]:
|
1294
1415
|
"""
|
1295
|
-
Specifies the
|
1416
|
+
Specifies that the step will success under all circumstances.
|
1296
1417
|
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1418
|
+
The decorator will create an optional artifact, specified by `var`, which
|
1419
|
+
contains the exception raised. You can use it to detect the presence
|
1420
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
1421
|
+
are missing.
|
1301
1422
|
|
1302
1423
|
Parameters
|
1303
1424
|
----------
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1311
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1312
|
-
disabled : bool, default False
|
1313
|
-
If set to True, disables @conda.
|
1425
|
+
var : str, optional, default None
|
1426
|
+
Name of the artifact in which to store the caught exception.
|
1427
|
+
If not specified, the exception is not stored.
|
1428
|
+
print_exception : bool, default True
|
1429
|
+
Determines whether or not the exception is printed to
|
1430
|
+
stdout when caught.
|
1314
1431
|
"""
|
1315
1432
|
...
|
1316
1433
|
|
1317
1434
|
@typing.overload
|
1318
|
-
def
|
1435
|
+
def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1319
1436
|
...
|
1320
1437
|
|
1321
1438
|
@typing.overload
|
1322
|
-
def
|
1323
|
-
...
|
1324
|
-
|
1325
|
-
def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
1326
|
-
"""
|
1327
|
-
Specifies the Conda environment for the step.
|
1328
|
-
|
1329
|
-
Information in this decorator will augment any
|
1330
|
-
attributes set in the `@conda_base` flow-level decorator. Hence,
|
1331
|
-
you can use `@conda_base` to set packages required by all
|
1332
|
-
steps and use `@conda` to specify step-specific overrides.
|
1333
|
-
|
1334
|
-
Parameters
|
1335
|
-
----------
|
1336
|
-
packages : Dict[str, str], default {}
|
1337
|
-
Packages to use for this step. The key is the name of the package
|
1338
|
-
and the value is the version to use.
|
1339
|
-
libraries : Dict[str, str], default {}
|
1340
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1341
|
-
python : str, optional, default None
|
1342
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1343
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1344
|
-
disabled : bool, default False
|
1345
|
-
If set to True, disables @conda.
|
1346
|
-
"""
|
1347
|
-
...
|
1348
|
-
|
1349
|
-
def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = "KUBERNETES_IMAGE_PULL_POLICY", service_account: str = "METAFLOW_KUBERNETES_SERVICE_ACCOUNT", secrets: typing.Optional[typing.List[str]] = None, node_selector: typing.Union[typing.Dict[str, str], str, None] = None, namespace: str = "METAFLOW_KUBERNETES_NAMESPACE", gpu: typing.Optional[int] = None, gpu_vendor: str = "KUBERNETES_GPU_VENDOR", tolerations: typing.List[str] = [], 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) -> 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]]]:
|
1350
|
-
"""
|
1351
|
-
Specifies that this step should execute on Kubernetes.
|
1352
|
-
|
1353
|
-
Parameters
|
1354
|
-
----------
|
1355
|
-
cpu : int, default 1
|
1356
|
-
Number of CPUs required for this step. If `@resources` is
|
1357
|
-
also present, the maximum value from all decorators is used.
|
1358
|
-
memory : int, default 4096
|
1359
|
-
Memory size (in MB) required for this step. If
|
1360
|
-
`@resources` is also present, the maximum value from all decorators is
|
1361
|
-
used.
|
1362
|
-
disk : int, default 10240
|
1363
|
-
Disk size (in MB) required for this step. If
|
1364
|
-
`@resources` is also present, the maximum value from all decorators is
|
1365
|
-
used.
|
1366
|
-
image : str, optional, default None
|
1367
|
-
Docker image to use when launching on Kubernetes. If not specified, and
|
1368
|
-
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
1369
|
-
not, a default Docker image mapping to the current version of Python is used.
|
1370
|
-
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
1371
|
-
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
1372
|
-
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
1373
|
-
Kubernetes service account to use when launching pod in Kubernetes.
|
1374
|
-
secrets : List[str], optional, default None
|
1375
|
-
Kubernetes secrets to use when launching pod in Kubernetes. These
|
1376
|
-
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
1377
|
-
in Metaflow configuration.
|
1378
|
-
node_selector: Union[Dict[str,str], str], optional, default None
|
1379
|
-
Kubernetes node selector(s) to apply to the pod running the task.
|
1380
|
-
Can be passed in as a comma separated string of values e.g. "kubernetes.io/os=linux,kubernetes.io/arch=amd64"
|
1381
|
-
or as a dictionary {"kubernetes.io/os": "linux", "kubernetes.io/arch": "amd64"}
|
1382
|
-
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
1383
|
-
Kubernetes namespace to use when launching pod in Kubernetes.
|
1384
|
-
gpu : int, optional, default None
|
1385
|
-
Number of GPUs required for this step. A value of zero implies that
|
1386
|
-
the scheduled node should not have GPUs.
|
1387
|
-
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
1388
|
-
The vendor of the GPUs to be used for this step.
|
1389
|
-
tolerations : List[str], default []
|
1390
|
-
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
1391
|
-
Kubernetes tolerations to use when launching pod in Kubernetes.
|
1392
|
-
use_tmpfs : bool, default False
|
1393
|
-
This enables an explicit tmpfs mount for this step.
|
1394
|
-
tmpfs_tempdir : bool, default True
|
1395
|
-
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
1396
|
-
tmpfs_size : int, optional, default: None
|
1397
|
-
The value for the size (in MiB) of the tmpfs mount for this step.
|
1398
|
-
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
1399
|
-
memory allocated for this step.
|
1400
|
-
tmpfs_path : str, optional, default /metaflow_temp
|
1401
|
-
Path to tmpfs mount for this step.
|
1402
|
-
persistent_volume_claims : Dict[str, str], optional, default None
|
1403
|
-
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
1404
|
-
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
1405
|
-
shared_memory: int, optional
|
1406
|
-
Shared memory size (in MiB) required for this step
|
1407
|
-
port: int, optional
|
1408
|
-
Port number to specify in the Kubernetes job object
|
1409
|
-
compute_pool : str, optional, default None
|
1410
|
-
Compute pool to be used for for this step.
|
1411
|
-
If not specified, any accessible compute pool within the perimeter is used.
|
1412
|
-
"""
|
1413
|
-
...
|
1414
|
-
|
1415
|
-
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]]:
|
1416
|
-
"""
|
1417
|
-
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)
|
1418
|
-
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1419
|
-
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1420
|
-
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1421
|
-
starts only after all sensors finish.
|
1422
|
-
|
1423
|
-
Parameters
|
1424
|
-
----------
|
1425
|
-
timeout : int
|
1426
|
-
Time, in seconds before the task times out and fails. (Default: 3600)
|
1427
|
-
poke_interval : int
|
1428
|
-
Time in seconds that the job should wait in between each try. (Default: 60)
|
1429
|
-
mode : str
|
1430
|
-
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1431
|
-
exponential_backoff : bool
|
1432
|
-
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1433
|
-
pool : str
|
1434
|
-
the slot pool this task should run in,
|
1435
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1436
|
-
soft_fail : bool
|
1437
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1438
|
-
name : str
|
1439
|
-
Name of the sensor on Airflow
|
1440
|
-
description : str
|
1441
|
-
Description of sensor in the Airflow UI
|
1442
|
-
bucket_key : Union[str, List[str]]
|
1443
|
-
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1444
|
-
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1445
|
-
bucket_name : str
|
1446
|
-
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1447
|
-
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1448
|
-
wildcard_match : bool
|
1449
|
-
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1450
|
-
aws_conn_id : str
|
1451
|
-
a reference to the s3 connection on Airflow. (Default: None)
|
1452
|
-
verify : bool
|
1453
|
-
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1454
|
-
"""
|
1439
|
+
def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1455
1440
|
...
|
1456
1441
|
|
1457
|
-
|
1458
|
-
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]]:
|
1442
|
+
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):
|
1459
1443
|
"""
|
1460
|
-
Specifies the
|
1461
|
-
|
1462
|
-
```
|
1463
|
-
@trigger_on_finish(flow='FooFlow')
|
1464
|
-
```
|
1465
|
-
or
|
1466
|
-
```
|
1467
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1468
|
-
```
|
1469
|
-
This decorator respects the @project decorator and triggers the flow
|
1470
|
-
when upstream runs within the same namespace complete successfully
|
1471
|
-
|
1472
|
-
Additionally, you can specify project aware upstream flow dependencies
|
1473
|
-
by specifying the fully qualified project_flow_name.
|
1474
|
-
```
|
1475
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1476
|
-
```
|
1477
|
-
or
|
1478
|
-
```
|
1479
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1480
|
-
```
|
1481
|
-
|
1482
|
-
You can also specify just the project or project branch (other values will be
|
1483
|
-
inferred from the current project or project branch):
|
1484
|
-
```
|
1485
|
-
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1486
|
-
```
|
1444
|
+
Specifies that the step will success under all circumstances.
|
1487
1445
|
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
- `prod.staging`
|
1446
|
+
The decorator will create an optional artifact, specified by `var`, which
|
1447
|
+
contains the exception raised. You can use it to detect the presence
|
1448
|
+
of errors, indicating that all happy-path artifacts produced by the step
|
1449
|
+
are missing.
|
1493
1450
|
|
1494
1451
|
Parameters
|
1495
1452
|
----------
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1453
|
+
var : str, optional, default None
|
1454
|
+
Name of the artifact in which to store the caught exception.
|
1455
|
+
If not specified, the exception is not stored.
|
1456
|
+
print_exception : bool, default True
|
1457
|
+
Determines whether or not the exception is printed to
|
1458
|
+
stdout when caught.
|
1504
1459
|
"""
|
1505
1460
|
...
|
1506
1461
|
|
1507
|
-
@typing.overload
|
1508
|
-
def
|
1509
|
-
|
1510
|
-
|
1511
|
-
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] = {}):
|
1512
|
-
"""
|
1513
|
-
Specifies the flow(s) that this flow depends on.
|
1514
|
-
|
1515
|
-
```
|
1516
|
-
@trigger_on_finish(flow='FooFlow')
|
1517
|
-
```
|
1518
|
-
or
|
1519
|
-
```
|
1520
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1521
|
-
```
|
1522
|
-
This decorator respects the @project decorator and triggers the flow
|
1523
|
-
when upstream runs within the same namespace complete successfully
|
1524
|
-
|
1525
|
-
Additionally, you can specify project aware upstream flow dependencies
|
1526
|
-
by specifying the fully qualified project_flow_name.
|
1527
|
-
```
|
1528
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1529
|
-
```
|
1530
|
-
or
|
1531
|
-
```
|
1532
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1533
|
-
```
|
1534
|
-
|
1535
|
-
You can also specify just the project or project branch (other values will be
|
1536
|
-
inferred from the current project or project branch):
|
1537
|
-
```
|
1538
|
-
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1539
|
-
```
|
1462
|
+
@typing.overload
|
1463
|
+
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]]]:
|
1464
|
+
"""
|
1465
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
1540
1466
|
|
1541
|
-
Note that `
|
1542
|
-
- `prod`
|
1543
|
-
- `user.bob`
|
1544
|
-
- `test.my_experiment`
|
1545
|
-
- `prod.staging`
|
1467
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
1546
1468
|
|
1547
1469
|
Parameters
|
1548
1470
|
----------
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1471
|
+
type : str, default 'default'
|
1472
|
+
Card type.
|
1473
|
+
id : str, optional, default None
|
1474
|
+
If multiple cards are present, use this id to identify this card.
|
1553
1475
|
options : Dict[str, Any], default {}
|
1554
|
-
|
1476
|
+
Options passed to the card. The contents depend on the card type.
|
1477
|
+
timeout : int, default 45
|
1478
|
+
Interrupt reporting if it takes more than this many seconds.
|
1555
1479
|
|
1556
1480
|
|
1557
1481
|
"""
|
1558
1482
|
...
|
1559
1483
|
|
1560
|
-
|
1484
|
+
@typing.overload
|
1485
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1486
|
+
...
|
1487
|
+
|
1488
|
+
@typing.overload
|
1489
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1490
|
+
...
|
1491
|
+
|
1492
|
+
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):
|
1561
1493
|
"""
|
1562
|
-
|
1494
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
1563
1495
|
|
1564
|
-
|
1565
|
-
use the same `@project(name)`.
|
1496
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
1566
1497
|
|
1567
1498
|
Parameters
|
1568
1499
|
----------
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1500
|
+
type : str, default 'default'
|
1501
|
+
Card type.
|
1502
|
+
id : str, optional, default None
|
1503
|
+
If multiple cards are present, use this id to identify this card.
|
1504
|
+
options : Dict[str, Any], default {}
|
1505
|
+
Options passed to the card. The contents depend on the card type.
|
1506
|
+
timeout : int, default 45
|
1507
|
+
Interrupt reporting if it takes more than this many seconds.
|
1573
1508
|
|
1574
1509
|
|
1575
1510
|
"""
|
1576
1511
|
...
|
1577
1512
|
|
1578
1513
|
@typing.overload
|
1579
|
-
def
|
1514
|
+
def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
1580
1515
|
"""
|
1581
|
-
Specifies
|
1582
|
-
|
1516
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
1517
|
+
the execution of a step.
|
1583
1518
|
|
1584
1519
|
Parameters
|
1585
1520
|
----------
|
1586
|
-
|
1587
|
-
|
1588
|
-
daily : bool, default True
|
1589
|
-
Run the workflow daily.
|
1590
|
-
weekly : bool, default False
|
1591
|
-
Run the workflow weekly.
|
1592
|
-
cron : str, optional, default None
|
1593
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1594
|
-
specified by this expression.
|
1595
|
-
timezone : str, optional, default None
|
1596
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1597
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1521
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
1522
|
+
List of secret specs, defining how the secrets are to be retrieved
|
1598
1523
|
"""
|
1599
1524
|
...
|
1600
1525
|
|
1601
1526
|
@typing.overload
|
1602
|
-
def
|
1527
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1603
1528
|
...
|
1604
1529
|
|
1605
|
-
|
1530
|
+
@typing.overload
|
1531
|
+
def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1532
|
+
...
|
1533
|
+
|
1534
|
+
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]]] = []):
|
1606
1535
|
"""
|
1607
|
-
Specifies
|
1608
|
-
|
1536
|
+
Specifies secrets to be retrieved and injected as environment variables prior to
|
1537
|
+
the execution of a step.
|
1609
1538
|
|
1610
1539
|
Parameters
|
1611
1540
|
----------
|
1612
|
-
|
1613
|
-
|
1614
|
-
daily : bool, default True
|
1615
|
-
Run the workflow daily.
|
1616
|
-
weekly : bool, default False
|
1617
|
-
Run the workflow weekly.
|
1618
|
-
cron : str, optional, default None
|
1619
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1620
|
-
specified by this expression.
|
1621
|
-
timezone : str, optional, default None
|
1622
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1623
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1541
|
+
sources : List[Union[str, Dict[str, Any]]], default: []
|
1542
|
+
List of secret specs, defining how the secrets are to be retrieved
|
1624
1543
|
"""
|
1625
1544
|
...
|
1626
1545
|
|
@@ -1663,6 +1582,161 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
|
|
1663
1582
|
"""
|
1664
1583
|
...
|
1665
1584
|
|
1585
|
+
@typing.overload
|
1586
|
+
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]]:
|
1587
|
+
"""
|
1588
|
+
Specifies the event(s) that this flow depends on.
|
1589
|
+
|
1590
|
+
```
|
1591
|
+
@trigger(event='foo')
|
1592
|
+
```
|
1593
|
+
or
|
1594
|
+
```
|
1595
|
+
@trigger(events=['foo', 'bar'])
|
1596
|
+
```
|
1597
|
+
|
1598
|
+
Additionally, you can specify the parameter mappings
|
1599
|
+
to map event payload to Metaflow parameters for the flow.
|
1600
|
+
```
|
1601
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1602
|
+
```
|
1603
|
+
or
|
1604
|
+
```
|
1605
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1606
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1607
|
+
```
|
1608
|
+
|
1609
|
+
'parameters' can also be a list of strings and tuples like so:
|
1610
|
+
```
|
1611
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1612
|
+
```
|
1613
|
+
This is equivalent to:
|
1614
|
+
```
|
1615
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1616
|
+
```
|
1617
|
+
|
1618
|
+
Parameters
|
1619
|
+
----------
|
1620
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
1621
|
+
Event dependency for this flow.
|
1622
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
1623
|
+
Events dependency for this flow.
|
1624
|
+
options : Dict[str, Any], default {}
|
1625
|
+
Backend-specific configuration for tuning eventing behavior.
|
1626
|
+
|
1627
|
+
|
1628
|
+
"""
|
1629
|
+
...
|
1630
|
+
|
1631
|
+
@typing.overload
|
1632
|
+
def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1633
|
+
...
|
1634
|
+
|
1635
|
+
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] = {}):
|
1636
|
+
"""
|
1637
|
+
Specifies the event(s) that this flow depends on.
|
1638
|
+
|
1639
|
+
```
|
1640
|
+
@trigger(event='foo')
|
1641
|
+
```
|
1642
|
+
or
|
1643
|
+
```
|
1644
|
+
@trigger(events=['foo', 'bar'])
|
1645
|
+
```
|
1646
|
+
|
1647
|
+
Additionally, you can specify the parameter mappings
|
1648
|
+
to map event payload to Metaflow parameters for the flow.
|
1649
|
+
```
|
1650
|
+
@trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
|
1651
|
+
```
|
1652
|
+
or
|
1653
|
+
```
|
1654
|
+
@trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
|
1655
|
+
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1656
|
+
```
|
1657
|
+
|
1658
|
+
'parameters' can also be a list of strings and tuples like so:
|
1659
|
+
```
|
1660
|
+
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1661
|
+
```
|
1662
|
+
This is equivalent to:
|
1663
|
+
```
|
1664
|
+
@trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
|
1665
|
+
```
|
1666
|
+
|
1667
|
+
Parameters
|
1668
|
+
----------
|
1669
|
+
event : Union[str, Dict[str, Any]], optional, default None
|
1670
|
+
Event dependency for this flow.
|
1671
|
+
events : List[Union[str, Dict[str, Any]]], default []
|
1672
|
+
Events dependency for this flow.
|
1673
|
+
options : Dict[str, Any], default {}
|
1674
|
+
Backend-specific configuration for tuning eventing behavior.
|
1675
|
+
|
1676
|
+
|
1677
|
+
"""
|
1678
|
+
...
|
1679
|
+
|
1680
|
+
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]]:
|
1681
|
+
"""
|
1682
|
+
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)
|
1683
|
+
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1684
|
+
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1685
|
+
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1686
|
+
starts only after all sensors finish.
|
1687
|
+
|
1688
|
+
Parameters
|
1689
|
+
----------
|
1690
|
+
timeout : int
|
1691
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1692
|
+
poke_interval : int
|
1693
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1694
|
+
mode : str
|
1695
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1696
|
+
exponential_backoff : bool
|
1697
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1698
|
+
pool : str
|
1699
|
+
the slot pool this task should run in,
|
1700
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1701
|
+
soft_fail : bool
|
1702
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1703
|
+
name : str
|
1704
|
+
Name of the sensor on Airflow
|
1705
|
+
description : str
|
1706
|
+
Description of sensor in the Airflow UI
|
1707
|
+
bucket_key : Union[str, List[str]]
|
1708
|
+
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1709
|
+
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1710
|
+
bucket_name : str
|
1711
|
+
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1712
|
+
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1713
|
+
wildcard_match : bool
|
1714
|
+
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1715
|
+
aws_conn_id : str
|
1716
|
+
a reference to the s3 connection on Airflow. (Default: None)
|
1717
|
+
verify : bool
|
1718
|
+
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1719
|
+
"""
|
1720
|
+
...
|
1721
|
+
|
1722
|
+
def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1723
|
+
"""
|
1724
|
+
Specifies what flows belong to the same project.
|
1725
|
+
|
1726
|
+
A project-specific namespace is created for all flows that
|
1727
|
+
use the same `@project(name)`.
|
1728
|
+
|
1729
|
+
Parameters
|
1730
|
+
----------
|
1731
|
+
name : str
|
1732
|
+
Project name. Make sure that the name is unique amongst all
|
1733
|
+
projects that use the same production scheduler. The name may
|
1734
|
+
contain only lowercase alphanumeric characters and underscores.
|
1735
|
+
|
1736
|
+
|
1737
|
+
"""
|
1738
|
+
...
|
1739
|
+
|
1666
1740
|
@typing.overload
|
1667
1741
|
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]]:
|
1668
1742
|
"""
|
@@ -1712,45 +1786,91 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
|
|
1712
1786
|
"""
|
1713
1787
|
...
|
1714
1788
|
|
1789
|
+
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]]:
|
1790
|
+
"""
|
1791
|
+
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.
|
1792
|
+
This decorator only works when a flow is scheduled on Airflow and is compiled using `airflow create`. More than one `@airflow_external_task_sensor` can be added as a flow decorators. Adding more than one decorator will ensure that `start` step starts only after all sensors finish.
|
1793
|
+
|
1794
|
+
Parameters
|
1795
|
+
----------
|
1796
|
+
timeout : int
|
1797
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1798
|
+
poke_interval : int
|
1799
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1800
|
+
mode : str
|
1801
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1802
|
+
exponential_backoff : bool
|
1803
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1804
|
+
pool : str
|
1805
|
+
the slot pool this task should run in,
|
1806
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1807
|
+
soft_fail : bool
|
1808
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1809
|
+
name : str
|
1810
|
+
Name of the sensor on Airflow
|
1811
|
+
description : str
|
1812
|
+
Description of sensor in the Airflow UI
|
1813
|
+
external_dag_id : str
|
1814
|
+
The dag_id that contains the task you want to wait for.
|
1815
|
+
external_task_ids : List[str]
|
1816
|
+
The list of task_ids that you want to wait for.
|
1817
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
1818
|
+
allowed_states : List[str]
|
1819
|
+
Iterable of allowed states, (Default: ['success'])
|
1820
|
+
failed_states : List[str]
|
1821
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
1822
|
+
execution_delta : datetime.timedelta
|
1823
|
+
time difference with the previous execution to look at,
|
1824
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
1825
|
+
check_existence: bool
|
1826
|
+
Set to True to check if the external task exists or check if
|
1827
|
+
the DAG to wait for exists. (Default: True)
|
1828
|
+
"""
|
1829
|
+
...
|
1830
|
+
|
1715
1831
|
@typing.overload
|
1716
|
-
def
|
1832
|
+
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]]:
|
1717
1833
|
"""
|
1718
|
-
Specifies the
|
1834
|
+
Specifies the flow(s) that this flow depends on.
|
1719
1835
|
|
1720
1836
|
```
|
1721
|
-
@
|
1837
|
+
@trigger_on_finish(flow='FooFlow')
|
1722
1838
|
```
|
1723
1839
|
or
|
1724
1840
|
```
|
1725
|
-
@
|
1841
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1726
1842
|
```
|
1843
|
+
This decorator respects the @project decorator and triggers the flow
|
1844
|
+
when upstream runs within the same namespace complete successfully
|
1727
1845
|
|
1728
|
-
Additionally, you can specify
|
1729
|
-
|
1846
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1847
|
+
by specifying the fully qualified project_flow_name.
|
1730
1848
|
```
|
1731
|
-
@
|
1849
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1732
1850
|
```
|
1733
1851
|
or
|
1734
1852
|
```
|
1735
|
-
@
|
1736
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1853
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1737
1854
|
```
|
1738
1855
|
|
1739
|
-
|
1740
|
-
|
1741
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1742
|
-
```
|
1743
|
-
This is equivalent to:
|
1856
|
+
You can also specify just the project or project branch (other values will be
|
1857
|
+
inferred from the current project or project branch):
|
1744
1858
|
```
|
1745
|
-
@
|
1859
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1746
1860
|
```
|
1747
1861
|
|
1862
|
+
Note that `branch` is typically one of:
|
1863
|
+
- `prod`
|
1864
|
+
- `user.bob`
|
1865
|
+
- `test.my_experiment`
|
1866
|
+
- `prod.staging`
|
1867
|
+
|
1748
1868
|
Parameters
|
1749
1869
|
----------
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1870
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1871
|
+
Upstream flow dependency for this flow.
|
1872
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1873
|
+
Upstream flow dependencies for this flow.
|
1754
1874
|
options : Dict[str, Any], default {}
|
1755
1875
|
Backend-specific configuration for tuning eventing behavior.
|
1756
1876
|
|
@@ -1759,47 +1879,51 @@ def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = No
|
|
1759
1879
|
...
|
1760
1880
|
|
1761
1881
|
@typing.overload
|
1762
|
-
def
|
1882
|
+
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1763
1883
|
...
|
1764
1884
|
|
1765
|
-
def
|
1885
|
+
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] = {}):
|
1766
1886
|
"""
|
1767
|
-
Specifies the
|
1887
|
+
Specifies the flow(s) that this flow depends on.
|
1768
1888
|
|
1769
1889
|
```
|
1770
|
-
@
|
1890
|
+
@trigger_on_finish(flow='FooFlow')
|
1771
1891
|
```
|
1772
1892
|
or
|
1773
1893
|
```
|
1774
|
-
@
|
1894
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1775
1895
|
```
|
1896
|
+
This decorator respects the @project decorator and triggers the flow
|
1897
|
+
when upstream runs within the same namespace complete successfully
|
1776
1898
|
|
1777
|
-
Additionally, you can specify
|
1778
|
-
|
1899
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1900
|
+
by specifying the fully qualified project_flow_name.
|
1779
1901
|
```
|
1780
|
-
@
|
1902
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1781
1903
|
```
|
1782
1904
|
or
|
1783
1905
|
```
|
1784
|
-
@
|
1785
|
-
{'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
|
1906
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1786
1907
|
```
|
1787
1908
|
|
1788
|
-
|
1789
|
-
|
1790
|
-
@trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
|
1791
|
-
```
|
1792
|
-
This is equivalent to:
|
1909
|
+
You can also specify just the project or project branch (other values will be
|
1910
|
+
inferred from the current project or project branch):
|
1793
1911
|
```
|
1794
|
-
@
|
1912
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1795
1913
|
```
|
1796
1914
|
|
1915
|
+
Note that `branch` is typically one of:
|
1916
|
+
- `prod`
|
1917
|
+
- `user.bob`
|
1918
|
+
- `test.my_experiment`
|
1919
|
+
- `prod.staging`
|
1920
|
+
|
1797
1921
|
Parameters
|
1798
1922
|
----------
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1923
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1924
|
+
Upstream flow dependency for this flow.
|
1925
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1926
|
+
Upstream flow dependencies for this flow.
|
1803
1927
|
options : Dict[str, Any], default {}
|
1804
1928
|
Backend-specific configuration for tuning eventing behavior.
|
1805
1929
|
|
@@ -1807,45 +1931,52 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
|
|
1807
1931
|
"""
|
1808
1932
|
...
|
1809
1933
|
|
1810
|
-
|
1934
|
+
@typing.overload
|
1935
|
+
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]]:
|
1811
1936
|
"""
|
1812
|
-
|
1813
|
-
|
1937
|
+
Specifies the times when the flow should be run when running on a
|
1938
|
+
production scheduler.
|
1814
1939
|
|
1815
1940
|
Parameters
|
1816
1941
|
----------
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
the
|
1942
|
+
hourly : bool, default False
|
1943
|
+
Run the workflow hourly.
|
1944
|
+
daily : bool, default True
|
1945
|
+
Run the workflow daily.
|
1946
|
+
weekly : bool, default False
|
1947
|
+
Run the workflow weekly.
|
1948
|
+
cron : str, optional, default None
|
1949
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1950
|
+
specified by this expression.
|
1951
|
+
timezone : str, optional, default None
|
1952
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1953
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1954
|
+
"""
|
1955
|
+
...
|
1956
|
+
|
1957
|
+
@typing.overload
|
1958
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1959
|
+
...
|
1960
|
+
|
1961
|
+
def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None):
|
1962
|
+
"""
|
1963
|
+
Specifies the times when the flow should be run when running on a
|
1964
|
+
production scheduler.
|
1965
|
+
|
1966
|
+
Parameters
|
1967
|
+
----------
|
1968
|
+
hourly : bool, default False
|
1969
|
+
Run the workflow hourly.
|
1970
|
+
daily : bool, default True
|
1971
|
+
Run the workflow daily.
|
1972
|
+
weekly : bool, default False
|
1973
|
+
Run the workflow weekly.
|
1974
|
+
cron : str, optional, default None
|
1975
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1976
|
+
specified by this expression.
|
1977
|
+
timezone : str, optional, default None
|
1978
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1979
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1849
1980
|
"""
|
1850
1981
|
...
|
1851
1982
|
|
@@ -1927,6 +2058,19 @@ def default_metadata() -> str:
|
|
1927
2058
|
...
|
1928
2059
|
|
1929
2060
|
class Metaflow(object, metaclass=type):
|
2061
|
+
"""
|
2062
|
+
Entry point to all objects in the Metaflow universe.
|
2063
|
+
|
2064
|
+
This object can be used to list all the flows present either through the explicit property
|
2065
|
+
or by iterating over this object.
|
2066
|
+
|
2067
|
+
Attributes
|
2068
|
+
----------
|
2069
|
+
flows : List[Flow]
|
2070
|
+
Returns the list of all `Flow` objects known to this metadata provider. Note that only
|
2071
|
+
flows present in the current namespace will be returned. A `Flow` is present in a namespace
|
2072
|
+
if it has at least one run in the namespace.
|
2073
|
+
"""
|
1930
2074
|
def __init__(self):
|
1931
2075
|
...
|
1932
2076
|
@property
|
@@ -1978,6 +2122,17 @@ class Metaflow(object, metaclass=type):
|
|
1978
2122
|
...
|
1979
2123
|
|
1980
2124
|
class Flow(metaflow.client.core.MetaflowObject, metaclass=type):
|
2125
|
+
"""
|
2126
|
+
A Flow represents all existing flows with a certain name, in other words,
|
2127
|
+
classes derived from `FlowSpec`. A container of `Run` objects.
|
2128
|
+
|
2129
|
+
Attributes
|
2130
|
+
----------
|
2131
|
+
latest_run : Run
|
2132
|
+
Latest `Run` (in progress or completed, successfully or not) of this flow.
|
2133
|
+
latest_successful_run : Run
|
2134
|
+
Latest successfully completed `Run` of this flow.
|
2135
|
+
"""
|
1981
2136
|
def __init__(self, *args, **kwargs):
|
1982
2137
|
...
|
1983
2138
|
@property
|
@@ -2064,6 +2219,26 @@ class Flow(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2064
2219
|
...
|
2065
2220
|
|
2066
2221
|
class Run(metaflow.client.core.MetaflowObject, metaclass=type):
|
2222
|
+
"""
|
2223
|
+
A `Run` represents an execution of a `Flow`. It is a container of `Step`s.
|
2224
|
+
|
2225
|
+
Attributes
|
2226
|
+
----------
|
2227
|
+
data : MetaflowData
|
2228
|
+
a shortcut to run['end'].task.data, i.e. data produced by this run.
|
2229
|
+
successful : bool
|
2230
|
+
True if the run completed successfully.
|
2231
|
+
finished : bool
|
2232
|
+
True if the run completed.
|
2233
|
+
finished_at : datetime
|
2234
|
+
Time this run finished.
|
2235
|
+
code : MetaflowCode
|
2236
|
+
Code package for this run (if present). See `MetaflowCode`.
|
2237
|
+
trigger : MetaflowTrigger
|
2238
|
+
Information about event(s) that triggered this run (if present). See `MetaflowTrigger`.
|
2239
|
+
end_task : Task
|
2240
|
+
`Task` for the end step (if it is present already).
|
2241
|
+
"""
|
2067
2242
|
def steps(self, *tags: str) -> typing.Iterator[metaflow.client.core.Step]:
|
2068
2243
|
"""
|
2069
2244
|
[Legacy function - do not use]
|
@@ -2296,6 +2471,23 @@ class Run(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2296
2471
|
...
|
2297
2472
|
|
2298
2473
|
class Step(metaflow.client.core.MetaflowObject, metaclass=type):
|
2474
|
+
"""
|
2475
|
+
A `Step` represents a user-defined step, that is, a method annotated with the `@step` decorator.
|
2476
|
+
|
2477
|
+
It contains `Task` objects associated with the step, that is, all executions of the
|
2478
|
+
`Step`. The step may contain multiple `Task`s in the case of a foreach step.
|
2479
|
+
|
2480
|
+
Attributes
|
2481
|
+
----------
|
2482
|
+
task : Task
|
2483
|
+
The first `Task` object in this step. This is a shortcut for retrieving the only
|
2484
|
+
task contained in a non-foreach step.
|
2485
|
+
finished_at : datetime
|
2486
|
+
Time when the latest `Task` of this step finished. Note that in the case of foreaches,
|
2487
|
+
this time may change during execution of the step.
|
2488
|
+
environment_info : Dict[str, Any]
|
2489
|
+
Information about the execution environment.
|
2490
|
+
"""
|
2299
2491
|
@property
|
2300
2492
|
def task(self) -> typing.Optional[metaflow.client.core.Task]:
|
2301
2493
|
"""
|
@@ -2430,6 +2622,55 @@ class Step(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2430
2622
|
...
|
2431
2623
|
|
2432
2624
|
class Task(metaflow.client.core.MetaflowObject, metaclass=type):
|
2625
|
+
"""
|
2626
|
+
A `Task` represents an execution of a `Step`.
|
2627
|
+
|
2628
|
+
It contains all `DataArtifact` objects produced by the task as
|
2629
|
+
well as metadata related to execution.
|
2630
|
+
|
2631
|
+
Note that the `@retry` decorator may cause multiple attempts of
|
2632
|
+
the task to be present. Usually you want the latest attempt, which
|
2633
|
+
is what instantiating a `Task` object returns by default. If
|
2634
|
+
you need to e.g. retrieve logs from a failed attempt, you can
|
2635
|
+
explicitly get information about a specific attempt by using the
|
2636
|
+
following syntax when creating a task:
|
2637
|
+
|
2638
|
+
`Task('flow/run/step/task', attempt=<attempt>)`
|
2639
|
+
|
2640
|
+
where `attempt=0` corresponds to the first attempt etc.
|
2641
|
+
|
2642
|
+
Attributes
|
2643
|
+
----------
|
2644
|
+
metadata : List[Metadata]
|
2645
|
+
List of all metadata events associated with the task.
|
2646
|
+
metadata_dict : Dict[str, str]
|
2647
|
+
A condensed version of `metadata`: A dictionary where keys
|
2648
|
+
are names of metadata events and values the latest corresponding event.
|
2649
|
+
data : MetaflowData
|
2650
|
+
Container of all data artifacts produced by this task. Note that this
|
2651
|
+
call downloads all data locally, so it can be slower than accessing
|
2652
|
+
artifacts individually. See `MetaflowData` for more information.
|
2653
|
+
artifacts : MetaflowArtifacts
|
2654
|
+
Container of `DataArtifact` objects produced by this task.
|
2655
|
+
successful : bool
|
2656
|
+
True if the task completed successfully.
|
2657
|
+
finished : bool
|
2658
|
+
True if the task completed.
|
2659
|
+
exception : object
|
2660
|
+
Exception raised by this task if there was one.
|
2661
|
+
finished_at : datetime
|
2662
|
+
Time this task finished.
|
2663
|
+
runtime_name : str
|
2664
|
+
Runtime this task was executed on.
|
2665
|
+
stdout : str
|
2666
|
+
Standard output for the task execution.
|
2667
|
+
stderr : str
|
2668
|
+
Standard error output for the task execution.
|
2669
|
+
code : MetaflowCode
|
2670
|
+
Code package for this task (if present). See `MetaflowCode`.
|
2671
|
+
environment_info : Dict[str, str]
|
2672
|
+
Information about the execution environment.
|
2673
|
+
"""
|
2433
2674
|
def __init__(self, *args, **kwargs):
|
2434
2675
|
...
|
2435
2676
|
@property
|
@@ -2744,6 +2985,21 @@ class Task(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2744
2985
|
...
|
2745
2986
|
|
2746
2987
|
class DataArtifact(metaflow.client.core.MetaflowObject, metaclass=type):
|
2988
|
+
"""
|
2989
|
+
A single data artifact and associated metadata. Note that this object does
|
2990
|
+
not contain other objects as it is the leaf object in the hierarchy.
|
2991
|
+
|
2992
|
+
Attributes
|
2993
|
+
----------
|
2994
|
+
data : object
|
2995
|
+
The data contained in this artifact, that is, the object produced during
|
2996
|
+
execution of this run.
|
2997
|
+
sha : string
|
2998
|
+
A unique ID of this artifact.
|
2999
|
+
finished_at : datetime
|
3000
|
+
Corresponds roughly to the `Task.finished_at` time of the parent `Task`.
|
3001
|
+
An alias for `DataArtifact.created_at`.
|
3002
|
+
"""
|
2747
3003
|
@property
|
2748
3004
|
def data(self) -> typing.Any:
|
2749
3005
|
"""
|
@@ -2800,6 +3056,44 @@ class DataArtifact(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2800
3056
|
...
|
2801
3057
|
|
2802
3058
|
class Runner(object, metaclass=type):
|
3059
|
+
"""
|
3060
|
+
Metaflow's Runner API that presents a programmatic interface
|
3061
|
+
to run flows and perform other operations either synchronously or asynchronously.
|
3062
|
+
The class expects a path to the flow file along with optional arguments
|
3063
|
+
that match top-level options on the command-line.
|
3064
|
+
|
3065
|
+
This class works as a context manager, calling `cleanup()` to remove
|
3066
|
+
temporary files at exit.
|
3067
|
+
|
3068
|
+
Example:
|
3069
|
+
```python
|
3070
|
+
with Runner('slowflow.py', pylint=False) as runner:
|
3071
|
+
result = runner.run(alpha=5, tags=["abc", "def"], max_workers=5)
|
3072
|
+
print(result.run.finished)
|
3073
|
+
```
|
3074
|
+
|
3075
|
+
Parameters
|
3076
|
+
----------
|
3077
|
+
flow_file : str
|
3078
|
+
Path to the flow file to run
|
3079
|
+
show_output : bool, default True
|
3080
|
+
Show the 'stdout' and 'stderr' to the console by default,
|
3081
|
+
Only applicable for synchronous 'run' and 'resume' functions.
|
3082
|
+
profile : Optional[str], default None
|
3083
|
+
Metaflow profile to use to run this run. If not specified, the default
|
3084
|
+
profile is used (or the one already set using `METAFLOW_PROFILE`)
|
3085
|
+
env : Optional[Dict], default None
|
3086
|
+
Additional environment variables to set for the Run. This overrides the
|
3087
|
+
environment set for this process.
|
3088
|
+
cwd : Optional[str], default None
|
3089
|
+
The directory to run the subprocess in; if not specified, the current
|
3090
|
+
directory is used.
|
3091
|
+
file_read_timeout : int, default 3600
|
3092
|
+
The timeout until which we try to read the runner attribute file.
|
3093
|
+
**kwargs : Any
|
3094
|
+
Additional arguments that you would pass to `python myflow.py` before
|
3095
|
+
the `run` command.
|
3096
|
+
"""
|
2803
3097
|
def __init__(self, flow_file: str, show_output: bool = True, profile: typing.Optional[str] = None, env: typing.Optional[typing.Dict] = None, cwd: typing.Optional[str] = None, file_read_timeout: int = 3600, **kwargs):
|
2804
3098
|
...
|
2805
3099
|
def __enter__(self) -> metaflow.runner.metaflow_runner.Runner:
|
@@ -2892,6 +3186,42 @@ class Runner(object, metaclass=type):
|
|
2892
3186
|
...
|
2893
3187
|
|
2894
3188
|
class NBRunner(object, metaclass=type):
|
3189
|
+
"""
|
3190
|
+
A wrapper over `Runner` for executing flows defined in a Jupyter
|
3191
|
+
notebook cell.
|
3192
|
+
|
3193
|
+
Instantiate this class on the last line of a notebook cell where
|
3194
|
+
a `flow` is defined. In contrast to `Runner`, this class is not
|
3195
|
+
meant to be used in a context manager. Instead, use a blocking helper
|
3196
|
+
function like `nbrun` (which calls `cleanup()` internally) or call
|
3197
|
+
`cleanup()` explictly when using non-blocking APIs.
|
3198
|
+
|
3199
|
+
```python
|
3200
|
+
run = NBRunner(FlowName).nbrun()
|
3201
|
+
```
|
3202
|
+
|
3203
|
+
Parameters
|
3204
|
+
----------
|
3205
|
+
flow : FlowSpec
|
3206
|
+
Flow defined in the same cell
|
3207
|
+
show_output : bool, default True
|
3208
|
+
Show the 'stdout' and 'stderr' to the console by default,
|
3209
|
+
Only applicable for synchronous 'run' and 'resume' functions.
|
3210
|
+
profile : Optional[str], default None
|
3211
|
+
Metaflow profile to use to run this run. If not specified, the default
|
3212
|
+
profile is used (or the one already set using `METAFLOW_PROFILE`)
|
3213
|
+
env : Optional[Dict], default None
|
3214
|
+
Additional environment variables to set for the Run. This overrides the
|
3215
|
+
environment set for this process.
|
3216
|
+
base_dir : Optional[str], default None
|
3217
|
+
The directory to run the subprocess in; if not specified, a temporary
|
3218
|
+
directory is used.
|
3219
|
+
file_read_timeout : int, default 3600
|
3220
|
+
The timeout until which we try to read the runner attribute file.
|
3221
|
+
**kwargs : Any
|
3222
|
+
Additional arguments that you would pass to `python myflow.py` before
|
3223
|
+
the `run` command.
|
3224
|
+
"""
|
2895
3225
|
def __init__(self, flow, show_output: bool = True, profile: typing.Optional[str] = None, env: typing.Optional[typing.Dict] = None, base_dir: str = "/tmp", file_read_timeout: int = 3600, **kwargs):
|
2896
3226
|
...
|
2897
3227
|
def nbrun(self, **kwargs):
|
@@ -2998,6 +3328,30 @@ class NBRunner(object, metaclass=type):
|
|
2998
3328
|
...
|
2999
3329
|
|
3000
3330
|
class Deployer(object, metaclass=type):
|
3331
|
+
"""
|
3332
|
+
Use the `Deployer` class to configure and access one of the production
|
3333
|
+
orchestrators supported by Metaflow.
|
3334
|
+
|
3335
|
+
Parameters
|
3336
|
+
----------
|
3337
|
+
flow_file : str
|
3338
|
+
Path to the flow file to deploy.
|
3339
|
+
show_output : bool, default True
|
3340
|
+
Show the 'stdout' and 'stderr' to the console by default.
|
3341
|
+
profile : Optional[str], default None
|
3342
|
+
Metaflow profile to use for the deployment. If not specified, the default
|
3343
|
+
profile is used.
|
3344
|
+
env : Optional[Dict[str, str]], default None
|
3345
|
+
Additional environment variables to set for the deployment.
|
3346
|
+
cwd : Optional[str], default None
|
3347
|
+
The directory to run the subprocess in; if not specified, the current
|
3348
|
+
directory is used.
|
3349
|
+
file_read_timeout : int, default 3600
|
3350
|
+
The timeout until which we try to read the deployer attribute file.
|
3351
|
+
**kwargs : Any
|
3352
|
+
Additional arguments that you would pass to `python myflow.py` before
|
3353
|
+
the deployment command.
|
3354
|
+
"""
|
3001
3355
|
def __init__(self, flow_file: str, show_output: bool = True, profile: typing.Optional[str] = None, env: typing.Optional[typing.Dict] = None, cwd: typing.Optional[str] = None, file_read_timeout: int = 3600, **kwargs):
|
3002
3356
|
...
|
3003
3357
|
def _Deployer__make_function(self, deployer_class):
|
@@ -3018,6 +3372,43 @@ class Deployer(object, metaclass=type):
|
|
3018
3372
|
...
|
3019
3373
|
|
3020
3374
|
class NBDeployer(object, metaclass=type):
|
3375
|
+
"""
|
3376
|
+
A wrapper over `Deployer` for deploying flows defined in a Jupyter
|
3377
|
+
notebook cell.
|
3378
|
+
|
3379
|
+
Instantiate this class on the last line of a notebook cell where
|
3380
|
+
a `flow` is defined. In contrast to `Deployer`, this class is not
|
3381
|
+
meant to be used in a context manager.
|
3382
|
+
|
3383
|
+
```python
|
3384
|
+
deployer = NBDeployer(FlowName)
|
3385
|
+
ar = deployer.argo_workflows(name="madhur")
|
3386
|
+
ar_obj = ar.create()
|
3387
|
+
result = ar_obj.trigger(alpha=300)
|
3388
|
+
print(result.status)
|
3389
|
+
print(result.run)
|
3390
|
+
result.terminate()
|
3391
|
+
```
|
3392
|
+
|
3393
|
+
Parameters
|
3394
|
+
----------
|
3395
|
+
flow : FlowSpec
|
3396
|
+
Flow defined in the same cell
|
3397
|
+
show_output : bool, default True
|
3398
|
+
Show the 'stdout' and 'stderr' to the console by default,
|
3399
|
+
profile : Optional[str], default None
|
3400
|
+
Metaflow profile to use to deploy this run. If not specified, the default
|
3401
|
+
profile is used (or the one already set using `METAFLOW_PROFILE`)
|
3402
|
+
env : Optional[Dict[str, str]], default None
|
3403
|
+
Additional environment variables to set. This overrides the
|
3404
|
+
environment set for this process.
|
3405
|
+
base_dir : Optional[str], default None
|
3406
|
+
The directory to run the subprocess in; if not specified, a temporary
|
3407
|
+
directory is used.
|
3408
|
+
**kwargs : Any
|
3409
|
+
Additional arguments that you would pass to `python myflow.py` i.e. options
|
3410
|
+
listed in `python myflow.py --help`
|
3411
|
+
"""
|
3021
3412
|
def __init__(self, flow, show_output: bool = True, profile: typing.Optional[str] = None, env: typing.Optional[typing.Dict] = None, base_dir: str = "/tmp", file_read_timeout: int = 3600, **kwargs):
|
3022
3413
|
...
|
3023
3414
|
def cleanup(self):
|