ob-metaflow-stubs 5.10__py2.py3-none-any.whl → 6.0.3.103rc0__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 +694 -498
- metaflow-stubs/cards.pyi +4 -4
- metaflow-stubs/cli.pyi +2 -2
- metaflow-stubs/client/__init__.pyi +4 -4
- metaflow-stubs/client/core.pyi +6 -6
- metaflow-stubs/client/filecache.pyi +2 -2
- metaflow-stubs/clone_util.pyi +2 -2
- metaflow-stubs/events.pyi +3 -3
- metaflow-stubs/exception.pyi +2 -2
- metaflow-stubs/flowspec.pyi +5 -5
- metaflow-stubs/generated_for.txt +1 -1
- metaflow-stubs/includefile.pyi +5 -5
- metaflow-stubs/info_file.pyi +2 -2
- metaflow-stubs/metadata/metadata.pyi +2 -2
- metaflow-stubs/metadata/util.pyi +2 -2
- metaflow-stubs/metaflow_config.pyi +2 -2
- metaflow-stubs/metaflow_current.pyi +133 -9
- metaflow-stubs/mflog/mflog.pyi +2 -2
- metaflow-stubs/multicore_utils.pyi +2 -2
- metaflow-stubs/parameters.pyi +4 -4
- metaflow-stubs/plugins/__init__.pyi +3 -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 +2 -2
- metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +2 -2
- metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +2 -2
- metaflow-stubs/plugins/argo/__init__.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
- metaflow-stubs/plugins/argo/argo_workflows.pyi +5 -5
- metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +6 -6
- metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +7 -7
- metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +2 -2
- 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 +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
- metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -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 +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
- metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +2 -2
- 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 +3 -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 +3 -3
- metaflow-stubs/plugins/cards/card_client.pyi +2 -2
- metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
- metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/basic.pyi +3 -3
- metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/components.pyi +4 -4
- metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
- metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +3 -3
- metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
- metaflow-stubs/plugins/cards/component_serializer.pyi +3 -3
- metaflow-stubs/plugins/cards/exception.pyi +2 -2
- metaflow-stubs/plugins/catch_decorator.pyi +2 -2
- metaflow-stubs/plugins/datatools/__init__.pyi +3 -3
- metaflow-stubs/plugins/datatools/local.pyi +2 -2
- metaflow-stubs/plugins/datatools/s3/__init__.pyi +3 -3
- metaflow-stubs/plugins/datatools/s3/s3.pyi +6 -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 +2 -2
- metaflow-stubs/plugins/events_decorator.pyi +2 -2
- metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
- metaflow-stubs/plugins/frameworks/pytorch.pyi +3 -3
- metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
- metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +3 -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 +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +3 -3
- metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +2 -2
- metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
- metaflow-stubs/plugins/logs_cli.pyi +3 -3
- metaflow-stubs/plugins/package_cli.pyi +2 -2
- metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
- metaflow-stubs/plugins/perimeters.pyi +2 -2
- metaflow-stubs/plugins/project_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/conda_environment.pyi +3 -3
- metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
- metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
- metaflow-stubs/plugins/pypi/utils.pyi +2 -2
- metaflow-stubs/plugins/resources_decorator.pyi +2 -2
- metaflow-stubs/plugins/retry_decorator.pyi +2 -2
- metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
- metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +2 -2
- metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
- metaflow-stubs/plugins/storage_executor.pyi +2 -2
- metaflow-stubs/plugins/tag_cli.pyi +4 -4
- metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
- metaflow-stubs/plugins/timeout_decorator.pyi +2 -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 +2 -2
- metaflow-stubs/runner/metaflow_runner.pyi +5 -5
- metaflow-stubs/runner/nbdeploy.pyi +2 -2
- metaflow-stubs/runner/nbrun.pyi +2 -2
- metaflow-stubs/runner/subprocess_manager.pyi +2 -2
- metaflow-stubs/runner/utils.pyi +2 -2
- metaflow-stubs/system/__init__.pyi +3 -3
- metaflow-stubs/system/system_logger.pyi +2 -2
- metaflow-stubs/system/system_monitor.pyi +3 -3
- metaflow-stubs/tagging_util.pyi +2 -2
- metaflow-stubs/tuple_util.pyi +2 -2
- {ob_metaflow_stubs-5.10.dist-info → ob_metaflow_stubs-6.0.3.103rc0.dist-info}/METADATA +1 -1
- ob_metaflow_stubs-6.0.3.103rc0.dist-info/RECORD +140 -0
- {ob_metaflow_stubs-5.10.dist-info → ob_metaflow_stubs-6.0.3.103rc0.dist-info}/WHEEL +1 -1
- ob_metaflow_stubs-5.10.dist-info/RECORD +0 -140
- {ob_metaflow_stubs-5.10.dist-info → ob_metaflow_stubs-6.0.3.103rc0.dist-info}/top_level.txt +0 -0
metaflow-stubs/__init__.pyi
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
##################################################################################
|
2
2
|
# Auto-generated Metaflow stub file #
|
3
|
-
# MF version: 2.12.22.1+ob(v1)
|
4
|
-
# Generated on 2024-09-
|
3
|
+
# MF version: 2.12.22.1+obcheckpoint(0.0.10);ob(v1) #
|
4
|
+
# Generated on 2024-09-20T18:44:03.631910 #
|
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.events
|
12
|
-
import metaflow.datastore.inputs
|
13
|
-
import metaflow.runner.metaflow_runner
|
14
|
-
import metaflow.metaflow_current
|
15
|
-
import metaflow.flowspec
|
16
11
|
import datetime
|
12
|
+
import metaflow.datastore.inputs
|
17
13
|
import metaflow.client.core
|
14
|
+
import metaflow.events
|
15
|
+
import metaflow.parameters
|
16
|
+
import metaflow.runner.metaflow_runner
|
18
17
|
import metaflow._vendor.click.types
|
18
|
+
import metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures
|
19
|
+
import metaflow.flowspec
|
19
20
|
import typing
|
20
|
-
import metaflow.
|
21
|
+
import metaflow.metaflow_current
|
21
22
|
FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
|
22
23
|
StepFlag = typing.NewType("StepFlag", bool)
|
23
24
|
|
@@ -433,57 +434,6 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
|
|
433
434
|
"""
|
434
435
|
...
|
435
436
|
|
436
|
-
@typing.overload
|
437
|
-
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]]]:
|
438
|
-
"""
|
439
|
-
Creates a human-readable report, a Metaflow Card, after this step completes.
|
440
|
-
|
441
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
442
|
-
|
443
|
-
Parameters
|
444
|
-
----------
|
445
|
-
type : str, default 'default'
|
446
|
-
Card type.
|
447
|
-
id : str, optional, default None
|
448
|
-
If multiple cards are present, use this id to identify this card.
|
449
|
-
options : Dict[str, Any], default {}
|
450
|
-
Options passed to the card. The contents depend on the card type.
|
451
|
-
timeout : int, default 45
|
452
|
-
Interrupt reporting if it takes more than this many seconds.
|
453
|
-
|
454
|
-
|
455
|
-
"""
|
456
|
-
...
|
457
|
-
|
458
|
-
@typing.overload
|
459
|
-
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
460
|
-
...
|
461
|
-
|
462
|
-
@typing.overload
|
463
|
-
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
464
|
-
...
|
465
|
-
|
466
|
-
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):
|
467
|
-
"""
|
468
|
-
Creates a human-readable report, a Metaflow Card, after this step completes.
|
469
|
-
|
470
|
-
Note that you may add multiple `@card` decorators in a step with different parameters.
|
471
|
-
|
472
|
-
Parameters
|
473
|
-
----------
|
474
|
-
type : str, default 'default'
|
475
|
-
Card type.
|
476
|
-
id : str, optional, default None
|
477
|
-
If multiple cards are present, use this id to identify this card.
|
478
|
-
options : Dict[str, Any], default {}
|
479
|
-
Options passed to the card. The contents depend on the card type.
|
480
|
-
timeout : int, default 45
|
481
|
-
Interrupt reporting if it takes more than this many seconds.
|
482
|
-
|
483
|
-
|
484
|
-
"""
|
485
|
-
...
|
486
|
-
|
487
437
|
@typing.overload
|
488
438
|
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]]]:
|
489
439
|
"""
|
@@ -534,145 +484,59 @@ def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
534
484
|
...
|
535
485
|
|
536
486
|
@typing.overload
|
537
|
-
def
|
487
|
+
def timeout(*, seconds: int = 0, minutes: int = 0, hours: int = 0) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
|
538
488
|
"""
|
539
|
-
Specifies
|
489
|
+
Specifies a timeout for your step.
|
540
490
|
|
541
|
-
|
542
|
-
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
543
|
-
you can use `@pypi_base` to set packages required by all
|
544
|
-
steps and use `@pypi` to specify step-specific overrides.
|
491
|
+
This decorator is useful if this step may hang indefinitely.
|
545
492
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
Packages to use for this step. The key is the name of the package
|
550
|
-
and the value is the version to use.
|
551
|
-
python : str, optional, default: None
|
552
|
-
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
553
|
-
that the version used will correspond to the version of the Python interpreter used to start the run.
|
554
|
-
"""
|
555
|
-
...
|
556
|
-
|
557
|
-
@typing.overload
|
558
|
-
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
559
|
-
...
|
560
|
-
|
561
|
-
@typing.overload
|
562
|
-
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
563
|
-
...
|
564
|
-
|
565
|
-
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):
|
566
|
-
"""
|
567
|
-
Specifies the PyPI packages for the step.
|
493
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
494
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
495
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
568
496
|
|
569
|
-
|
570
|
-
|
571
|
-
you can use `@pypi_base` to set packages required by all
|
572
|
-
steps and use `@pypi` to specify step-specific overrides.
|
497
|
+
Note that all the values specified in parameters are added together so if you specify
|
498
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
573
499
|
|
574
500
|
Parameters
|
575
501
|
----------
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
502
|
+
seconds : int, default 0
|
503
|
+
Number of seconds to wait prior to timing out.
|
504
|
+
minutes : int, default 0
|
505
|
+
Number of minutes to wait prior to timing out.
|
506
|
+
hours : int, default 0
|
507
|
+
Number of hours to wait prior to timing out.
|
582
508
|
"""
|
583
509
|
...
|
584
510
|
|
585
511
|
@typing.overload
|
586
|
-
def
|
587
|
-
"""
|
588
|
-
Internal decorator to support Fast bakery
|
589
|
-
"""
|
512
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
590
513
|
...
|
591
514
|
|
592
515
|
@typing.overload
|
593
|
-
def
|
594
|
-
...
|
595
|
-
|
596
|
-
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
597
|
-
"""
|
598
|
-
Internal decorator to support Fast bakery
|
599
|
-
"""
|
516
|
+
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
600
517
|
...
|
601
518
|
|
602
|
-
|
603
|
-
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]]]:
|
519
|
+
def timeout(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, seconds: int = 0, minutes: int = 0, hours: int = 0):
|
604
520
|
"""
|
605
|
-
Specifies
|
606
|
-
|
607
|
-
Use `@resources` to specify the resource requirements
|
608
|
-
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
609
|
-
|
610
|
-
You can choose the compute layer on the command line by executing e.g.
|
611
|
-
```
|
612
|
-
python myflow.py run --with batch
|
613
|
-
```
|
614
|
-
or
|
615
|
-
```
|
616
|
-
python myflow.py run --with kubernetes
|
617
|
-
```
|
618
|
-
which executes the flow on the desired system using the
|
619
|
-
requirements specified in `@resources`.
|
521
|
+
Specifies a timeout for your step.
|
620
522
|
|
621
|
-
|
622
|
-
----------
|
623
|
-
cpu : int, default 1
|
624
|
-
Number of CPUs required for this step.
|
625
|
-
gpu : int, default 0
|
626
|
-
Number of GPUs required for this step.
|
627
|
-
disk : int, optional, default None
|
628
|
-
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
629
|
-
memory : int, default 4096
|
630
|
-
Memory size (in MB) required for this step.
|
631
|
-
shared_memory : int, optional, default None
|
632
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
633
|
-
This parameter maps to the `--shm-size` option in Docker.
|
634
|
-
"""
|
635
|
-
...
|
636
|
-
|
637
|
-
@typing.overload
|
638
|
-
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
639
|
-
...
|
640
|
-
|
641
|
-
@typing.overload
|
642
|
-
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
643
|
-
...
|
644
|
-
|
645
|
-
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):
|
646
|
-
"""
|
647
|
-
Specifies the resources needed when executing this step.
|
523
|
+
This decorator is useful if this step may hang indefinitely.
|
648
524
|
|
649
|
-
|
650
|
-
|
525
|
+
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
526
|
+
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
527
|
+
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
651
528
|
|
652
|
-
|
653
|
-
|
654
|
-
python myflow.py run --with batch
|
655
|
-
```
|
656
|
-
or
|
657
|
-
```
|
658
|
-
python myflow.py run --with kubernetes
|
659
|
-
```
|
660
|
-
which executes the flow on the desired system using the
|
661
|
-
requirements specified in `@resources`.
|
529
|
+
Note that all the values specified in parameters are added together so if you specify
|
530
|
+
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
662
531
|
|
663
532
|
Parameters
|
664
533
|
----------
|
665
|
-
|
666
|
-
Number of
|
667
|
-
|
668
|
-
Number of
|
669
|
-
|
670
|
-
|
671
|
-
memory : int, default 4096
|
672
|
-
Memory size (in MB) required for this step.
|
673
|
-
shared_memory : int, optional, default None
|
674
|
-
The value for the size (in MiB) of the /dev/shm volume for this step.
|
675
|
-
This parameter maps to the `--shm-size` option in Docker.
|
534
|
+
seconds : int, default 0
|
535
|
+
Number of seconds to wait prior to timing out.
|
536
|
+
minutes : int, default 0
|
537
|
+
Number of minutes to wait prior to timing out.
|
538
|
+
hours : int, default 0
|
539
|
+
Number of hours to wait prior to timing out.
|
676
540
|
"""
|
677
541
|
...
|
678
542
|
|
@@ -710,56 +574,137 @@ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
|
|
710
574
|
...
|
711
575
|
|
712
576
|
@typing.overload
|
713
|
-
def
|
577
|
+
def checkpoint(*, load_policy: str = "fresh", 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]]]:
|
714
578
|
"""
|
715
|
-
|
579
|
+
Enables checkpointing for a step.
|
580
|
+
|
716
581
|
|
717
582
|
Parameters
|
718
583
|
----------
|
719
|
-
|
720
|
-
|
584
|
+
load_policy : str, default: "fresh"
|
585
|
+
The policy for loading the checkpoint. The following policies are supported:
|
586
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
587
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
588
|
+
will be loaded at the start of the task.
|
589
|
+
- "none": Do not load any checkpoint
|
590
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
591
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
592
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
593
|
+
created within the task will be loaded when the task is retries execution on failure.
|
594
|
+
|
595
|
+
temp_dir_root : str, default: None
|
596
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
597
|
+
|
598
|
+
|
599
|
+
|
721
600
|
"""
|
722
601
|
...
|
723
602
|
|
724
603
|
@typing.overload
|
725
|
-
def
|
604
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
726
605
|
...
|
727
606
|
|
728
607
|
@typing.overload
|
729
|
-
def
|
608
|
+
def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
730
609
|
...
|
731
610
|
|
732
|
-
def
|
611
|
+
def checkpoint(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, load_policy: str = "fresh", temp_dir_root: str = None):
|
733
612
|
"""
|
734
|
-
|
613
|
+
Enables checkpointing for a step.
|
614
|
+
|
735
615
|
|
736
616
|
Parameters
|
737
617
|
----------
|
738
|
-
|
739
|
-
|
618
|
+
load_policy : str, default: "fresh"
|
619
|
+
The policy for loading the checkpoint. The following policies are supported:
|
620
|
+
- "eager": Loads the the latest available checkpoint within the namespace.
|
621
|
+
With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
|
622
|
+
will be loaded at the start of the task.
|
623
|
+
- "none": Do not load any checkpoint
|
624
|
+
- "fresh": Loads the lastest checkpoint created within the running Task.
|
625
|
+
This mode helps loading checkpoints across various retry attempts of the same task.
|
626
|
+
With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
|
627
|
+
created within the task will be loaded when the task is retries execution on failure.
|
628
|
+
|
629
|
+
temp_dir_root : str, default: None
|
630
|
+
The root directory under which `current.checkpoint.directory` will be created.
|
631
|
+
|
632
|
+
|
633
|
+
|
740
634
|
"""
|
741
635
|
...
|
742
636
|
|
743
637
|
@typing.overload
|
744
|
-
def
|
638
|
+
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]]]:
|
745
639
|
"""
|
746
|
-
|
747
|
-
to a step needs to be retried.
|
748
|
-
|
749
|
-
This decorator is useful for handling transient errors, such as networking issues.
|
750
|
-
If your task contains operations that can't be retried safely, e.g. database updates,
|
751
|
-
it is advisable to annotate it with `@retry(times=0)`.
|
640
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
752
641
|
|
753
|
-
|
754
|
-
decorator will execute a no-op task after all retries have been exhausted,
|
755
|
-
ensuring that the flow execution can continue.
|
642
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
756
643
|
|
757
644
|
Parameters
|
758
645
|
----------
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
646
|
+
type : str, default 'default'
|
647
|
+
Card type.
|
648
|
+
id : str, optional, default None
|
649
|
+
If multiple cards are present, use this id to identify this card.
|
650
|
+
options : Dict[str, Any], default {}
|
651
|
+
Options passed to the card. The contents depend on the card type.
|
652
|
+
timeout : int, default 45
|
653
|
+
Interrupt reporting if it takes more than this many seconds.
|
654
|
+
|
655
|
+
|
656
|
+
"""
|
657
|
+
...
|
658
|
+
|
659
|
+
@typing.overload
|
660
|
+
def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
661
|
+
...
|
662
|
+
|
663
|
+
@typing.overload
|
664
|
+
def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
665
|
+
...
|
666
|
+
|
667
|
+
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):
|
668
|
+
"""
|
669
|
+
Creates a human-readable report, a Metaflow Card, after this step completes.
|
670
|
+
|
671
|
+
Note that you may add multiple `@card` decorators in a step with different parameters.
|
672
|
+
|
673
|
+
Parameters
|
674
|
+
----------
|
675
|
+
type : str, default 'default'
|
676
|
+
Card type.
|
677
|
+
id : str, optional, default None
|
678
|
+
If multiple cards are present, use this id to identify this card.
|
679
|
+
options : Dict[str, Any], default {}
|
680
|
+
Options passed to the card. The contents depend on the card type.
|
681
|
+
timeout : int, default 45
|
682
|
+
Interrupt reporting if it takes more than this many seconds.
|
683
|
+
|
684
|
+
|
685
|
+
"""
|
686
|
+
...
|
687
|
+
|
688
|
+
@typing.overload
|
689
|
+
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]]]:
|
690
|
+
"""
|
691
|
+
Specifies the number of times the task corresponding
|
692
|
+
to a step needs to be retried.
|
693
|
+
|
694
|
+
This decorator is useful for handling transient errors, such as networking issues.
|
695
|
+
If your task contains operations that can't be retried safely, e.g. database updates,
|
696
|
+
it is advisable to annotate it with `@retry(times=0)`.
|
697
|
+
|
698
|
+
This can be used in conjunction with the `@catch` decorator. The `@catch`
|
699
|
+
decorator will execute a no-op task after all retries have been exhausted,
|
700
|
+
ensuring that the flow execution can continue.
|
701
|
+
|
702
|
+
Parameters
|
703
|
+
----------
|
704
|
+
times : int, default 3
|
705
|
+
Number of times to retry this task.
|
706
|
+
minutes_between_retries : int, default 2
|
707
|
+
Number of minutes between retries.
|
763
708
|
"""
|
764
709
|
...
|
765
710
|
|
@@ -794,135 +739,101 @@ def retry(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
|
|
794
739
|
...
|
795
740
|
|
796
741
|
@typing.overload
|
797
|
-
def
|
742
|
+
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]]]:
|
798
743
|
"""
|
799
|
-
|
800
|
-
|
744
|
+
Specifies environment variables to be set prior to the execution of a step.
|
745
|
+
|
746
|
+
Parameters
|
747
|
+
----------
|
748
|
+
vars : Dict[str, str], default {}
|
749
|
+
Dictionary of environment variables to set.
|
801
750
|
"""
|
802
751
|
...
|
803
752
|
|
804
753
|
@typing.overload
|
805
|
-
def
|
754
|
+
def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
806
755
|
...
|
807
756
|
|
808
|
-
|
757
|
+
@typing.overload
|
758
|
+
def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
759
|
+
...
|
760
|
+
|
761
|
+
def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
|
809
762
|
"""
|
810
|
-
|
811
|
-
|
763
|
+
Specifies environment variables to be set prior to the execution of a step.
|
764
|
+
|
765
|
+
Parameters
|
766
|
+
----------
|
767
|
+
vars : Dict[str, str], default {}
|
768
|
+
Dictionary of environment variables to set.
|
812
769
|
"""
|
813
770
|
...
|
814
771
|
|
815
772
|
@typing.overload
|
816
|
-
def
|
773
|
+
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]]]:
|
817
774
|
"""
|
818
|
-
Specifies the
|
775
|
+
Specifies the PyPI packages for the step.
|
819
776
|
|
820
777
|
Information in this decorator will augment any
|
821
|
-
attributes set in the `@
|
822
|
-
you can use `@
|
823
|
-
steps and use `@
|
778
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
779
|
+
you can use `@pypi_base` to set packages required by all
|
780
|
+
steps and use `@pypi` to specify step-specific overrides.
|
824
781
|
|
825
782
|
Parameters
|
826
783
|
----------
|
827
|
-
packages : Dict[str, str], default {}
|
784
|
+
packages : Dict[str, str], default: {}
|
828
785
|
Packages to use for this step. The key is the name of the package
|
829
786
|
and the value is the version to use.
|
830
|
-
|
831
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
832
|
-
python : str, optional, default None
|
787
|
+
python : str, optional, default: None
|
833
788
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
834
789
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
835
|
-
disabled : bool, default False
|
836
|
-
If set to True, disables @conda.
|
837
790
|
"""
|
838
791
|
...
|
839
792
|
|
840
793
|
@typing.overload
|
841
|
-
def
|
794
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
842
795
|
...
|
843
796
|
|
844
797
|
@typing.overload
|
845
|
-
def
|
798
|
+
def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
846
799
|
...
|
847
800
|
|
848
|
-
def
|
801
|
+
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):
|
849
802
|
"""
|
850
|
-
Specifies the
|
803
|
+
Specifies the PyPI packages for the step.
|
851
804
|
|
852
805
|
Information in this decorator will augment any
|
853
|
-
attributes set in the `@
|
854
|
-
you can use `@
|
855
|
-
steps and use `@
|
806
|
+
attributes set in the `@pyi_base` flow-level decorator. Hence,
|
807
|
+
you can use `@pypi_base` to set packages required by all
|
808
|
+
steps and use `@pypi` to specify step-specific overrides.
|
856
809
|
|
857
810
|
Parameters
|
858
811
|
----------
|
859
|
-
packages : Dict[str, str], default {}
|
812
|
+
packages : Dict[str, str], default: {}
|
860
813
|
Packages to use for this step. The key is the name of the package
|
861
814
|
and the value is the version to use.
|
862
|
-
|
863
|
-
Supported for backward compatibility. When used with packages, packages will take precedence.
|
864
|
-
python : str, optional, default None
|
815
|
+
python : str, optional, default: None
|
865
816
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
866
817
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
867
|
-
disabled : bool, default False
|
868
|
-
If set to True, disables @conda.
|
869
818
|
"""
|
870
819
|
...
|
871
820
|
|
872
821
|
@typing.overload
|
873
|
-
def
|
822
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
874
823
|
"""
|
875
|
-
|
876
|
-
|
877
|
-
This decorator is useful if this step may hang indefinitely.
|
878
|
-
|
879
|
-
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
880
|
-
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
881
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
882
|
-
|
883
|
-
Note that all the values specified in parameters are added together so if you specify
|
884
|
-
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
885
|
-
|
886
|
-
Parameters
|
887
|
-
----------
|
888
|
-
seconds : int, default 0
|
889
|
-
Number of seconds to wait prior to timing out.
|
890
|
-
minutes : int, default 0
|
891
|
-
Number of minutes to wait prior to timing out.
|
892
|
-
hours : int, default 0
|
893
|
-
Number of hours to wait prior to timing out.
|
824
|
+
Decorator prototype for all step decorators. This function gets specialized
|
825
|
+
and imported for all decorators types by _import_plugin_decorators().
|
894
826
|
"""
|
895
827
|
...
|
896
828
|
|
897
829
|
@typing.overload
|
898
|
-
def
|
899
|
-
...
|
900
|
-
|
901
|
-
@typing.overload
|
902
|
-
def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
830
|
+
def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
903
831
|
...
|
904
832
|
|
905
|
-
def
|
833
|
+
def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
906
834
|
"""
|
907
|
-
|
908
|
-
|
909
|
-
This decorator is useful if this step may hang indefinitely.
|
910
|
-
|
911
|
-
This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
|
912
|
-
A timeout is considered to be an exception thrown by the step. It will cause the step to be
|
913
|
-
retried if needed and the exception will be caught by the `@catch` decorator, if present.
|
914
|
-
|
915
|
-
Note that all the values specified in parameters are added together so if you specify
|
916
|
-
60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
|
917
|
-
|
918
|
-
Parameters
|
919
|
-
----------
|
920
|
-
seconds : int, default 0
|
921
|
-
Number of seconds to wait prior to timing out.
|
922
|
-
minutes : int, default 0
|
923
|
-
Number of minutes to wait prior to timing out.
|
924
|
-
hours : int, default 0
|
925
|
-
Number of hours to wait prior to timing out.
|
835
|
+
Decorator prototype for all step decorators. This function gets specialized
|
836
|
+
and imported for all decorators types by _import_plugin_decorators().
|
926
837
|
"""
|
927
838
|
...
|
928
839
|
|
@@ -993,71 +904,262 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
|
|
993
904
|
...
|
994
905
|
|
995
906
|
@typing.overload
|
996
|
-
def
|
907
|
+
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]]]:
|
997
908
|
"""
|
998
|
-
Specifies the
|
909
|
+
Specifies the Conda environment for the step.
|
910
|
+
|
911
|
+
Information in this decorator will augment any
|
912
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
913
|
+
you can use `@conda_base` to set packages required by all
|
914
|
+
steps and use `@conda` to specify step-specific overrides.
|
999
915
|
|
1000
|
-
Use `@pypi_base` to set common packages required by all
|
1001
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1002
916
|
Parameters
|
1003
917
|
----------
|
1004
|
-
packages : Dict[str, str], default
|
1005
|
-
Packages to use for this
|
918
|
+
packages : Dict[str, str], default {}
|
919
|
+
Packages to use for this step. The key is the name of the package
|
1006
920
|
and the value is the version to use.
|
1007
|
-
|
921
|
+
libraries : Dict[str, str], default {}
|
922
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
923
|
+
python : str, optional, default None
|
1008
924
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1009
925
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
926
|
+
disabled : bool, default False
|
927
|
+
If set to True, disables @conda.
|
1010
928
|
"""
|
1011
929
|
...
|
1012
930
|
|
1013
931
|
@typing.overload
|
1014
|
-
def
|
932
|
+
def conda(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1015
933
|
...
|
1016
934
|
|
1017
|
-
|
935
|
+
@typing.overload
|
936
|
+
def conda(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
937
|
+
...
|
938
|
+
|
939
|
+
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):
|
1018
940
|
"""
|
1019
|
-
Specifies the
|
941
|
+
Specifies the Conda environment for the step.
|
942
|
+
|
943
|
+
Information in this decorator will augment any
|
944
|
+
attributes set in the `@conda_base` flow-level decorator. Hence,
|
945
|
+
you can use `@conda_base` to set packages required by all
|
946
|
+
steps and use `@conda` to specify step-specific overrides.
|
1020
947
|
|
1021
|
-
Use `@pypi_base` to set common packages required by all
|
1022
|
-
steps and use `@pypi` to specify step-specific overrides.
|
1023
948
|
Parameters
|
1024
949
|
----------
|
1025
|
-
packages : Dict[str, str], default
|
1026
|
-
Packages to use for this
|
950
|
+
packages : Dict[str, str], default {}
|
951
|
+
Packages to use for this step. The key is the name of the package
|
1027
952
|
and the value is the version to use.
|
1028
|
-
|
953
|
+
libraries : Dict[str, str], default {}
|
954
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
955
|
+
python : str, optional, default None
|
1029
956
|
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1030
957
|
that the version used will correspond to the version of the Python interpreter used to start the run.
|
958
|
+
disabled : bool, default False
|
959
|
+
If set to True, disables @conda.
|
1031
960
|
"""
|
1032
961
|
...
|
1033
962
|
|
1034
963
|
@typing.overload
|
1035
|
-
def
|
964
|
+
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]]]:
|
1036
965
|
"""
|
1037
|
-
Specifies the
|
1038
|
-
|
966
|
+
Specifies the resources needed when executing this step.
|
967
|
+
|
968
|
+
Use `@resources` to specify the resource requirements
|
969
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
970
|
+
|
971
|
+
You can choose the compute layer on the command line by executing e.g.
|
972
|
+
```
|
973
|
+
python myflow.py run --with batch
|
974
|
+
```
|
975
|
+
or
|
976
|
+
```
|
977
|
+
python myflow.py run --with kubernetes
|
978
|
+
```
|
979
|
+
which executes the flow on the desired system using the
|
980
|
+
requirements specified in `@resources`.
|
1039
981
|
|
1040
982
|
Parameters
|
1041
983
|
----------
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
984
|
+
cpu : int, default 1
|
985
|
+
Number of CPUs required for this step.
|
986
|
+
gpu : int, default 0
|
987
|
+
Number of GPUs required for this step.
|
988
|
+
disk : int, optional, default None
|
989
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
990
|
+
memory : int, default 4096
|
991
|
+
Memory size (in MB) required for this step.
|
992
|
+
shared_memory : int, optional, default None
|
993
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
994
|
+
This parameter maps to the `--shm-size` option in Docker.
|
995
|
+
"""
|
996
|
+
...
|
997
|
+
|
998
|
+
@typing.overload
|
999
|
+
def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1000
|
+
...
|
1001
|
+
|
1002
|
+
@typing.overload
|
1003
|
+
def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1004
|
+
...
|
1005
|
+
|
1006
|
+
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):
|
1007
|
+
"""
|
1008
|
+
Specifies the resources needed when executing this step.
|
1009
|
+
|
1010
|
+
Use `@resources` to specify the resource requirements
|
1011
|
+
independently of the specific compute layer (`@batch`, `@kubernetes`).
|
1012
|
+
|
1013
|
+
You can choose the compute layer on the command line by executing e.g.
|
1014
|
+
```
|
1015
|
+
python myflow.py run --with batch
|
1016
|
+
```
|
1017
|
+
or
|
1018
|
+
```
|
1019
|
+
python myflow.py run --with kubernetes
|
1020
|
+
```
|
1021
|
+
which executes the flow on the desired system using the
|
1022
|
+
requirements specified in `@resources`.
|
1023
|
+
|
1024
|
+
Parameters
|
1025
|
+
----------
|
1026
|
+
cpu : int, default 1
|
1027
|
+
Number of CPUs required for this step.
|
1028
|
+
gpu : int, default 0
|
1029
|
+
Number of GPUs required for this step.
|
1030
|
+
disk : int, optional, default None
|
1031
|
+
Disk size (in MB) required for this step. Only applies on Kubernetes.
|
1032
|
+
memory : int, default 4096
|
1033
|
+
Memory size (in MB) required for this step.
|
1034
|
+
shared_memory : int, optional, default None
|
1035
|
+
The value for the size (in MiB) of the /dev/shm volume for this step.
|
1036
|
+
This parameter maps to the `--shm-size` option in Docker.
|
1037
|
+
"""
|
1038
|
+
...
|
1039
|
+
|
1040
|
+
@typing.overload
|
1041
|
+
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]]]:
|
1042
|
+
"""
|
1043
|
+
Enables loading / saving of models within a step.
|
1044
|
+
|
1045
|
+
|
1046
|
+
Parameters
|
1047
|
+
----------
|
1048
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
1049
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
1050
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
1051
|
+
- `current.checkpoint`
|
1052
|
+
- `current.model`
|
1053
|
+
- `current.huggingface_hub`
|
1054
|
+
|
1055
|
+
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
|
1056
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
1057
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
1058
|
+
|
1059
|
+
temp_dir_root : str, default: None
|
1060
|
+
The root directory under which `current.model.loaded` will store loaded models
|
1061
|
+
|
1062
|
+
|
1063
|
+
|
1064
|
+
"""
|
1065
|
+
...
|
1066
|
+
|
1067
|
+
@typing.overload
|
1068
|
+
def model(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1069
|
+
...
|
1070
|
+
|
1071
|
+
@typing.overload
|
1072
|
+
def model(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1073
|
+
...
|
1074
|
+
|
1075
|
+
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):
|
1076
|
+
"""
|
1077
|
+
Enables loading / saving of models within a step.
|
1078
|
+
|
1079
|
+
|
1080
|
+
Parameters
|
1081
|
+
----------
|
1082
|
+
load : Union[List[str],str,List[Tuple[str,Union[str,None]]]], default: None
|
1083
|
+
Artifact name/s referencing the models/checkpoints to load. Artifact names refer to the names of the instance variables set to `self`.
|
1084
|
+
These artifact names give to `load` be reference objects or reference `key` string's from objects created by:
|
1085
|
+
- `current.checkpoint`
|
1086
|
+
- `current.model`
|
1087
|
+
- `current.huggingface_hub`
|
1088
|
+
|
1089
|
+
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
|
1090
|
+
the local filesystem. If the second element is None, the artifact will be unpacked in the current working directory.
|
1091
|
+
If a string is provided, then the artifact corresponding to that name will be loaded in the current working directory.
|
1092
|
+
|
1093
|
+
temp_dir_root : str, default: None
|
1094
|
+
The root directory under which `current.model.loaded` will store loaded models
|
1095
|
+
|
1096
|
+
|
1097
|
+
|
1098
|
+
"""
|
1099
|
+
...
|
1100
|
+
|
1101
|
+
@typing.overload
|
1102
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
|
1103
|
+
"""
|
1104
|
+
Internal decorator to support Fast bakery
|
1105
|
+
"""
|
1106
|
+
...
|
1107
|
+
|
1108
|
+
@typing.overload
|
1109
|
+
def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
|
1110
|
+
...
|
1111
|
+
|
1112
|
+
def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
|
1113
|
+
"""
|
1114
|
+
Internal decorator to support Fast bakery
|
1115
|
+
"""
|
1116
|
+
...
|
1117
|
+
|
1118
|
+
def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1119
|
+
"""
|
1120
|
+
Specifies what flows belong to the same project.
|
1121
|
+
|
1122
|
+
A project-specific namespace is created for all flows that
|
1123
|
+
use the same `@project(name)`.
|
1124
|
+
|
1125
|
+
Parameters
|
1126
|
+
----------
|
1127
|
+
name : str
|
1128
|
+
Project name. Make sure that the name is unique amongst all
|
1129
|
+
projects that use the same production scheduler. The name may
|
1130
|
+
contain only lowercase alphanumeric characters and underscores.
|
1131
|
+
|
1132
|
+
|
1133
|
+
"""
|
1134
|
+
...
|
1135
|
+
|
1136
|
+
@typing.overload
|
1137
|
+
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]]:
|
1138
|
+
"""
|
1139
|
+
Specifies the times when the flow should be run when running on a
|
1140
|
+
production scheduler.
|
1141
|
+
|
1142
|
+
Parameters
|
1143
|
+
----------
|
1144
|
+
hourly : bool, default False
|
1145
|
+
Run the workflow hourly.
|
1146
|
+
daily : bool, default True
|
1147
|
+
Run the workflow daily.
|
1148
|
+
weekly : bool, default False
|
1149
|
+
Run the workflow weekly.
|
1150
|
+
cron : str, optional, default None
|
1151
|
+
Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
|
1152
|
+
specified by this expression.
|
1153
|
+
timezone : str, optional, default None
|
1154
|
+
Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
|
1155
|
+
which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
|
1156
|
+
"""
|
1157
|
+
...
|
1158
|
+
|
1159
|
+
@typing.overload
|
1160
|
+
def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1161
|
+
...
|
1162
|
+
|
1061
1163
|
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):
|
1062
1164
|
"""
|
1063
1165
|
Specifies the times when the flow should be run when running on a
|
@@ -1081,58 +1183,115 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
|
|
1081
1183
|
...
|
1082
1184
|
|
1083
1185
|
@typing.overload
|
1084
|
-
def
|
1186
|
+
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]]:
|
1085
1187
|
"""
|
1086
|
-
Specifies the
|
1188
|
+
Specifies the flow(s) that this flow depends on.
|
1087
1189
|
|
1088
|
-
|
1089
|
-
|
1190
|
+
```
|
1191
|
+
@trigger_on_finish(flow='FooFlow')
|
1192
|
+
```
|
1193
|
+
or
|
1194
|
+
```
|
1195
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1196
|
+
```
|
1197
|
+
This decorator respects the @project decorator and triggers the flow
|
1198
|
+
when upstream runs within the same namespace complete successfully
|
1199
|
+
|
1200
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1201
|
+
by specifying the fully qualified project_flow_name.
|
1202
|
+
```
|
1203
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1204
|
+
```
|
1205
|
+
or
|
1206
|
+
```
|
1207
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1208
|
+
```
|
1209
|
+
|
1210
|
+
You can also specify just the project or project branch (other values will be
|
1211
|
+
inferred from the current project or project branch):
|
1212
|
+
```
|
1213
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1214
|
+
```
|
1215
|
+
|
1216
|
+
Note that `branch` is typically one of:
|
1217
|
+
- `prod`
|
1218
|
+
- `user.bob`
|
1219
|
+
- `test.my_experiment`
|
1220
|
+
- `prod.staging`
|
1090
1221
|
|
1091
1222
|
Parameters
|
1092
1223
|
----------
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
disabled : bool, default False
|
1102
|
-
If set to True, disables Conda.
|
1224
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1225
|
+
Upstream flow dependency for this flow.
|
1226
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1227
|
+
Upstream flow dependencies for this flow.
|
1228
|
+
options : Dict[str, Any], default {}
|
1229
|
+
Backend-specific configuration for tuning eventing behavior.
|
1230
|
+
|
1231
|
+
|
1103
1232
|
"""
|
1104
1233
|
...
|
1105
1234
|
|
1106
1235
|
@typing.overload
|
1107
|
-
def
|
1236
|
+
def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1108
1237
|
...
|
1109
1238
|
|
1110
|
-
def
|
1239
|
+
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] = {}):
|
1111
1240
|
"""
|
1112
|
-
Specifies the
|
1241
|
+
Specifies the flow(s) that this flow depends on.
|
1113
1242
|
|
1114
|
-
|
1115
|
-
|
1243
|
+
```
|
1244
|
+
@trigger_on_finish(flow='FooFlow')
|
1245
|
+
```
|
1246
|
+
or
|
1247
|
+
```
|
1248
|
+
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1249
|
+
```
|
1250
|
+
This decorator respects the @project decorator and triggers the flow
|
1251
|
+
when upstream runs within the same namespace complete successfully
|
1252
|
+
|
1253
|
+
Additionally, you can specify project aware upstream flow dependencies
|
1254
|
+
by specifying the fully qualified project_flow_name.
|
1255
|
+
```
|
1256
|
+
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1257
|
+
```
|
1258
|
+
or
|
1259
|
+
```
|
1260
|
+
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1261
|
+
```
|
1262
|
+
|
1263
|
+
You can also specify just the project or project branch (other values will be
|
1264
|
+
inferred from the current project or project branch):
|
1265
|
+
```
|
1266
|
+
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1267
|
+
```
|
1268
|
+
|
1269
|
+
Note that `branch` is typically one of:
|
1270
|
+
- `prod`
|
1271
|
+
- `user.bob`
|
1272
|
+
- `test.my_experiment`
|
1273
|
+
- `prod.staging`
|
1116
1274
|
|
1117
1275
|
Parameters
|
1118
1276
|
----------
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
disabled : bool, default False
|
1128
|
-
If set to True, disables Conda.
|
1277
|
+
flow : Union[str, Dict[str, str]], optional, default None
|
1278
|
+
Upstream flow dependency for this flow.
|
1279
|
+
flows : List[Union[str, Dict[str, str]]], default []
|
1280
|
+
Upstream flow dependencies for this flow.
|
1281
|
+
options : Dict[str, Any], default {}
|
1282
|
+
Backend-specific configuration for tuning eventing behavior.
|
1283
|
+
|
1284
|
+
|
1129
1285
|
"""
|
1130
1286
|
...
|
1131
1287
|
|
1132
|
-
def
|
1288
|
+
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]]:
|
1133
1289
|
"""
|
1134
|
-
The `@
|
1135
|
-
This decorator only works when a flow is scheduled on Airflow
|
1290
|
+
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)
|
1291
|
+
before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
|
1292
|
+
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1293
|
+
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1294
|
+
starts only after all sensors finish.
|
1136
1295
|
|
1137
1296
|
Parameters
|
1138
1297
|
----------
|
@@ -1153,52 +1312,18 @@ def airflow_external_task_sensor(*, timeout: int, poke_interval: int, mode: str,
|
|
1153
1312
|
Name of the sensor on Airflow
|
1154
1313
|
description : str
|
1155
1314
|
Description of sensor in the Airflow UI
|
1156
|
-
|
1157
|
-
The
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
check_existence: bool
|
1169
|
-
Set to True to check if the external task exists or check if
|
1170
|
-
the DAG to wait for exists. (Default: True)
|
1171
|
-
"""
|
1172
|
-
...
|
1173
|
-
|
1174
|
-
def nim(*, models: "list[NIM]", backend: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1175
|
-
"""
|
1176
|
-
This decorator is used to run NIM containers in Metaflow tasks as sidecars.
|
1177
|
-
|
1178
|
-
User code call
|
1179
|
-
-----------
|
1180
|
-
@nim(
|
1181
|
-
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
1182
|
-
backend='managed'
|
1183
|
-
)
|
1184
|
-
|
1185
|
-
Valid backend options
|
1186
|
-
---------------------
|
1187
|
-
- 'managed': Outerbounds selects a compute provider based on the model.
|
1188
|
-
- 🚧 'dataplane': Run in your account.
|
1189
|
-
|
1190
|
-
Valid model options
|
1191
|
-
----------------
|
1192
|
-
- 'meta/llama3-8b-instruct': 8B parameter model
|
1193
|
-
- 'meta/llama3-70b-instruct': 70B parameter model
|
1194
|
-
- Upon request, any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
|
1195
|
-
|
1196
|
-
Parameters
|
1197
|
-
----------
|
1198
|
-
models: list[NIM]
|
1199
|
-
List of NIM containers running models in sidecars.
|
1200
|
-
backend: str
|
1201
|
-
Compute provider to run the NIM container.
|
1315
|
+
bucket_key : Union[str, List[str]]
|
1316
|
+
The key(s) being waited on. Supports full s3:// style url or relative path from root level.
|
1317
|
+
When it's specified as a full s3:// url, please leave `bucket_name` as None
|
1318
|
+
bucket_name : str
|
1319
|
+
Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
|
1320
|
+
When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
|
1321
|
+
wildcard_match : bool
|
1322
|
+
whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
|
1323
|
+
aws_conn_id : str
|
1324
|
+
a reference to the s3 connection on Airflow. (Default: None)
|
1325
|
+
verify : bool
|
1326
|
+
Whether or not to verify SSL certificates for S3 connection. (Default: None)
|
1202
1327
|
"""
|
1203
1328
|
...
|
1204
1329
|
|
@@ -1297,31 +1422,59 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
|
|
1297
1422
|
"""
|
1298
1423
|
...
|
1299
1424
|
|
1300
|
-
|
1425
|
+
@typing.overload
|
1426
|
+
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]]:
|
1301
1427
|
"""
|
1302
|
-
Specifies
|
1428
|
+
Specifies the Conda environment for all steps of the flow.
|
1303
1429
|
|
1304
|
-
|
1305
|
-
use
|
1430
|
+
Use `@conda_base` to set common libraries required by all
|
1431
|
+
steps and use `@conda` to specify step-specific additions.
|
1306
1432
|
|
1307
1433
|
Parameters
|
1308
1434
|
----------
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1435
|
+
packages : Dict[str, str], default {}
|
1436
|
+
Packages to use for this flow. The key is the name of the package
|
1437
|
+
and the value is the version to use.
|
1438
|
+
libraries : Dict[str, str], default {}
|
1439
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1440
|
+
python : str, optional, default None
|
1441
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1442
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1443
|
+
disabled : bool, default False
|
1444
|
+
If set to True, disables Conda.
|
1445
|
+
"""
|
1446
|
+
...
|
1447
|
+
|
1448
|
+
@typing.overload
|
1449
|
+
def conda_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1450
|
+
...
|
1451
|
+
|
1452
|
+
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):
|
1453
|
+
"""
|
1454
|
+
Specifies the Conda environment for all steps of the flow.
|
1313
1455
|
|
1456
|
+
Use `@conda_base` to set common libraries required by all
|
1457
|
+
steps and use `@conda` to specify step-specific additions.
|
1314
1458
|
|
1459
|
+
Parameters
|
1460
|
+
----------
|
1461
|
+
packages : Dict[str, str], default {}
|
1462
|
+
Packages to use for this flow. The key is the name of the package
|
1463
|
+
and the value is the version to use.
|
1464
|
+
libraries : Dict[str, str], default {}
|
1465
|
+
Supported for backward compatibility. When used with packages, packages will take precedence.
|
1466
|
+
python : str, optional, default None
|
1467
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1468
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1469
|
+
disabled : bool, default False
|
1470
|
+
If set to True, disables Conda.
|
1315
1471
|
"""
|
1316
1472
|
...
|
1317
1473
|
|
1318
|
-
def
|
1474
|
+
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]]:
|
1319
1475
|
"""
|
1320
|
-
The `@
|
1321
|
-
|
1322
|
-
and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
|
1323
|
-
added as a flow decorators. Adding more than one decorator will ensure that `start` step
|
1324
|
-
starts only after all sensors finish.
|
1476
|
+
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.
|
1477
|
+
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.
|
1325
1478
|
|
1326
1479
|
Parameters
|
1327
1480
|
----------
|
@@ -1342,121 +1495,91 @@ def airflow_s3_key_sensor(*, timeout: int, poke_interval: int, mode: str, expone
|
|
1342
1495
|
Name of the sensor on Airflow
|
1343
1496
|
description : str
|
1344
1497
|
Description of sensor in the Airflow UI
|
1345
|
-
|
1346
|
-
The
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1498
|
+
external_dag_id : str
|
1499
|
+
The dag_id that contains the task you want to wait for.
|
1500
|
+
external_task_ids : List[str]
|
1501
|
+
The list of task_ids that you want to wait for.
|
1502
|
+
If None (default value) the sensor waits for the DAG. (Default: None)
|
1503
|
+
allowed_states : List[str]
|
1504
|
+
Iterable of allowed states, (Default: ['success'])
|
1505
|
+
failed_states : List[str]
|
1506
|
+
Iterable of failed or dis-allowed states. (Default: None)
|
1507
|
+
execution_delta : datetime.timedelta
|
1508
|
+
time difference with the previous execution to look at,
|
1509
|
+
the default is the same logical date as the current task or DAG. (Default: None)
|
1510
|
+
check_existence: bool
|
1511
|
+
Set to True to check if the external task exists or check if
|
1512
|
+
the DAG to wait for exists. (Default: True)
|
1357
1513
|
"""
|
1358
1514
|
...
|
1359
1515
|
|
1360
|
-
|
1361
|
-
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]]:
|
1516
|
+
def nim(*, models: "list[NIM]", backend: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1362
1517
|
"""
|
1363
|
-
|
1364
|
-
|
1365
|
-
```
|
1366
|
-
@trigger_on_finish(flow='FooFlow')
|
1367
|
-
```
|
1368
|
-
or
|
1369
|
-
```
|
1370
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1371
|
-
```
|
1372
|
-
This decorator respects the @project decorator and triggers the flow
|
1373
|
-
when upstream runs within the same namespace complete successfully
|
1518
|
+
This decorator is used to run NIM containers in Metaflow tasks as sidecars.
|
1374
1519
|
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
```
|
1382
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1383
|
-
```
|
1520
|
+
User code call
|
1521
|
+
-----------
|
1522
|
+
@nim(
|
1523
|
+
models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
|
1524
|
+
backend='managed'
|
1525
|
+
)
|
1384
1526
|
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
```
|
1527
|
+
Valid backend options
|
1528
|
+
---------------------
|
1529
|
+
- 'managed': Outerbounds selects a compute provider based on the model.
|
1530
|
+
- 🚧 'dataplane': Run in your account.
|
1390
1531
|
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1532
|
+
Valid model options
|
1533
|
+
----------------
|
1534
|
+
- 'meta/llama3-8b-instruct': 8B parameter model
|
1535
|
+
- 'meta/llama3-70b-instruct': 70B parameter model
|
1536
|
+
- Upon request, any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
|
1396
1537
|
|
1397
1538
|
Parameters
|
1398
1539
|
----------
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1540
|
+
models: list[NIM]
|
1541
|
+
List of NIM containers running models in sidecars.
|
1542
|
+
backend: str
|
1543
|
+
Compute provider to run the NIM container.
|
1544
|
+
"""
|
1545
|
+
...
|
1546
|
+
|
1547
|
+
@typing.overload
|
1548
|
+
def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
|
1549
|
+
"""
|
1550
|
+
Specifies the PyPI packages for all steps of the flow.
|
1406
1551
|
|
1552
|
+
Use `@pypi_base` to set common packages required by all
|
1553
|
+
steps and use `@pypi` to specify step-specific overrides.
|
1554
|
+
Parameters
|
1555
|
+
----------
|
1556
|
+
packages : Dict[str, str], default: {}
|
1557
|
+
Packages to use for this flow. The key is the name of the package
|
1558
|
+
and the value is the version to use.
|
1559
|
+
python : str, optional, default: None
|
1560
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1561
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1407
1562
|
"""
|
1408
1563
|
...
|
1409
1564
|
|
1410
1565
|
@typing.overload
|
1411
|
-
def
|
1566
|
+
def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
|
1412
1567
|
...
|
1413
1568
|
|
1414
|
-
def
|
1569
|
+
def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
|
1415
1570
|
"""
|
1416
|
-
Specifies the
|
1417
|
-
|
1418
|
-
```
|
1419
|
-
@trigger_on_finish(flow='FooFlow')
|
1420
|
-
```
|
1421
|
-
or
|
1422
|
-
```
|
1423
|
-
@trigger_on_finish(flows=['FooFlow', 'BarFlow'])
|
1424
|
-
```
|
1425
|
-
This decorator respects the @project decorator and triggers the flow
|
1426
|
-
when upstream runs within the same namespace complete successfully
|
1427
|
-
|
1428
|
-
Additionally, you can specify project aware upstream flow dependencies
|
1429
|
-
by specifying the fully qualified project_flow_name.
|
1430
|
-
```
|
1431
|
-
@trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
|
1432
|
-
```
|
1433
|
-
or
|
1434
|
-
```
|
1435
|
-
@trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
|
1436
|
-
```
|
1437
|
-
|
1438
|
-
You can also specify just the project or project branch (other values will be
|
1439
|
-
inferred from the current project or project branch):
|
1440
|
-
```
|
1441
|
-
@trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
|
1442
|
-
```
|
1443
|
-
|
1444
|
-
Note that `branch` is typically one of:
|
1445
|
-
- `prod`
|
1446
|
-
- `user.bob`
|
1447
|
-
- `test.my_experiment`
|
1448
|
-
- `prod.staging`
|
1571
|
+
Specifies the PyPI packages for all steps of the flow.
|
1449
1572
|
|
1573
|
+
Use `@pypi_base` to set common packages required by all
|
1574
|
+
steps and use `@pypi` to specify step-specific overrides.
|
1450
1575
|
Parameters
|
1451
1576
|
----------
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1577
|
+
packages : Dict[str, str], default: {}
|
1578
|
+
Packages to use for this flow. The key is the name of the package
|
1579
|
+
and the value is the version to use.
|
1580
|
+
python : str, optional, default: None
|
1581
|
+
Version of Python to use, e.g. '3.7.4'. A default value of None implies
|
1582
|
+
that the version used will correspond to the version of the Python interpreter used to start the run.
|
1460
1583
|
"""
|
1461
1584
|
...
|
1462
1585
|
|
@@ -2640,6 +2763,79 @@ class NBDeployer(object, metaclass=type):
|
|
2640
2763
|
|
2641
2764
|
pkg_name: str
|
2642
2765
|
|
2766
|
+
class Checkpoint(object, metaclass=type):
|
2767
|
+
def __init__(self, temp_dir_root = None, init_dir = False):
|
2768
|
+
...
|
2769
|
+
@property
|
2770
|
+
def directory(self):
|
2771
|
+
...
|
2772
|
+
def save(self, path = None, metadata = None, latest = True, name = "mfchckpt"):
|
2773
|
+
"""
|
2774
|
+
saves the checkpoint to the datastore (resemble's a create op)
|
2775
|
+
|
2776
|
+
Parameters
|
2777
|
+
----------
|
2778
|
+
|
2779
|
+
- `path` (str or os.PathLike):
|
2780
|
+
- path to directory
|
2781
|
+
- path to file
|
2782
|
+
- `name`:
|
2783
|
+
- name of the checkpoint
|
2784
|
+
- `metadata`:
|
2785
|
+
- metadata of the checkpoint
|
2786
|
+
"""
|
2787
|
+
...
|
2788
|
+
def __enter__(self):
|
2789
|
+
...
|
2790
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
2791
|
+
...
|
2792
|
+
def list(self, name: typing.Optional[str] = None, task: typing.Union["metaflow.Task", str, None] = None, attempt: typing.Union[int, str, None] = None, as_dict: bool = True, within_task: bool = True) -> typing.Iterable[typing.Union[typing.Dict, metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures.CheckpointArtifact]]:
|
2793
|
+
"""
|
2794
|
+
lists the checkpoints in the datastore based on the Task.
|
2795
|
+
It will always be task scoped.
|
2796
|
+
|
2797
|
+
Usage:
|
2798
|
+
------
|
2799
|
+
|
2800
|
+
```python
|
2801
|
+
|
2802
|
+
Checkpoint().list(name="best") # lists checkpoints in the current task with the name "best"
|
2803
|
+
Checkpoint().list(name="best", task="anotherflow/somerunid/somestep/sometask") # lists checkpoints in the another task with the name "best"
|
2804
|
+
Checkpoint().list(task="anotherflow/somerunid/somestep/sometask", name="best") # Identical as the above one but
|
2805
|
+
Checkpoint().list() # lists all the checkpoints in the current task
|
2806
|
+
|
2807
|
+
```
|
2808
|
+
|
2809
|
+
Parameters
|
2810
|
+
----------
|
2811
|
+
|
2812
|
+
- `name`:
|
2813
|
+
- name of the checkpoint to filter for
|
2814
|
+
- `task`:
|
2815
|
+
- Task object outside the one that is currently set in the `Checkpoint` object; Can be a pathspec string.
|
2816
|
+
- `attempt`:
|
2817
|
+
- attempt number of the task (optional filter. If none, then lists all checkpoints from all attempts)
|
2818
|
+
"""
|
2819
|
+
...
|
2820
|
+
def load(self, reference: typing.Union[str, typing.Dict, metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures.CheckpointArtifact], path: typing.Optional[str] = None):
|
2821
|
+
"""
|
2822
|
+
loads a checkpoint reference from the datastore. (resembles a read op)
|
2823
|
+
|
2824
|
+
Parameters
|
2825
|
+
----------
|
2826
|
+
|
2827
|
+
`reference` :
|
2828
|
+
- can be a string, dict or a CheckpointArtifact object:
|
2829
|
+
- string: a string reference to the checkpoint (checkpoint key)
|
2830
|
+
- dict: a dictionary reference to the checkpoint
|
2831
|
+
- CheckpointArtifact: a CheckpointArtifact object reference to the checkpoint
|
2832
|
+
"""
|
2833
|
+
...
|
2834
|
+
...
|
2835
|
+
|
2836
|
+
def load_model(reference: typing.Union[str, metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures.MetaflowDataArtifactReference, dict], path: str):
|
2837
|
+
...
|
2838
|
+
|
2643
2839
|
def get_aws_client(module, with_error = False, role_arn = None, session_vars = None, client_params = None):
|
2644
2840
|
...
|
2645
2841
|
|