ob-metaflow-stubs 6.0.3.104__py2.py3-none-any.whl → 6.0.3.106__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- metaflow-stubs/__init__.pyi +853 -515
- metaflow-stubs/cards.pyi +211 -5
- metaflow-stubs/cli.pyi +22 -2
- metaflow-stubs/client/__init__.pyi +128 -3
- metaflow-stubs/client/core.pyi +226 -6
- metaflow-stubs/client/filecache.pyi +2 -2
- metaflow-stubs/clone_util.pyi +5 -2
- metaflow-stubs/events.pyi +20 -2
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +70 -4
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +156 -3
- metaflow-stubs/info_file.pyi +2 -2
- metaflow-stubs/metadata/metadata.pyi +8 -2
- metaflow-stubs/metadata/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +2 -2
- metaflow-stubs/metaflow_current.pyi +22 -19
- metaflow-stubs/mflog/mflog.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/parameters.pyi +68 -2
- metaflow-stubs/plugins/__init__.pyi +14 -3
- metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
- metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
- metaflow-stubs/plugins/airflow/exception.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/__init__.pyi +80 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +5 -2
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +44 -2
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +44 -2
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +16 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +17 -4
- metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +98 -7
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +32 -4
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +50 -5
- 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_client.pyi +2 -2
- metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +102 -2
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +15 -3
- metaflow-stubs/plugins/aws/step_functions/__init__.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_client.pyi +2 -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 +21 -3
- 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 +63 -5
- metaflow-stubs/plugins/cards/card_client.pyi +34 -3
- 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 +52 -2
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +28 -2
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +41 -2
- metaflow-stubs/plugins/cards/card_modules/card.pyi +28 -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 +35 -2
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +55 -2
- metaflow-stubs/plugins/cards/exception.pyi +8 -2
- metaflow-stubs/plugins/catch_decorator.pyi +19 -2
- 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 +83 -6
- 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 +106 -2
- 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 +15 -3
- 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 +11 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +65 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +99 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +5 -2
- metaflow-stubs/plugins/logs_cli.pyi +3 -3
- metaflow-stubs/plugins/package_cli.pyi +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +29 -2
- metaflow-stubs/plugins/perimeters.pyi +2 -2
- metaflow-stubs/plugins/project_decorator.pyi +59 -2
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +45 -2
- metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
- 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 +2 -2
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +11 -2
- metaflow-stubs/plugins/storage_executor.pyi +6 -2
- metaflow-stubs/plugins/tag_cli.pyi +37 -6
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +10 -3
- metaflow-stubs/plugins/timeout_decorator.pyi +23 -2
- metaflow-stubs/procpoll.pyi +2 -2
- metaflow-stubs/profilers/__init__.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 +118 -10
- 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 +3 -3
- metaflow-stubs/system/system_logger.pyi +3 -3
- metaflow-stubs/system/system_monitor.pyi +2 -2
- metaflow-stubs/tagging_util.pyi +2 -2
- metaflow-stubs/tuple_util.pyi +2 -2
- {ob_metaflow_stubs-6.0.3.104.dist-info → ob_metaflow_stubs-6.0.3.106.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.3.106.dist-info/RECORD +140 -0
- ob_metaflow_stubs-6.0.3.104.dist-info/RECORD +0 -140
- {ob_metaflow_stubs-6.0.3.104.dist-info → ob_metaflow_stubs-6.0.3.106.dist-info}/WHEEL +0 -0
- {ob_metaflow_stubs-6.0.3.104.dist-info → ob_metaflow_stubs-6.0.3.106.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
##################################################################################
|
2
2
|
# Auto-generated Metaflow stub file #
|
3
|
-
# MF version: 2.12.
|
4
|
-
# Generated on 2024-
|
3
|
+
# MF version: 2.12.24.1+obcheckpoint(0.0.11);ob(v1) #
|
4
|
+
# Generated on 2024-10-04T19:10:58.884265 #
|
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.client.core
|
12
11
|
import metaflow._vendor.click.types
|
13
|
-
import
|
12
|
+
import metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures
|
14
13
|
import metaflow.parameters
|
15
|
-
import metaflow.events
|
16
14
|
import metaflow.metaflow_current
|
17
15
|
import datetime
|
16
|
+
import typing
|
17
|
+
import metaflow.events
|
18
|
+
import metaflow.runner.metaflow_runner
|
18
19
|
import metaflow.datastore.inputs
|
19
|
-
import metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures
|
20
20
|
import metaflow.flowspec
|
21
|
-
import
|
21
|
+
import metaflow.client.core
|
22
22
|
FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
|
23
23
|
StepFlag = typing.NewType("StepFlag", bool)
|
24
24
|
|
@@ -102,6 +102,14 @@ def metadata(ms: str) -> str:
|
|
102
102
|
...
|
103
103
|
|
104
104
|
class FlowSpec(object, metaclass=metaflow.flowspec._FlowSpecMeta):
|
105
|
+
"""
|
106
|
+
Main class from which all Flows should inherit.
|
107
|
+
|
108
|
+
Attributes
|
109
|
+
----------
|
110
|
+
index
|
111
|
+
input
|
112
|
+
"""
|
105
113
|
def __init__(self, use_cli = True):
|
106
114
|
"""
|
107
115
|
Construct a FlowSpec
|
@@ -323,6 +331,49 @@ class FlowSpec(object, metaclass=metaflow.flowspec._FlowSpecMeta):
|
|
323
331
|
...
|
324
332
|
|
325
333
|
class Parameter(object, metaclass=type):
|
334
|
+
"""
|
335
|
+
Defines a parameter for a flow.
|
336
|
+
|
337
|
+
Parameters must be instantiated as class variables in flow classes, e.g.
|
338
|
+
```
|
339
|
+
class MyFlow(FlowSpec):
|
340
|
+
param = Parameter('myparam')
|
341
|
+
```
|
342
|
+
in this case, the parameter is specified on the command line as
|
343
|
+
```
|
344
|
+
python myflow.py run --myparam=5
|
345
|
+
```
|
346
|
+
and its value is accessible through a read-only artifact like this:
|
347
|
+
```
|
348
|
+
print(self.param == 5)
|
349
|
+
```
|
350
|
+
Note that the user-visible parameter name, `myparam` above, can be
|
351
|
+
different from the artifact name, `param` above.
|
352
|
+
|
353
|
+
The parameter value is converted to a Python type based on the `type`
|
354
|
+
argument or to match the type of `default`, if it is set.
|
355
|
+
|
356
|
+
Parameters
|
357
|
+
----------
|
358
|
+
name : str
|
359
|
+
User-visible parameter name.
|
360
|
+
default : str or float or int or bool or `JSONType` or a function.
|
361
|
+
Default value for the parameter. Use a special `JSONType` class to
|
362
|
+
indicate that the value must be a valid JSON object. A function
|
363
|
+
implies that the parameter corresponds to a *deploy-time parameter*.
|
364
|
+
The type of the default value is used as the parameter `type`.
|
365
|
+
type : Type, default None
|
366
|
+
If `default` is not specified, define the parameter type. Specify
|
367
|
+
one of `str`, `float`, `int`, `bool`, or `JSONType`. If None, defaults
|
368
|
+
to the type of `default` or `str` if none specified.
|
369
|
+
help : str, optional
|
370
|
+
Help text to show in `run --help`.
|
371
|
+
required : bool, default False
|
372
|
+
Require that the user specified a value for the parameter.
|
373
|
+
`required=True` implies that the `default` is not used.
|
374
|
+
show_default : bool, default True
|
375
|
+
If True, show the default value in the help text.
|
376
|
+
"""
|
326
377
|
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]):
|
327
378
|
...
|
328
379
|
def __repr__(self):
|
@@ -355,6 +406,33 @@ def S3(*args, **kwargs):
|
|
355
406
|
...
|
356
407
|
|
357
408
|
class IncludeFile(metaflow.parameters.Parameter, metaclass=type):
|
409
|
+
"""
|
410
|
+
Includes a local file as a parameter for the flow.
|
411
|
+
|
412
|
+
`IncludeFile` behaves like `Parameter` except that it reads its value from a file instead of
|
413
|
+
the command line. The user provides a path to a file on the command line. The file contents
|
414
|
+
are saved as a read-only artifact which is available in all steps of the flow.
|
415
|
+
|
416
|
+
Parameters
|
417
|
+
----------
|
418
|
+
name : str
|
419
|
+
User-visible parameter name.
|
420
|
+
default : Union[str, Callable[ParameterContext, str]]
|
421
|
+
Default path to a local file. A function
|
422
|
+
implies that the parameter corresponds to a *deploy-time parameter*.
|
423
|
+
is_text : bool, default True
|
424
|
+
Convert the file contents to a string using the provided `encoding`.
|
425
|
+
If False, the artifact is stored in `bytes`.
|
426
|
+
encoding : str, optional, default 'utf-8'
|
427
|
+
Use this encoding to decode the file contexts if `is_text=True`.
|
428
|
+
required : bool, default False
|
429
|
+
Require that the user specified a value for the parameter.
|
430
|
+
`required=True` implies that the `default` is not used.
|
431
|
+
help : str, optional
|
432
|
+
Help text to show in `run --help`.
|
433
|
+
show_default : bool, default True
|
434
|
+
If True, show the default value in the help text.
|
435
|
+
"""
|
358
436
|
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]):
|
359
437
|
...
|
360
438
|
def load_parameter(self, v):
|
@@ -435,19 +513,63 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
435
513
|
...
|
436
514
|
|
437
515
|
@typing.overload
|
438
|
-
def
|
516
|
+
def model(*, load: typing.Union[typing.List[str], str, typing.List[typing.Tuple[str, typing.Optional[str]]]] = None, temp_dir_root: 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]]]:
|
439
517
|
"""
|
440
|
-
|
518
|
+
Enables loading / saving of models within a step.
|
519
|
+
|
520
|
+
|
521
|
+
Parameters
|
522
|
+
----------
|
523
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
524
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
525
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
526
|
+
- `current.checkpoint`
|
527
|
+
- `current.model`
|
528
|
+
- `current.huggingface_hub`
|
529
|
+
|
530
|
+
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
531
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
532
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
533
|
+
|
534
|
+
temp_dir_root : str, default: None
|
535
|
+
The root directory under which `current.model.loaded` will store loaded models
|
536
|
+
|
537
|
+
|
538
|
+
|
441
539
|
"""
|
442
540
|
...
|
443
541
|
|
444
542
|
@typing.overload
|
445
|
-
def
|
543
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
446
544
|
...
|
447
545
|
|
448
|
-
|
546
|
+
@typing.overload
|
547
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
548
|
+
...
|
549
|
+
|
550
|
+
def model(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load: typing.Union[typing.List[str], str, typing.List[typing.Tuple[str, typing.Optional[str]]]] = None, temp_dir_root: str = None):
|
449
551
|
"""
|
450
|
-
|
552
|
+
Enables loading / saving of models within a step.
|
553
|
+
|
554
|
+
|
555
|
+
Parameters
|
556
|
+
----------
|
557
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
558
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
559
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
560
|
+
- `current.checkpoint`
|
561
|
+
- `current.model`
|
562
|
+
- `current.huggingface_hub`
|
563
|
+
|
564
|
+
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
565
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
566
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
567
|
+
|
568
|
+
temp_dir_root : str, default: None
|
569
|
+
The root directory under which `current.model.loaded` will store loaded models
|
570
|
+
|
571
|
+
|
572
|
+
|
451
573
|
"""
|
452
574
|
...
|
453
575
|
|
@@ -508,6 +630,23 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
508
630
|
"""
|
509
631
|
...
|
510
632
|
|
633
|
+
@typing.overload
|
634
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
635
|
+
"""
|
636
|
+
Internal decorator to support Fast bakery
|
637
|
+
"""
|
638
|
+
...
|
639
|
+
|
640
|
+
@typing.overload
|
641
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
642
|
+
...
|
643
|
+
|
644
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
645
|
+
"""
|
646
|
+
Internal decorator to support Fast bakery
|
647
|
+
"""
|
648
|
+
...
|
649
|
+
|
511
650
|
@typing.overload
|
512
651
|
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]]]:
|
513
652
|
"""
|
@@ -591,131 +730,231 @@ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
591
730
|
...
|
592
731
|
|
593
732
|
@typing.overload
|
594
|
-
def
|
733
|
+
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]]]:
|
595
734
|
"""
|
596
|
-
|
597
|
-
|
735
|
+
Specifies environment variables to be set prior to the execution of a step.
|
598
736
|
|
599
737
|
Parameters
|
600
738
|
----------
|
601
|
-
|
602
|
-
|
603
|
-
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
604
|
-
- `current.checkpoint`
|
605
|
-
- `current.model`
|
606
|
-
- `current.huggingface_hub`
|
607
|
-
|
608
|
-
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
609
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
610
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
611
|
-
|
612
|
-
temp_dir_root : str, default: None
|
613
|
-
The root directory under which `current.model.loaded` will store loaded models
|
614
|
-
|
615
|
-
|
616
|
-
|
739
|
+
vars : Dict[str, str], default {}
|
740
|
+
Dictionary of environment variables to set.
|
617
741
|
"""
|
618
742
|
...
|
619
743
|
|
620
744
|
@typing.overload
|
621
|
-
def
|
745
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
622
746
|
...
|
623
747
|
|
624
748
|
@typing.overload
|
625
|
-
def
|
749
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
626
750
|
...
|
627
751
|
|
628
|
-
def
|
752
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
629
753
|
"""
|
630
|
-
|
631
|
-
|
754
|
+
Specifies environment variables to be set prior to the execution of a step.
|
632
755
|
|
633
756
|
Parameters
|
634
757
|
----------
|
635
|
-
|
636
|
-
|
637
|
-
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
638
|
-
- `current.checkpoint`
|
639
|
-
- `current.model`
|
640
|
-
- `current.huggingface_hub`
|
641
|
-
|
642
|
-
If a list of tuples is provided, the first element is the artifact name and the second element is the path the artifact needs be unpacked on
|
643
|
-
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
644
|
-
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
645
|
-
|
646
|
-
temp_dir_root : str, default: None
|
647
|
-
The root directory under which `current.model.loaded` will store loaded models
|
648
|
-
|
649
|
-
|
650
|
-
|
758
|
+
vars : Dict[str, str], default {}
|
759
|
+
Dictionary of environment variables to set.
|
651
760
|
"""
|
652
761
|
...
|
653
762
|
|
654
763
|
@typing.overload
|
655
|
-
def
|
764
|
+
def resources(*, cpu: int = 1, gpu: int = 0, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
656
765
|
"""
|
657
|
-
|
766
|
+
Specifies the resources needed when executing this step.
|
658
767
|
|
659
|
-
|
768
|
+
Use `@resources` to specify the resource requirements
|
769
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
770
|
+
|
771
|
+
You can choose the compute layer on the command line by executing e.g.
|
772
|
+
```
|
773
|
+
python myflow.py run --with batch
|
774
|
+
```
|
775
|
+
or
|
776
|
+
```
|
777
|
+
python myflow.py run --with kubernetes
|
778
|
+
```
|
779
|
+
which executes the flow on the desired system using the
|
780
|
+
requirements specified in `@resources`.
|
660
781
|
|
661
782
|
Parameters
|
662
783
|
----------
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
784
|
+
cpu : int, default 1
|
785
|
+
Number of CPUs required for this step.
|
786
|
+
gpu : int, default 0
|
787
|
+
Number of GPUs required for this step.
|
788
|
+
disk : int, optional, default None
|
789
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
790
|
+
memory : int, default 4096
|
791
|
+
Memory size (in MB) required for this step.
|
792
|
+
shared_memory : int, optional, default None
|
793
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
794
|
+
This parameter maps to the `--shm-size` option in Docker.
|
673
795
|
"""
|
674
796
|
...
|
675
797
|
|
676
798
|
@typing.overload
|
677
|
-
def
|
799
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
678
800
|
...
|
679
801
|
|
680
802
|
@typing.overload
|
681
|
-
def
|
803
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
682
804
|
...
|
683
805
|
|
684
|
-
def
|
806
|
+
def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: int = 0, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None):
|
685
807
|
"""
|
686
|
-
|
808
|
+
Specifies the resources needed when executing this step.
|
687
809
|
|
688
|
-
|
810
|
+
Use `@resources` to specify the resource requirements
|
811
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
812
|
+
|
813
|
+
You can choose the compute layer on the command line by executing e.g.
|
814
|
+
```
|
815
|
+
python myflow.py run --with batch
|
816
|
+
```
|
817
|
+
or
|
818
|
+
```
|
819
|
+
python myflow.py run --with kubernetes
|
820
|
+
```
|
821
|
+
which executes the flow on the desired system using the
|
822
|
+
requirements specified in `@resources`.
|
689
823
|
|
690
824
|
Parameters
|
691
825
|
----------
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
826
|
+
cpu : int, default 1
|
827
|
+
Number of CPUs required for this step.
|
828
|
+
gpu : int, default 0
|
829
|
+
Number of GPUs required for this step.
|
830
|
+
disk : int, optional, default None
|
831
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
832
|
+
memory : int, default 4096
|
833
|
+
Memory size (in MB) required for this step.
|
834
|
+
shared_memory : int, optional, default None
|
835
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
836
|
+
This parameter maps to the `--shm-size` option in Docker.
|
702
837
|
"""
|
703
838
|
...
|
704
839
|
|
705
840
|
@typing.overload
|
706
|
-
def
|
841
|
+
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]]]:
|
707
842
|
"""
|
708
|
-
Specifies the
|
843
|
+
Specifies the number of times the task corresponding
|
844
|
+
to a step needs to be retried.
|
709
845
|
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
846
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
847
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
848
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
849
|
+
|
850
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
851
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
852
|
+
ensuring that the flow execution can continue.
|
714
853
|
|
715
854
|
Parameters
|
716
855
|
----------
|
717
|
-
|
718
|
-
|
856
|
+
times : int, default 3
|
857
|
+
Number of times to retry this task.
|
858
|
+
minutes_between_retries : int, default 2
|
859
|
+
Number of minutes between retries.
|
860
|
+
"""
|
861
|
+
...
|
862
|
+
|
863
|
+
@typing.overload
|
864
|
+
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
865
|
+
...
|
866
|
+
|
867
|
+
@typing.overload
|
868
|
+
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
869
|
+
...
|
870
|
+
|
871
|
+
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):
|
872
|
+
"""
|
873
|
+
Specifies the number of times the task corresponding
|
874
|
+
to a step needs to be retried.
|
875
|
+
|
876
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
877
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
878
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
879
|
+
|
880
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
881
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
882
|
+
ensuring that the flow execution can continue.
|
883
|
+
|
884
|
+
Parameters
|
885
|
+
----------
|
886
|
+
times : int, default 3
|
887
|
+
Number of times to retry this task.
|
888
|
+
minutes_between_retries : int, default 2
|
889
|
+
Number of minutes between retries.
|
890
|
+
"""
|
891
|
+
...
|
892
|
+
|
893
|
+
@typing.overload
|
894
|
+
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]]]:
|
895
|
+
"""
|
896
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
897
|
+
|
898
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
899
|
+
|
900
|
+
Parameters
|
901
|
+
----------
|
902
|
+
type : str, default 'default'
|
903
|
+
Card type.
|
904
|
+
id : str, optional, default None
|
905
|
+
If multiple cards are present, use this id to identify this card.
|
906
|
+
options : Dict[str, Any], default {}
|
907
|
+
Options passed to the card. The contents depend on the card type.
|
908
|
+
timeout : int, default 45
|
909
|
+
Interrupt reporting if it takes more than this many seconds.
|
910
|
+
|
911
|
+
|
912
|
+
"""
|
913
|
+
...
|
914
|
+
|
915
|
+
@typing.overload
|
916
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
917
|
+
...
|
918
|
+
|
919
|
+
@typing.overload
|
920
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
921
|
+
...
|
922
|
+
|
923
|
+
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):
|
924
|
+
"""
|
925
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
926
|
+
|
927
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
928
|
+
|
929
|
+
Parameters
|
930
|
+
----------
|
931
|
+
type : str, default 'default'
|
932
|
+
Card type.
|
933
|
+
id : str, optional, default None
|
934
|
+
If multiple cards are present, use this id to identify this card.
|
935
|
+
options : Dict[str, Any], default {}
|
936
|
+
Options passed to the card. The contents depend on the card type.
|
937
|
+
timeout : int, default 45
|
938
|
+
Interrupt reporting if it takes more than this many seconds.
|
939
|
+
|
940
|
+
|
941
|
+
"""
|
942
|
+
...
|
943
|
+
|
944
|
+
@typing.overload
|
945
|
+
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]]]:
|
946
|
+
"""
|
947
|
+
Specifies the PyPI packages for the step.
|
948
|
+
|
949
|
+
Information in this decorator will augment any
|
950
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
951
|
+
you can use `@pypi_base` to set packages required by all
|
952
|
+
steps and use `@pypi` to specify step-specific overrides.
|
953
|
+
|
954
|
+
Parameters
|
955
|
+
----------
|
956
|
+
packages : Dict[str, str], default: {}
|
957
|
+
Packages to use for this step. The key is the name of the package
|
719
958
|
and the value is the version to use.
|
720
959
|
python : str, optional, default: None
|
721
960
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
@@ -808,34 +1047,69 @@ def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
808
1047
|
"""
|
809
1048
|
...
|
810
1049
|
|
811
|
-
|
812
|
-
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]]]:
|
813
|
-
"""
|
814
|
-
Specifies environment variables to be set prior to the execution of a step.
|
815
|
-
|
816
|
-
Parameters
|
817
|
-
----------
|
818
|
-
vars : Dict[str, str], default {}
|
819
|
-
Dictionary of environment variables to set.
|
820
|
-
"""
|
821
|
-
...
|
822
|
-
|
823
|
-
@typing.overload
|
824
|
-
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
825
|
-
...
|
826
|
-
|
827
|
-
@typing.overload
|
828
|
-
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
829
|
-
...
|
830
|
-
|
831
|
-
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
1050
|
+
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]]]:
|
832
1051
|
"""
|
833
|
-
Specifies
|
1052
|
+
Specifies that this step should execute on Kubernetes.
|
834
1053
|
|
835
1054
|
Parameters
|
836
1055
|
----------
|
837
|
-
|
838
|
-
|
1056
|
+
cpu : int, default 1
|
1057
|
+
Number of CPUs required for this step. If `@resources` is
|
1058
|
+
also present, the maximum value from all decorators is used.
|
1059
|
+
memory : int, default 4096
|
1060
|
+
Memory size (in MB) required for this step. If
|
1061
|
+
`@resources` is also present, the maximum value from all decorators is
|
1062
|
+
used.
|
1063
|
+
disk : int, default 10240
|
1064
|
+
Disk size (in MB) required for this step. If
|
1065
|
+
`@resources` is also present, the maximum value from all decorators is
|
1066
|
+
used.
|
1067
|
+
image : str, optional, default None
|
1068
|
+
Docker image to use when launching on Kubernetes. If not specified, and
|
1069
|
+
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
1070
|
+
not, a default Docker image mapping to the current version of Python is used.
|
1071
|
+
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
1072
|
+
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
1073
|
+
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
1074
|
+
Kubernetes service account to use when launching pod in Kubernetes.
|
1075
|
+
secrets : List[str], optional, default None
|
1076
|
+
Kubernetes secrets to use when launching pod in Kubernetes. These
|
1077
|
+
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
1078
|
+
in Metaflow configuration.
|
1079
|
+
node_selector: Union[Dict[str,str], str], optional, default None
|
1080
|
+
Kubernetes node selector(s) to apply to the pod running the task.
|
1081
|
+
Can be passed in as a comma separated string of values e.g. "kubernetes.io/os=linux,kubernetes.io/arch=amd64"
|
1082
|
+
or as a dictionary {"kubernetes.io/os": "linux", "kubernetes.io/arch": "amd64"}
|
1083
|
+
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
1084
|
+
Kubernetes namespace to use when launching pod in Kubernetes.
|
1085
|
+
gpu : int, optional, default None
|
1086
|
+
Number of GPUs required for this step. A value of zero implies that
|
1087
|
+
the scheduled node should not have GPUs.
|
1088
|
+
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
1089
|
+
The vendor of the GPUs to be used for this step.
|
1090
|
+
tolerations : List[str], default []
|
1091
|
+
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
1092
|
+
Kubernetes tolerations to use when launching pod in Kubernetes.
|
1093
|
+
use_tmpfs : bool, default False
|
1094
|
+
This enables an explicit tmpfs mount for this step.
|
1095
|
+
tmpfs_tempdir : bool, default True
|
1096
|
+
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
1097
|
+
tmpfs_size : int, optional, default: None
|
1098
|
+
The value for the size (in MiB) of the tmpfs mount for this step.
|
1099
|
+
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
1100
|
+
memory allocated for this step.
|
1101
|
+
tmpfs_path : str, optional, default /metaflow_temp
|
1102
|
+
Path to tmpfs mount for this step.
|
1103
|
+
persistent_volume_claims : Dict[str, str], optional, default None
|
1104
|
+
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
1105
|
+
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
1106
|
+
shared_memory: int, optional
|
1107
|
+
Shared memory size (in MiB) required for this step
|
1108
|
+
port: int, optional
|
1109
|
+
Port number to specify in the Kubernetes job object
|
1110
|
+
compute_pool : str, optional, default None
|
1111
|
+
Compute pool to be used for for this step.
|
1112
|
+
If not specified, any accessible compute pool within the perimeter is used.
|
839
1113
|
"""
|
840
1114
|
...
|
841
1115
|
|
@@ -919,238 +1193,161 @@ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
919
1193
|
"""
|
920
1194
|
...
|
921
1195
|
|
922
|
-
|
923
|
-
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]]]:
|
1196
|
+
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]]:
|
924
1197
|
"""
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
929
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
930
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
931
|
-
|
932
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
933
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
934
|
-
ensuring that the flow execution can continue.
|
1198
|
+
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.
|
1199
|
+
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.
|
935
1200
|
|
936
1201
|
Parameters
|
937
1202
|
----------
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
1203
|
+
timeout : int
|
1204
|
+
Time, in seconds before the task times out and fails. (Default: 3600)
|
1205
|
+
poke_interval : int
|
1206
|
+
Time in seconds that the job should wait in between each try. (Default: 60)
|
1207
|
+
mode : str
|
1208
|
+
How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
|
1209
|
+
exponential_backoff : bool
|
1210
|
+
allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
|
1211
|
+
pool : str
|
1212
|
+
the slot pool this task should run in,
|
1213
|
+
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1214
|
+
soft_fail : bool
|
1215
|
+
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1216
|
+
name : str
|
1217
|
+
Name of the sensor on Airflow
|
1218
|
+
description : str
|
1219
|
+
Description of sensor in the Airflow UI
|
1220
|
+
external_dag_id : str
|
1221
|
+
The dag_id that contains the task you want to wait for.
|
1222
|
+
external_task_ids : List[str]
|
1223
|
+
The list of task_ids that you want to wait for.
|
1224
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
1225
|
+
allowed_states : List[str]
|
1226
|
+
Iterable of allowed states, (Default: ['success'])
|
1227
|
+
failed_states : List[str]
|
1228
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
1229
|
+
execution_delta : datetime.timedelta
|
1230
|
+
time difference with the previous execution to look at,
|
1231
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
1232
|
+
check_existence: bool
|
1233
|
+
Set to True to check if the external task exists or check if
|
1234
|
+
the DAG to wait for exists. (Default: True)
|
942
1235
|
"""
|
943
1236
|
...
|
944
1237
|
|
945
|
-
|
946
|
-
def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
947
|
-
...
|
948
|
-
|
949
|
-
@typing.overload
|
950
|
-
def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
951
|
-
...
|
952
|
-
|
953
|
-
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):
|
1238
|
+
def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
954
1239
|
"""
|
955
|
-
Specifies
|
956
|
-
to a step needs to be retried.
|
1240
|
+
Specifies what flows belong to the same project.
|
957
1241
|
|
958
|
-
|
959
|
-
|
960
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
961
|
-
|
962
|
-
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
963
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
964
|
-
ensuring that the flow execution can continue.
|
1242
|
+
A project-specific namespace is created for all flows that
|
1243
|
+
use the same `@project(name)`.
|
965
1244
|
|
966
1245
|
Parameters
|
967
1246
|
----------
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
1247
|
+
name : str
|
1248
|
+
Project name. Make sure that the name is unique amongst all
|
1249
|
+
projects that use the same production scheduler. The name may
|
1250
|
+
contain only lowercase alphanumeric characters and underscores.
|
1251
|
+
|
1252
|
+
|
972
1253
|
"""
|
973
1254
|
...
|
974
1255
|
|
975
1256
|
@typing.overload
|
976
|
-
def
|
1257
|
+
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]]:
|
977
1258
|
"""
|
978
|
-
Specifies the
|
979
|
-
|
980
|
-
Use `@resources` to specify the resource requirements
|
981
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
982
|
-
|
983
|
-
You can choose the compute layer on the command line by executing e.g.
|
984
|
-
```
|
985
|
-
python myflow.py run --with batch
|
986
|
-
```
|
987
|
-
or
|
988
|
-
```
|
989
|
-
python myflow.py run --with kubernetes
|
990
|
-
```
|
991
|
-
which executes the flow on the desired system using the
|
992
|
-
requirements specified in `@resources`.
|
1259
|
+
Specifies the times when the flow should be run when running on a
|
1260
|
+
production scheduler.
|
993
1261
|
|
994
1262
|
Parameters
|
995
1263
|
----------
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1264
|
+
hourly : bool, default False
|
1265
|
+
Run the workflow hourly.
|
1266
|
+
daily : bool, default True
|
1267
|
+
Run the workflow daily.
|
1268
|
+
weekly : bool, default False
|
1269
|
+
Run the workflow weekly.
|
1270
|
+
cron : str, optional, default None
|
1271
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1272
|
+
specified by this expression.
|
1273
|
+
timezone : str, optional, default None
|
1274
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1275
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1007
1276
|
"""
|
1008
1277
|
...
|
1009
1278
|
|
1010
1279
|
@typing.overload
|
1011
|
-
def
|
1012
|
-
...
|
1013
|
-
|
1014
|
-
@typing.overload
|
1015
|
-
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1016
|
-
...
|
1017
|
-
|
1018
|
-
def resources(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, cpu: int = 1, gpu: int = 0, disk: typing.Optional[int] = None, memory: int = 4096, shared_memory: typing.Optional[int] = None):
|
1019
|
-
"""
|
1020
|
-
Specifies the resources needed when executing this step.
|
1021
|
-
|
1022
|
-
Use `@resources` to specify the resource requirements
|
1023
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
1024
|
-
|
1025
|
-
You can choose the compute layer on the command line by executing e.g.
|
1026
|
-
```
|
1027
|
-
python myflow.py run --with batch
|
1028
|
-
```
|
1029
|
-
or
|
1030
|
-
```
|
1031
|
-
python myflow.py run --with kubernetes
|
1032
|
-
```
|
1033
|
-
which executes the flow on the desired system using the
|
1034
|
-
requirements specified in `@resources`.
|
1035
|
-
|
1036
|
-
Parameters
|
1037
|
-
----------
|
1038
|
-
cpu : int, default 1
|
1039
|
-
Number of CPUs required for this step.
|
1040
|
-
gpu : int, default 0
|
1041
|
-
Number of GPUs required for this step.
|
1042
|
-
disk : int, optional, default None
|
1043
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
1044
|
-
memory : int, default 4096
|
1045
|
-
Memory size (in MB) required for this step.
|
1046
|
-
shared_memory : int, optional, default None
|
1047
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
1048
|
-
This parameter maps to the `--shm-size` option in Docker.
|
1049
|
-
"""
|
1280
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1050
1281
|
...
|
1051
1282
|
|
1052
|
-
def
|
1283
|
+
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):
|
1053
1284
|
"""
|
1054
|
-
Specifies
|
1285
|
+
Specifies the times when the flow should be run when running on a
|
1286
|
+
production scheduler.
|
1055
1287
|
|
1056
1288
|
Parameters
|
1057
1289
|
----------
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
Docker image to use when launching on Kubernetes. If not specified, and
|
1071
|
-
METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
|
1072
|
-
not, a default Docker image mapping to the current version of Python is used.
|
1073
|
-
image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
|
1074
|
-
If given, the imagePullPolicy to be applied to the Docker image of the step.
|
1075
|
-
service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
|
1076
|
-
Kubernetes service account to use when launching pod in Kubernetes.
|
1077
|
-
secrets : List[str], optional, default None
|
1078
|
-
Kubernetes secrets to use when launching pod in Kubernetes. These
|
1079
|
-
secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
|
1080
|
-
in Metaflow configuration.
|
1081
|
-
node_selector: Union[Dict[str,str], str], optional, default None
|
1082
|
-
Kubernetes node selector(s) to apply to the pod running the task.
|
1083
|
-
Can be passed in as a comma separated string of values e.g. "kubernetes.io/os=linux,kubernetes.io/arch=amd64"
|
1084
|
-
or as a dictionary {"kubernetes.io/os": "linux", "kubernetes.io/arch": "amd64"}
|
1085
|
-
namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
|
1086
|
-
Kubernetes namespace to use when launching pod in Kubernetes.
|
1087
|
-
gpu : int, optional, default None
|
1088
|
-
Number of GPUs required for this step. A value of zero implies that
|
1089
|
-
the scheduled node should not have GPUs.
|
1090
|
-
gpu_vendor : str, default KUBERNETES_GPU_VENDOR
|
1091
|
-
The vendor of the GPUs to be used for this step.
|
1092
|
-
tolerations : List[str], default []
|
1093
|
-
The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
|
1094
|
-
Kubernetes tolerations to use when launching pod in Kubernetes.
|
1095
|
-
use_tmpfs : bool, default False
|
1096
|
-
This enables an explicit tmpfs mount for this step.
|
1097
|
-
tmpfs_tempdir : bool, default True
|
1098
|
-
sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
|
1099
|
-
tmpfs_size : int, optional, default: None
|
1100
|
-
The value for the size (in MiB) of the tmpfs mount for this step.
|
1101
|
-
This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
|
1102
|
-
memory allocated for this step.
|
1103
|
-
tmpfs_path : str, optional, default /metaflow_temp
|
1104
|
-
Path to tmpfs mount for this step.
|
1105
|
-
persistent_volume_claims : Dict[str, str], optional, default None
|
1106
|
-
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
|
1107
|
-
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
|
1108
|
-
shared_memory: int, optional
|
1109
|
-
Shared memory size (in MiB) required for this step
|
1110
|
-
port: int, optional
|
1111
|
-
Port number to specify in the Kubernetes job object
|
1112
|
-
compute_pool : str, optional, default None
|
1113
|
-
Compute pool to be used for for this step.
|
1114
|
-
If not specified, any accessible compute pool within the perimeter is used.
|
1290
|
+
hourly : bool, default False
|
1291
|
+
Run the workflow hourly.
|
1292
|
+
daily : bool, default True
|
1293
|
+
Run the workflow daily.
|
1294
|
+
weekly : bool, default False
|
1295
|
+
Run the workflow weekly.
|
1296
|
+
cron : str, optional, default None
|
1297
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1298
|
+
specified by this expression.
|
1299
|
+
timezone : str, optional, default None
|
1300
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1301
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1115
1302
|
"""
|
1116
1303
|
...
|
1117
1304
|
|
1118
1305
|
@typing.overload
|
1119
|
-
def
|
1306
|
+
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]]:
|
1120
1307
|
"""
|
1121
|
-
Specifies the
|
1308
|
+
Specifies the Conda environment for all steps of the flow.
|
1309
|
+
|
1310
|
+
Use `@conda_base` to set common libraries required by all
|
1311
|
+
steps and use `@conda` to specify step-specific additions.
|
1122
1312
|
|
1123
|
-
Use `@pypi_base` to set common packages required by all
|
1124
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1125
1313
|
Parameters
|
1126
1314
|
----------
|
1127
|
-
packages : Dict[str, str], default
|
1315
|
+
packages : Dict[str, str], default {}
|
1128
1316
|
Packages to use for this flow. The key is the name of the package
|
1129
1317
|
and the value is the version to use.
|
1130
|
-
|
1318
|
+
libraries : Dict[str, str], default {}
|
1319
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1320
|
+
python : str, optional, default None
|
1131
1321
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1132
1322
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1323
|
+
disabled : bool, default False
|
1324
|
+
If set to True, disables Conda.
|
1133
1325
|
"""
|
1134
1326
|
...
|
1135
1327
|
|
1136
1328
|
@typing.overload
|
1137
|
-
def
|
1329
|
+
def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1138
1330
|
...
|
1139
1331
|
|
1140
|
-
def
|
1332
|
+
def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, libraries: typing.Dict[str, str] = {}, python: typing.Optional[str] = None, disabled: bool = False):
|
1141
1333
|
"""
|
1142
|
-
Specifies the
|
1334
|
+
Specifies the Conda environment for all steps of the flow.
|
1335
|
+
|
1336
|
+
Use `@conda_base` to set common libraries required by all
|
1337
|
+
steps and use `@conda` to specify step-specific additions.
|
1143
1338
|
|
1144
|
-
Use `@pypi_base` to set common packages required by all
|
1145
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1146
1339
|
Parameters
|
1147
1340
|
----------
|
1148
|
-
packages : Dict[str, str], default
|
1341
|
+
packages : Dict[str, str], default {}
|
1149
1342
|
Packages to use for this flow. The key is the name of the package
|
1150
1343
|
and the value is the version to use.
|
1151
|
-
|
1344
|
+
libraries : Dict[str, str], default {}
|
1345
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1346
|
+
python : str, optional, default None
|
1152
1347
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1153
1348
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1349
|
+
disabled : bool, default False
|
1350
|
+
If set to True, disables Conda.
|
1154
1351
|
"""
|
1155
1352
|
...
|
1156
1353
|
|
@@ -1185,94 +1382,145 @@ def nim(*, models: "list[NIM]", backend: str) -> typing.Callable[[typing.Type[Fl
|
|
1185
1382
|
"""
|
1186
1383
|
...
|
1187
1384
|
|
1188
|
-
|
1385
|
+
@typing.overload
|
1386
|
+
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]]:
|
1189
1387
|
"""
|
1190
|
-
|
1191
|
-
|
1388
|
+
Specifies the flow(s) that this flow depends on.
|
1389
|
+
|
1390
|
+
```
|
1391
|
+
@trigger_on_finish(flow='FooFlow')
|
1392
|
+
```
|
1393
|
+
or
|
1394
|
+
```
|
1395
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1396
|
+
```
|
1397
|
+
This decorator respects the @project decorator and triggers the flow
|
1398
|
+
when upstream runs within the same namespace complete successfully
|
1399
|
+
|
1400
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1401
|
+
by specifying the fully qualified project_flow_name.
|
1402
|
+
```
|
1403
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1404
|
+
```
|
1405
|
+
or
|
1406
|
+
```
|
1407
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1408
|
+
```
|
1409
|
+
|
1410
|
+
You can also specify just the project or project branch (other values will be
|
1411
|
+
inferred from the current project or project branch):
|
1412
|
+
```
|
1413
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1414
|
+
```
|
1415
|
+
|
1416
|
+
Note that `branch` is typically one of:
|
1417
|
+
- `prod`
|
1418
|
+
- `user.bob`
|
1419
|
+
- `test.my_experiment`
|
1420
|
+
- `prod.staging`
|
1192
1421
|
|
1193
1422
|
Parameters
|
1194
1423
|
----------
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
pool : str
|
1204
|
-
the slot pool this task should run in,
|
1205
|
-
slot pools are a way to limit concurrency for certain tasks. (Default:None)
|
1206
|
-
soft_fail : bool
|
1207
|
-
Set to true to mark the task as SKIPPED on failure. (Default: False)
|
1208
|
-
name : str
|
1209
|
-
Name of the sensor on Airflow
|
1210
|
-
description : str
|
1211
|
-
Description of sensor in the Airflow UI
|
1212
|
-
external_dag_id : str
|
1213
|
-
The dag_id that contains the task you want to wait for.
|
1214
|
-
external_task_ids : List[str]
|
1215
|
-
The list of task_ids that you want to wait for.
|
1216
|
-
If None (default value) the sensor waits for the DAG. (Default: None)
|
1217
|
-
allowed_states : List[str]
|
1218
|
-
Iterable of allowed states, (Default: ['success'])
|
1219
|
-
failed_states : List[str]
|
1220
|
-
Iterable of failed or dis-allowed states. (Default: None)
|
1221
|
-
execution_delta : datetime.timedelta
|
1222
|
-
time difference with the previous execution to look at,
|
1223
|
-
the default is the same logical date as the current task or DAG. (Default: None)
|
1224
|
-
check_existence: bool
|
1225
|
-
Set to True to check if the external task exists or check if
|
1226
|
-
the DAG to wait for exists. (Default: True)
|
1424
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1425
|
+
Upstream flow dependency for this flow.
|
1426
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1427
|
+
Upstream flow dependencies for this flow.
|
1428
|
+
options : Dict[str, Any], default {}
|
1429
|
+
Backend-specific configuration for tuning eventing behavior.
|
1430
|
+
|
1431
|
+
|
1227
1432
|
"""
|
1228
1433
|
...
|
1229
1434
|
|
1230
1435
|
@typing.overload
|
1231
|
-
def
|
1436
|
+
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1437
|
+
...
|
1438
|
+
|
1439
|
+
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] = {}):
|
1232
1440
|
"""
|
1233
|
-
Specifies the
|
1441
|
+
Specifies the flow(s) that this flow depends on.
|
1234
1442
|
|
1235
|
-
|
1236
|
-
|
1443
|
+
```
|
1444
|
+
@trigger_on_finish(flow='FooFlow')
|
1445
|
+
```
|
1446
|
+
or
|
1447
|
+
```
|
1448
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1449
|
+
```
|
1450
|
+
This decorator respects the @project decorator and triggers the flow
|
1451
|
+
when upstream runs within the same namespace complete successfully
|
1452
|
+
|
1453
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1454
|
+
by specifying the fully qualified project_flow_name.
|
1455
|
+
```
|
1456
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1457
|
+
```
|
1458
|
+
or
|
1459
|
+
```
|
1460
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1461
|
+
```
|
1462
|
+
|
1463
|
+
You can also specify just the project or project branch (other values will be
|
1464
|
+
inferred from the current project or project branch):
|
1465
|
+
```
|
1466
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1467
|
+
```
|
1468
|
+
|
1469
|
+
Note that `branch` is typically one of:
|
1470
|
+
- `prod`
|
1471
|
+
- `user.bob`
|
1472
|
+
- `test.my_experiment`
|
1473
|
+
- `prod.staging`
|
1474
|
+
|
1475
|
+
Parameters
|
1476
|
+
----------
|
1477
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1478
|
+
Upstream flow dependency for this flow.
|
1479
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1480
|
+
Upstream flow dependencies for this flow.
|
1481
|
+
options : Dict[str, Any], default {}
|
1482
|
+
Backend-specific configuration for tuning eventing behavior.
|
1483
|
+
|
1484
|
+
|
1485
|
+
"""
|
1486
|
+
...
|
1487
|
+
|
1488
|
+
@typing.overload
|
1489
|
+
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1490
|
+
"""
|
1491
|
+
Specifies the PyPI packages for all steps of the flow.
|
1237
1492
|
|
1493
|
+
Use `@pypi_base` to set common packages required by all
|
1494
|
+
steps and use `@pypi` to specify step-specific overrides.
|
1238
1495
|
Parameters
|
1239
1496
|
----------
|
1240
|
-
packages : Dict[str, str], default {}
|
1497
|
+
packages : Dict[str, str], default: {}
|
1241
1498
|
Packages to use for this flow. The key is the name of the package
|
1242
1499
|
and the value is the version to use.
|
1243
|
-
|
1244
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1245
|
-
python : str, optional, default None
|
1500
|
+
python : str, optional, default: None
|
1246
1501
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1247
1502
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1248
|
-
disabled : bool, default False
|
1249
|
-
If set to True, disables Conda.
|
1250
1503
|
"""
|
1251
1504
|
...
|
1252
1505
|
|
1253
1506
|
@typing.overload
|
1254
|
-
def
|
1507
|
+
def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1255
1508
|
...
|
1256
1509
|
|
1257
|
-
def
|
1510
|
+
def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
1258
1511
|
"""
|
1259
|
-
Specifies the
|
1260
|
-
|
1261
|
-
Use `@conda_base` to set common libraries required by all
|
1262
|
-
steps and use `@conda` to specify step-specific additions.
|
1512
|
+
Specifies the PyPI packages for all steps of the flow.
|
1263
1513
|
|
1514
|
+
Use `@pypi_base` to set common packages required by all
|
1515
|
+
steps and use `@pypi` to specify step-specific overrides.
|
1264
1516
|
Parameters
|
1265
1517
|
----------
|
1266
|
-
packages : Dict[str, str], default {}
|
1518
|
+
packages : Dict[str, str], default: {}
|
1267
1519
|
Packages to use for this flow. The key is the name of the package
|
1268
1520
|
and the value is the version to use.
|
1269
|
-
|
1270
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1271
|
-
python : str, optional, default None
|
1521
|
+
python : str, optional, default: None
|
1272
1522
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1273
1523
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1274
|
-
disabled : bool, default False
|
1275
|
-
If set to True, disables Conda.
|
1276
1524
|
"""
|
1277
1525
|
...
|
1278
1526
|
|
@@ -1371,73 +1619,6 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
|
|
1371
1619
|
"""
|
1372
1620
|
...
|
1373
1621
|
|
1374
|
-
def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1375
|
-
"""
|
1376
|
-
Specifies what flows belong to the same project.
|
1377
|
-
|
1378
|
-
A project-specific namespace is created for all flows that
|
1379
|
-
use the same `@project(name)`.
|
1380
|
-
|
1381
|
-
Parameters
|
1382
|
-
----------
|
1383
|
-
name : str
|
1384
|
-
Project name. Make sure that the name is unique amongst all
|
1385
|
-
projects that use the same production scheduler. The name may
|
1386
|
-
contain only lowercase alphanumeric characters and underscores.
|
1387
|
-
|
1388
|
-
|
1389
|
-
"""
|
1390
|
-
...
|
1391
|
-
|
1392
|
-
@typing.overload
|
1393
|
-
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]]:
|
1394
|
-
"""
|
1395
|
-
Specifies the times when the flow should be run when running on a
|
1396
|
-
production scheduler.
|
1397
|
-
|
1398
|
-
Parameters
|
1399
|
-
----------
|
1400
|
-
hourly : bool, default False
|
1401
|
-
Run the workflow hourly.
|
1402
|
-
daily : bool, default True
|
1403
|
-
Run the workflow daily.
|
1404
|
-
weekly : bool, default False
|
1405
|
-
Run the workflow weekly.
|
1406
|
-
cron : str, optional, default None
|
1407
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1408
|
-
specified by this expression.
|
1409
|
-
timezone : str, optional, default None
|
1410
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1411
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1412
|
-
"""
|
1413
|
-
...
|
1414
|
-
|
1415
|
-
@typing.overload
|
1416
|
-
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1417
|
-
...
|
1418
|
-
|
1419
|
-
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):
|
1420
|
-
"""
|
1421
|
-
Specifies the times when the flow should be run when running on a
|
1422
|
-
production scheduler.
|
1423
|
-
|
1424
|
-
Parameters
|
1425
|
-
----------
|
1426
|
-
hourly : bool, default False
|
1427
|
-
Run the workflow hourly.
|
1428
|
-
daily : bool, default True
|
1429
|
-
Run the workflow daily.
|
1430
|
-
weekly : bool, default False
|
1431
|
-
Run the workflow weekly.
|
1432
|
-
cron : str, optional, default None
|
1433
|
-
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1434
|
-
specified by this expression.
|
1435
|
-
timezone : str, optional, default None
|
1436
|
-
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1437
|
-
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1438
|
-
"""
|
1439
|
-
...
|
1440
|
-
|
1441
1622
|
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]]:
|
1442
1623
|
"""
|
1443
1624
|
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)
|
@@ -1480,109 +1661,6 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
|
|
1480
1661
|
"""
|
1481
1662
|
...
|
1482
1663
|
|
1483
|
-
@typing.overload
|
1484
|
-
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]]:
|
1485
|
-
"""
|
1486
|
-
Specifies the flow(s) that this flow depends on.
|
1487
|
-
|
1488
|
-
```
|
1489
|
-
@trigger_on_finish(flow='FooFlow')
|
1490
|
-
```
|
1491
|
-
or
|
1492
|
-
```
|
1493
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1494
|
-
```
|
1495
|
-
This decorator respects the @project decorator and triggers the flow
|
1496
|
-
when upstream runs within the same namespace complete successfully
|
1497
|
-
|
1498
|
-
Additionally, you can specify project aware upstream flow dependencies
|
1499
|
-
by specifying the fully qualified project_flow_name.
|
1500
|
-
```
|
1501
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1502
|
-
```
|
1503
|
-
or
|
1504
|
-
```
|
1505
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1506
|
-
```
|
1507
|
-
|
1508
|
-
You can also specify just the project or project branch (other values will be
|
1509
|
-
inferred from the current project or project branch):
|
1510
|
-
```
|
1511
|
-
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1512
|
-
```
|
1513
|
-
|
1514
|
-
Note that `branch` is typically one of:
|
1515
|
-
- `prod`
|
1516
|
-
- `user.bob`
|
1517
|
-
- `test.my_experiment`
|
1518
|
-
- `prod.staging`
|
1519
|
-
|
1520
|
-
Parameters
|
1521
|
-
----------
|
1522
|
-
flow : Union[str, Dict[str, str]], optional, default None
|
1523
|
-
Upstream flow dependency for this flow.
|
1524
|
-
flows : List[Union[str, Dict[str, str]]], default []
|
1525
|
-
Upstream flow dependencies for this flow.
|
1526
|
-
options : Dict[str, Any], default {}
|
1527
|
-
Backend-specific configuration for tuning eventing behavior.
|
1528
|
-
|
1529
|
-
|
1530
|
-
"""
|
1531
|
-
...
|
1532
|
-
|
1533
|
-
@typing.overload
|
1534
|
-
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1535
|
-
...
|
1536
|
-
|
1537
|
-
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] = {}):
|
1538
|
-
"""
|
1539
|
-
Specifies the flow(s) that this flow depends on.
|
1540
|
-
|
1541
|
-
```
|
1542
|
-
@trigger_on_finish(flow='FooFlow')
|
1543
|
-
```
|
1544
|
-
or
|
1545
|
-
```
|
1546
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1547
|
-
```
|
1548
|
-
This decorator respects the @project decorator and triggers the flow
|
1549
|
-
when upstream runs within the same namespace complete successfully
|
1550
|
-
|
1551
|
-
Additionally, you can specify project aware upstream flow dependencies
|
1552
|
-
by specifying the fully qualified project_flow_name.
|
1553
|
-
```
|
1554
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1555
|
-
```
|
1556
|
-
or
|
1557
|
-
```
|
1558
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1559
|
-
```
|
1560
|
-
|
1561
|
-
You can also specify just the project or project branch (other values will be
|
1562
|
-
inferred from the current project or project branch):
|
1563
|
-
```
|
1564
|
-
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1565
|
-
```
|
1566
|
-
|
1567
|
-
Note that `branch` is typically one of:
|
1568
|
-
- `prod`
|
1569
|
-
- `user.bob`
|
1570
|
-
- `test.my_experiment`
|
1571
|
-
- `prod.staging`
|
1572
|
-
|
1573
|
-
Parameters
|
1574
|
-
----------
|
1575
|
-
flow : Union[str, Dict[str, str]], optional, default None
|
1576
|
-
Upstream flow dependency for this flow.
|
1577
|
-
flows : List[Union[str, Dict[str, str]]], default []
|
1578
|
-
Upstream flow dependencies for this flow.
|
1579
|
-
options : Dict[str, Any], default {}
|
1580
|
-
Backend-specific configuration for tuning eventing behavior.
|
1581
|
-
|
1582
|
-
|
1583
|
-
"""
|
1584
|
-
...
|
1585
|
-
|
1586
1664
|
def namespace(ns: typing.Optional[str]) -> typing.Optional[str]:
|
1587
1665
|
"""
|
1588
1666
|
Switch namespace to the one provided.
|
@@ -1661,6 +1739,19 @@ def default_metadata() -> str:
|
|
1661
1739
|
...
|
1662
1740
|
|
1663
1741
|
class Metaflow(object, metaclass=type):
|
1742
|
+
"""
|
1743
|
+
Entry point to all objects in the Metaflow universe.
|
1744
|
+
|
1745
|
+
This object can be used to list all the flows present either through the explicit property
|
1746
|
+
or by iterating over this object.
|
1747
|
+
|
1748
|
+
Attributes
|
1749
|
+
----------
|
1750
|
+
flows : List[Flow]
|
1751
|
+
Returns the list of all `Flow` objects known to this metadata provider. Note that only
|
1752
|
+
flows present in the current namespace will be returned. A `Flow` is present in a namespace
|
1753
|
+
if it has at least one run in the namespace.
|
1754
|
+
"""
|
1664
1755
|
def __init__(self):
|
1665
1756
|
...
|
1666
1757
|
@property
|
@@ -1712,6 +1803,17 @@ class Metaflow(object, metaclass=type):
|
|
1712
1803
|
...
|
1713
1804
|
|
1714
1805
|
class Flow(metaflow.client.core.MetaflowObject, metaclass=type):
|
1806
|
+
"""
|
1807
|
+
A Flow represents all existing flows with a certain name, in other words,
|
1808
|
+
classes derived from `FlowSpec`. A container of `Run` objects.
|
1809
|
+
|
1810
|
+
Attributes
|
1811
|
+
----------
|
1812
|
+
latest_run : Run
|
1813
|
+
Latest `Run` (in progress or completed, successfully or not) of this flow.
|
1814
|
+
latest_successful_run : Run
|
1815
|
+
Latest successfully completed `Run` of this flow.
|
1816
|
+
"""
|
1715
1817
|
def __init__(self, *args, **kwargs):
|
1716
1818
|
...
|
1717
1819
|
@property
|
@@ -1798,6 +1900,26 @@ class Flow(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
1798
1900
|
...
|
1799
1901
|
|
1800
1902
|
class Run(metaflow.client.core.MetaflowObject, metaclass=type):
|
1903
|
+
"""
|
1904
|
+
A `Run` represents an execution of a `Flow`. It is a container of `Step`s.
|
1905
|
+
|
1906
|
+
Attributes
|
1907
|
+
----------
|
1908
|
+
data : MetaflowData
|
1909
|
+
a shortcut to run['end'].task.data, i.e. data produced by this run.
|
1910
|
+
successful : bool
|
1911
|
+
True if the run completed successfully.
|
1912
|
+
finished : bool
|
1913
|
+
True if the run completed.
|
1914
|
+
finished_at : datetime
|
1915
|
+
Time this run finished.
|
1916
|
+
code : MetaflowCode
|
1917
|
+
Code package for this run (if present). See `MetaflowCode`.
|
1918
|
+
trigger : MetaflowTrigger
|
1919
|
+
Information about event(s) that triggered this run (if present). See `MetaflowTrigger`.
|
1920
|
+
end_task : Task
|
1921
|
+
`Task` for the end step (if it is present already).
|
1922
|
+
"""
|
1801
1923
|
def steps(self, *tags: str) -> typing.Iterator[metaflow.client.core.Step]:
|
1802
1924
|
"""
|
1803
1925
|
[Legacy function - do not use]
|
@@ -2030,6 +2152,23 @@ class Run(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2030
2152
|
...
|
2031
2153
|
|
2032
2154
|
class Step(metaflow.client.core.MetaflowObject, metaclass=type):
|
2155
|
+
"""
|
2156
|
+
A `Step` represents a user-defined step, that is, a method annotated with the `@step` decorator.
|
2157
|
+
|
2158
|
+
It contains `Task` objects associated with the step, that is, all executions of the
|
2159
|
+
`Step`. The step may contain multiple `Task`s in the case of a foreach step.
|
2160
|
+
|
2161
|
+
Attributes
|
2162
|
+
----------
|
2163
|
+
task : Task
|
2164
|
+
The first `Task` object in this step. This is a shortcut for retrieving the only
|
2165
|
+
task contained in a non-foreach step.
|
2166
|
+
finished_at : datetime
|
2167
|
+
Time when the latest `Task` of this step finished. Note that in the case of foreaches,
|
2168
|
+
this time may change during execution of the step.
|
2169
|
+
environment_info : Dict[str, Any]
|
2170
|
+
Information about the execution environment.
|
2171
|
+
"""
|
2033
2172
|
@property
|
2034
2173
|
def task(self) -> typing.Optional[metaflow.client.core.Task]:
|
2035
2174
|
"""
|
@@ -2164,6 +2303,55 @@ class Step(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2164
2303
|
...
|
2165
2304
|
|
2166
2305
|
class Task(metaflow.client.core.MetaflowObject, metaclass=type):
|
2306
|
+
"""
|
2307
|
+
A `Task` represents an execution of a `Step`.
|
2308
|
+
|
2309
|
+
It contains all `DataArtifact` objects produced by the task as
|
2310
|
+
well as metadata related to execution.
|
2311
|
+
|
2312
|
+
Note that the `@retry` decorator may cause multiple attempts of
|
2313
|
+
the task to be present. Usually you want the latest attempt, which
|
2314
|
+
is what instantiating a `Task` object returns by default. If
|
2315
|
+
you need to e.g. retrieve logs from a failed attempt, you can
|
2316
|
+
explicitly get information about a specific attempt by using the
|
2317
|
+
following syntax when creating a task:
|
2318
|
+
|
2319
|
+
`Task('flow/run/step/task', attempt=<attempt>)`
|
2320
|
+
|
2321
|
+
where `attempt=0` corresponds to the first attempt etc.
|
2322
|
+
|
2323
|
+
Attributes
|
2324
|
+
----------
|
2325
|
+
metadata : List[Metadata]
|
2326
|
+
List of all metadata events associated with the task.
|
2327
|
+
metadata_dict : Dict[str, str]
|
2328
|
+
A condensed version of `metadata`: A dictionary where keys
|
2329
|
+
are names of metadata events and values the latest corresponding event.
|
2330
|
+
data : MetaflowData
|
2331
|
+
Container of all data artifacts produced by this task. Note that this
|
2332
|
+
call downloads all data locally, so it can be slower than accessing
|
2333
|
+
artifacts individually. See `MetaflowData` for more information.
|
2334
|
+
artifacts : MetaflowArtifacts
|
2335
|
+
Container of `DataArtifact` objects produced by this task.
|
2336
|
+
successful : bool
|
2337
|
+
True if the task completed successfully.
|
2338
|
+
finished : bool
|
2339
|
+
True if the task completed.
|
2340
|
+
exception : object
|
2341
|
+
Exception raised by this task if there was one.
|
2342
|
+
finished_at : datetime
|
2343
|
+
Time this task finished.
|
2344
|
+
runtime_name : str
|
2345
|
+
Runtime this task was executed on.
|
2346
|
+
stdout : str
|
2347
|
+
Standard output for the task execution.
|
2348
|
+
stderr : str
|
2349
|
+
Standard error output for the task execution.
|
2350
|
+
code : MetaflowCode
|
2351
|
+
Code package for this task (if present). See `MetaflowCode`.
|
2352
|
+
environment_info : Dict[str, str]
|
2353
|
+
Information about the execution environment.
|
2354
|
+
"""
|
2167
2355
|
def __init__(self, *args, **kwargs):
|
2168
2356
|
...
|
2169
2357
|
@property
|
@@ -2478,6 +2666,21 @@ class Task(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2478
2666
|
...
|
2479
2667
|
|
2480
2668
|
class DataArtifact(metaflow.client.core.MetaflowObject, metaclass=type):
|
2669
|
+
"""
|
2670
|
+
A single data artifact and associated metadata. Note that this object does
|
2671
|
+
not contain other objects as it is the leaf object in the hierarchy.
|
2672
|
+
|
2673
|
+
Attributes
|
2674
|
+
----------
|
2675
|
+
data : object
|
2676
|
+
The data contained in this artifact, that is, the object produced during
|
2677
|
+
execution of this run.
|
2678
|
+
sha : string
|
2679
|
+
A unique ID of this artifact.
|
2680
|
+
finished_at : datetime
|
2681
|
+
Corresponds roughly to the `Task.finished_at` time of the parent `Task`.
|
2682
|
+
An alias for `DataArtifact.created_at`.
|
2683
|
+
"""
|
2481
2684
|
@property
|
2482
2685
|
def data(self) -> typing.Any:
|
2483
2686
|
"""
|
@@ -2534,6 +2737,44 @@ class DataArtifact(metaflow.client.core.MetaflowObject, metaclass=type):
|
|
2534
2737
|
...
|
2535
2738
|
|
2536
2739
|
class Runner(object, metaclass=type):
|
2740
|
+
"""
|
2741
|
+
Metaflow's Runner API that presents a programmatic interface
|
2742
|
+
to run flows and perform other operations either synchronously or asynchronously.
|
2743
|
+
The class expects a path to the flow file along with optional arguments
|
2744
|
+
that match top-level options on the command-line.
|
2745
|
+
|
2746
|
+
This class works as a context manager, calling `cleanup()` to remove
|
2747
|
+
temporary files at exit.
|
2748
|
+
|
2749
|
+
Example:
|
2750
|
+
```python
|
2751
|
+
with Runner('slowflow.py', pylint=False) as runner:
|
2752
|
+
result = runner.run(alpha=5, tags=["abc", "def"], max_workers=5)
|
2753
|
+
print(result.run.finished)
|
2754
|
+
```
|
2755
|
+
|
2756
|
+
Parameters
|
2757
|
+
----------
|
2758
|
+
flow_file : str
|
2759
|
+
Path to the flow file to run
|
2760
|
+
show_output : bool, default True
|
2761
|
+
Show the 'stdout' and 'stderr' to the console by default,
|
2762
|
+
Only applicable for synchronous 'run' and 'resume' functions.
|
2763
|
+
profile : Optional[str], default None
|
2764
|
+
Metaflow profile to use to run this run. If not specified, the default
|
2765
|
+
profile is used (or the one already set using `METAFLOW_PROFILE`)
|
2766
|
+
env : Optional[Dict], default None
|
2767
|
+
Additional environment variables to set for the Run. This overrides the
|
2768
|
+
environment set for this process.
|
2769
|
+
cwd : Optional[str], default None
|
2770
|
+
The directory to run the subprocess in; if not specified, the current
|
2771
|
+
directory is used.
|
2772
|
+
file_read_timeout : int, default 3600
|
2773
|
+
The timeout until which we try to read the runner attribute file.
|
2774
|
+
**kwargs : Any
|
2775
|
+
Additional arguments that you would pass to `python myflow.py` before
|
2776
|
+
the `run` command.
|
2777
|
+
"""
|
2537
2778
|
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):
|
2538
2779
|
...
|
2539
2780
|
def __enter__(self) -> metaflow.runner.metaflow_runner.Runner:
|
@@ -2626,6 +2867,42 @@ class Runner(object, metaclass=type):
|
|
2626
2867
|
...
|
2627
2868
|
|
2628
2869
|
class NBRunner(object, metaclass=type):
|
2870
|
+
"""
|
2871
|
+
A wrapper over `Runner` for executing flows defined in a Jupyter
|
2872
|
+
notebook cell.
|
2873
|
+
|
2874
|
+
Instantiate this class on the last line of a notebook cell where
|
2875
|
+
a `flow` is defined. In contrast to `Runner`, this class is not
|
2876
|
+
meant to be used in a context manager. Instead, use a blocking helper
|
2877
|
+
function like `nbrun` (which calls `cleanup()` internally) or call
|
2878
|
+
`cleanup()` explictly when using non-blocking APIs.
|
2879
|
+
|
2880
|
+
```python
|
2881
|
+
run = NBRunner(FlowName).nbrun()
|
2882
|
+
```
|
2883
|
+
|
2884
|
+
Parameters
|
2885
|
+
----------
|
2886
|
+
flow : FlowSpec
|
2887
|
+
Flow defined in the same cell
|
2888
|
+
show_output : bool, default True
|
2889
|
+
Show the 'stdout' and 'stderr' to the console by default,
|
2890
|
+
Only applicable for synchronous 'run' and 'resume' functions.
|
2891
|
+
profile : Optional[str], default None
|
2892
|
+
Metaflow profile to use to run this run. If not specified, the default
|
2893
|
+
profile is used (or the one already set using `METAFLOW_PROFILE`)
|
2894
|
+
env : Optional[Dict], default None
|
2895
|
+
Additional environment variables to set for the Run. This overrides the
|
2896
|
+
environment set for this process.
|
2897
|
+
base_dir : Optional[str], default None
|
2898
|
+
The directory to run the subprocess in; if not specified, a temporary
|
2899
|
+
directory is used.
|
2900
|
+
file_read_timeout : int, default 3600
|
2901
|
+
The timeout until which we try to read the runner attribute file.
|
2902
|
+
**kwargs : Any
|
2903
|
+
Additional arguments that you would pass to `python myflow.py` before
|
2904
|
+
the `run` command.
|
2905
|
+
"""
|
2629
2906
|
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):
|
2630
2907
|
...
|
2631
2908
|
def nbrun(self, **kwargs):
|
@@ -2732,6 +3009,30 @@ class NBRunner(object, metaclass=type):
|
|
2732
3009
|
...
|
2733
3010
|
|
2734
3011
|
class Deployer(object, metaclass=type):
|
3012
|
+
"""
|
3013
|
+
Use the `Deployer` class to configure and access one of the production
|
3014
|
+
orchestrators supported by Metaflow.
|
3015
|
+
|
3016
|
+
Parameters
|
3017
|
+
----------
|
3018
|
+
flow_file : str
|
3019
|
+
Path to the flow file to deploy.
|
3020
|
+
show_output : bool, default True
|
3021
|
+
Show the 'stdout' and 'stderr' to the console by default.
|
3022
|
+
profile : Optional[str], default None
|
3023
|
+
Metaflow profile to use for the deployment. If not specified, the default
|
3024
|
+
profile is used.
|
3025
|
+
env : Optional[Dict[str, str]], default None
|
3026
|
+
Additional environment variables to set for the deployment.
|
3027
|
+
cwd : Optional[str], default None
|
3028
|
+
The directory to run the subprocess in; if not specified, the current
|
3029
|
+
directory is used.
|
3030
|
+
file_read_timeout : int, default 3600
|
3031
|
+
The timeout until which we try to read the deployer attribute file.
|
3032
|
+
**kwargs : Any
|
3033
|
+
Additional arguments that you would pass to `python myflow.py` before
|
3034
|
+
the deployment command.
|
3035
|
+
"""
|
2735
3036
|
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):
|
2736
3037
|
...
|
2737
3038
|
def _Deployer__make_function(self, deployer_class):
|
@@ -2752,6 +3053,43 @@ class Deployer(object, metaclass=type):
|
|
2752
3053
|
...
|
2753
3054
|
|
2754
3055
|
class NBDeployer(object, metaclass=type):
|
3056
|
+
"""
|
3057
|
+
A wrapper over `Deployer` for deploying flows defined in a Jupyter
|
3058
|
+
notebook cell.
|
3059
|
+
|
3060
|
+
Instantiate this class on the last line of a notebook cell where
|
3061
|
+
a `flow` is defined. In contrast to `Deployer`, this class is not
|
3062
|
+
meant to be used in a context manager.
|
3063
|
+
|
3064
|
+
```python
|
3065
|
+
deployer = NBDeployer(FlowName)
|
3066
|
+
ar = deployer.argo_workflows(name="madhur")
|
3067
|
+
ar_obj = ar.create()
|
3068
|
+
result = ar_obj.trigger(alpha=300)
|
3069
|
+
print(result.status)
|
3070
|
+
print(result.run)
|
3071
|
+
result.terminate()
|
3072
|
+
```
|
3073
|
+
|
3074
|
+
Parameters
|
3075
|
+
----------
|
3076
|
+
flow : FlowSpec
|
3077
|
+
Flow defined in the same cell
|
3078
|
+
show_output : bool, default True
|
3079
|
+
Show the 'stdout' and 'stderr' to the console by default,
|
3080
|
+
profile : Optional[str], default None
|
3081
|
+
Metaflow profile to use to deploy this run. If not specified, the default
|
3082
|
+
profile is used (or the one already set using `METAFLOW_PROFILE`)
|
3083
|
+
env : Optional[Dict[str, str]], default None
|
3084
|
+
Additional environment variables to set. This overrides the
|
3085
|
+
environment set for this process.
|
3086
|
+
base_dir : Optional[str], default None
|
3087
|
+
The directory to run the subprocess in; if not specified, a temporary
|
3088
|
+
directory is used.
|
3089
|
+
**kwargs : Any
|
3090
|
+
Additional arguments that you would pass to `python myflow.py` i.e. options
|
3091
|
+
listed in `python myflow.py --help`
|
3092
|
+
"""
|
2755
3093
|
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):
|
2756
3094
|
...
|
2757
3095
|
def cleanup(self):
|