ob-metaflow-stubs 5.9.1__py2.py3-none-any.whl → 6.0.3.102rc0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. metaflow-stubs/__init__.pyi +652 -458
  2. metaflow-stubs/cards.pyi +6 -6
  3. metaflow-stubs/cli.pyi +2 -2
  4. metaflow-stubs/client/__init__.pyi +4 -4
  5. metaflow-stubs/client/core.pyi +7 -7
  6. metaflow-stubs/client/filecache.pyi +3 -3
  7. metaflow-stubs/clone_util.pyi +2 -2
  8. metaflow-stubs/events.pyi +2 -2
  9. metaflow-stubs/exception.pyi +2 -2
  10. metaflow-stubs/flowspec.pyi +4 -4
  11. metaflow-stubs/generated_for.txt +1 -1
  12. metaflow-stubs/includefile.pyi +3 -3
  13. metaflow-stubs/info_file.pyi +16 -0
  14. metaflow-stubs/metadata/metadata.pyi +2 -2
  15. metaflow-stubs/metadata/util.pyi +2 -2
  16. metaflow-stubs/metaflow_config.pyi +2 -2
  17. metaflow-stubs/metaflow_current.pyi +155 -31
  18. metaflow-stubs/mflog/mflog.pyi +2 -2
  19. metaflow-stubs/multicore_utils.pyi +2 -2
  20. metaflow-stubs/parameters.pyi +3 -3
  21. metaflow-stubs/plugins/__init__.pyi +3 -3
  22. metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
  23. metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
  24. metaflow-stubs/plugins/airflow/exception.pyi +2 -2
  25. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
  26. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
  27. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +3 -3
  28. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +3 -3
  29. metaflow-stubs/plugins/argo/__init__.pyi +2 -2
  30. metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
  31. metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
  32. metaflow-stubs/plugins/argo/argo_workflows.pyi +4 -4
  33. metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +6 -6
  34. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +6 -6
  35. metaflow-stubs/plugins/argo/argo_workflows_deployer.pyi +3 -3
  36. metaflow-stubs/plugins/aws/__init__.pyi +2 -2
  37. metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
  38. metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
  39. metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
  40. metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
  41. metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
  42. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +3 -3
  43. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
  44. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -3
  45. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
  46. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
  47. metaflow-stubs/plugins/aws/step_functions/production_token.pyi +2 -2
  48. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
  49. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
  50. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
  51. metaflow-stubs/plugins/aws/step_functions/step_functions_deployer.pyi +3 -3
  52. metaflow-stubs/plugins/azure/__init__.pyi +2 -2
  53. metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
  54. metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
  55. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +3 -3
  56. metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
  57. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
  58. metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
  59. metaflow-stubs/plugins/cards/__init__.pyi +2 -2
  60. metaflow-stubs/plugins/cards/card_cli.pyi +4 -4
  61. metaflow-stubs/plugins/cards/card_client.pyi +3 -3
  62. metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
  63. metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
  64. metaflow-stubs/plugins/cards/card_decorator.pyi +3 -3
  65. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
  66. metaflow-stubs/plugins/cards/card_modules/basic.pyi +4 -4
  67. metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
  68. metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
  69. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
  70. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
  71. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +3 -3
  72. metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
  73. metaflow-stubs/plugins/cards/component_serializer.pyi +4 -4
  74. metaflow-stubs/plugins/cards/exception.pyi +2 -2
  75. metaflow-stubs/plugins/catch_decorator.pyi +3 -3
  76. metaflow-stubs/plugins/datatools/__init__.pyi +3 -3
  77. metaflow-stubs/plugins/datatools/local.pyi +2 -2
  78. metaflow-stubs/plugins/datatools/s3/__init__.pyi +3 -3
  79. metaflow-stubs/plugins/datatools/s3/s3.pyi +5 -5
  80. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
  81. metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
  82. metaflow-stubs/plugins/debug_logger.pyi +2 -2
  83. metaflow-stubs/plugins/debug_monitor.pyi +2 -2
  84. metaflow-stubs/plugins/environment_decorator.pyi +2 -2
  85. metaflow-stubs/plugins/events_decorator.pyi +3 -3
  86. metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
  87. metaflow-stubs/plugins/frameworks/pytorch.pyi +3 -3
  88. metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
  89. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +3 -3
  90. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
  91. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
  92. metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
  93. metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
  94. metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
  95. metaflow-stubs/plugins/kubernetes/kube_utils.pyi +2 -2
  96. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +2 -2
  97. metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +3 -3
  98. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
  99. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +3 -3
  100. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +2 -2
  101. metaflow-stubs/plugins/logs_cli.pyi +3 -3
  102. metaflow-stubs/plugins/package_cli.pyi +2 -2
  103. metaflow-stubs/plugins/parallel_decorator.pyi +3 -3
  104. metaflow-stubs/plugins/perimeters.pyi +2 -2
  105. metaflow-stubs/plugins/project_decorator.pyi +3 -3
  106. metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
  107. metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
  108. metaflow-stubs/plugins/pypi/conda_environment.pyi +4 -4
  109. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
  110. metaflow-stubs/plugins/pypi/pypi_environment.pyi +3 -3
  111. metaflow-stubs/plugins/pypi/utils.pyi +2 -2
  112. metaflow-stubs/plugins/resources_decorator.pyi +2 -2
  113. metaflow-stubs/plugins/retry_decorator.pyi +2 -2
  114. metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
  115. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +3 -3
  116. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
  117. metaflow-stubs/plugins/storage_executor.pyi +2 -2
  118. metaflow-stubs/plugins/tag_cli.pyi +5 -5
  119. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +3 -3
  120. metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
  121. metaflow-stubs/procpoll.pyi +2 -2
  122. metaflow-stubs/profilers/__init__.pyi +2 -2
  123. metaflow-stubs/pylint_wrapper.pyi +2 -2
  124. metaflow-stubs/runner/__init__.pyi +2 -2
  125. metaflow-stubs/runner/deployer.pyi +3 -3
  126. metaflow-stubs/runner/metaflow_runner.pyi +5 -5
  127. metaflow-stubs/runner/nbdeploy.pyi +2 -2
  128. metaflow-stubs/runner/nbrun.pyi +2 -2
  129. metaflow-stubs/runner/subprocess_manager.pyi +2 -2
  130. metaflow-stubs/runner/utils.pyi +2 -2
  131. metaflow-stubs/system/__init__.pyi +3 -3
  132. metaflow-stubs/system/system_logger.pyi +3 -3
  133. metaflow-stubs/system/system_monitor.pyi +3 -3
  134. metaflow-stubs/tagging_util.pyi +2 -2
  135. metaflow-stubs/tuple_util.pyi +2 -2
  136. {ob_metaflow_stubs-5.9.1.dist-info → ob_metaflow_stubs-6.0.3.102rc0.dist-info}/METADATA +1 -1
  137. ob_metaflow_stubs-6.0.3.102rc0.dist-info/RECORD +140 -0
  138. {ob_metaflow_stubs-5.9.1.dist-info → ob_metaflow_stubs-6.0.3.102rc0.dist-info}/WHEEL +1 -1
  139. ob_metaflow_stubs-5.9.1.dist-info/RECORD +0 -139
  140. {ob_metaflow_stubs-5.9.1.dist-info → ob_metaflow_stubs-6.0.3.102rc0.dist-info}/top_level.txt +0 -0
@@ -1,30 +1,27 @@
1
1
  ##################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
- # MF version: 2.12.20.1+ob(v1) #
4
- # Generated on 2024-09-16T18:41:26.221357 #
3
+ # MF version: 2.12.22.1+obcheckpoint(0.0.10);ob(v1) #
4
+ # Generated on 2024-09-20T18:35:21.800373 #
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._vendor.click.types
12
- import metaflow.client.core
13
- import metaflow.runner.metaflow_runner
14
- import datetime
15
11
  import metaflow.events
12
+ import metaflow_extensions.obcheckpoint.plugins.machine_learning_utilities.datastructures
13
+ import metaflow.datastore.inputs
16
14
  import metaflow.metaflow_current
15
+ import metaflow._vendor.click.types
16
+ import metaflow.runner.metaflow_runner
17
17
  import typing
18
18
  import metaflow.flowspec
19
+ import metaflow.client.core
19
20
  import metaflow.parameters
20
- import metaflow.datastore.inputs
21
+ import datetime
21
22
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
22
23
  StepFlag = typing.NewType("StepFlag", bool)
23
24
 
24
- CURRENT_DIRECTORY: str
25
-
26
- INFO_FILE: str
27
-
28
25
  EXT_PKG: str
29
26
 
30
27
  def parallel_imap_unordered(func: typing.Callable[[typing.Any], typing.Any], iterable: typing.Iterable[typing.Any], max_parallel: typing.Optional[int] = None, dir: typing.Optional[str] = None) -> typing.Iterator[typing.Any]:
@@ -438,143 +435,104 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
438
435
  ...
439
436
 
440
437
  @typing.overload
441
- 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]]]:
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]]]:
442
439
  """
443
- Specifies the resources needed when executing this step.
444
-
445
- Use `@resources` to specify the resource requirements
446
- independently of the specific compute layer (`@batch`, `@kubernetes`).
440
+ Specifies that the step will success under all circumstances.
447
441
 
448
- You can choose the compute layer on the command line by executing e.g.
449
- ```
450
- python myflow.py run --with batch
451
- ```
452
- or
453
- ```
454
- python myflow.py run --with kubernetes
455
- ```
456
- which executes the flow on the desired system using the
457
- requirements specified in `@resources`.
442
+ The decorator will create an optional artifact, specified by `var`, which
443
+ contains the exception raised. You can use it to detect the presence
444
+ of errors, indicating that all happy-path artifacts produced by the step
445
+ are missing.
458
446
 
459
447
  Parameters
460
448
  ----------
461
- cpu : int, default 1
462
- Number of CPUs required for this step.
463
- gpu : int, default 0
464
- Number of GPUs required for this step.
465
- disk : int, optional, default None
466
- Disk size (in MB) required for this step. Only applies on Kubernetes.
467
- memory : int, default 4096
468
- Memory size (in MB) required for this step.
469
- shared_memory : int, optional, default None
470
- The value for the size (in MiB) of the /dev/shm volume for this step.
471
- This parameter maps to the `--shm-size` option in Docker.
449
+ var : str, optional, default None
450
+ Name of the artifact in which to store the caught exception.
451
+ If not specified, the exception is not stored.
452
+ print_exception : bool, default True
453
+ Determines whether or not the exception is printed to
454
+ stdout when caught.
472
455
  """
473
456
  ...
474
457
 
475
458
  @typing.overload
476
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
459
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
477
460
  ...
478
461
 
479
462
  @typing.overload
480
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
463
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
481
464
  ...
482
465
 
483
- 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):
466
+ def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, var: typing.Optional[str] = None, print_exception: bool = True):
484
467
  """
485
- Specifies the resources needed when executing this step.
486
-
487
- Use `@resources` to specify the resource requirements
488
- independently of the specific compute layer (`@batch`, `@kubernetes`).
468
+ Specifies that the step will success under all circumstances.
489
469
 
490
- You can choose the compute layer on the command line by executing e.g.
491
- ```
492
- python myflow.py run --with batch
493
- ```
494
- or
495
- ```
496
- python myflow.py run --with kubernetes
497
- ```
498
- which executes the flow on the desired system using the
499
- requirements specified in `@resources`.
470
+ The decorator will create an optional artifact, specified by `var`, which
471
+ contains the exception raised. You can use it to detect the presence
472
+ of errors, indicating that all happy-path artifacts produced by the step
473
+ are missing.
500
474
 
501
475
  Parameters
502
476
  ----------
503
- cpu : int, default 1
504
- Number of CPUs required for this step.
505
- gpu : int, default 0
506
- Number of GPUs required for this step.
507
- disk : int, optional, default None
508
- Disk size (in MB) required for this step. Only applies on Kubernetes.
509
- memory : int, default 4096
510
- Memory size (in MB) required for this step.
511
- shared_memory : int, optional, default None
512
- The value for the size (in MiB) of the /dev/shm volume for this step.
513
- This parameter maps to the `--shm-size` option in Docker.
477
+ var : str, optional, default None
478
+ Name of the artifact in which to store the caught exception.
479
+ If not specified, the exception is not stored.
480
+ print_exception : bool, default True
481
+ Determines whether or not the exception is printed to
482
+ stdout when caught.
514
483
  """
515
484
  ...
516
485
 
517
486
  @typing.overload
518
- 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]]]:
487
+ 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]]]:
519
488
  """
520
- Specifies environment variables to be set prior to the execution of a step.
489
+ Specifies the number of times the task corresponding
490
+ to a step needs to be retried.
521
491
 
522
- Parameters
523
- ----------
524
- vars : Dict[str, str], default {}
525
- Dictionary of environment variables to set.
526
- """
527
- ...
528
-
529
- @typing.overload
530
- def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
531
- ...
532
-
533
- @typing.overload
534
- def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
535
- ...
536
-
537
- def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
538
- """
539
- Specifies environment variables to be set prior to the execution of a step.
492
+ This decorator is useful for handling transient errors, such as networking issues.
493
+ If your task contains operations that can't be retried safely, e.g. database updates,
494
+ it is advisable to annotate it with `@retry(times=0)`.
540
495
 
541
- Parameters
542
- ----------
543
- vars : Dict[str, str], default {}
544
- Dictionary of environment variables to set.
545
- """
546
- ...
547
-
548
- @typing.overload
549
- def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
550
- """
551
- Specifies secrets to be retrieved and injected as environment variables prior to
552
- the execution of a step.
496
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
497
+ decorator will execute a no-op task after all retries have been exhausted,
498
+ ensuring that the flow execution can continue.
553
499
 
554
500
  Parameters
555
501
  ----------
556
- sources : List[Union[str, Dict[str, Any]]], default: []
557
- List of secret specs, defining how the secrets are to be retrieved
502
+ times : int, default 3
503
+ Number of times to retry this task.
504
+ minutes_between_retries : int, default 2
505
+ Number of minutes between retries.
558
506
  """
559
507
  ...
560
508
 
561
509
  @typing.overload
562
- def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
510
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
563
511
  ...
564
512
 
565
513
  @typing.overload
566
- def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
514
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
567
515
  ...
568
516
 
569
- def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
517
+ 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):
570
518
  """
571
- Specifies secrets to be retrieved and injected as environment variables prior to
572
- the execution of a step.
519
+ Specifies the number of times the task corresponding
520
+ to a step needs to be retried.
521
+
522
+ This decorator is useful for handling transient errors, such as networking issues.
523
+ If your task contains operations that can't be retried safely, e.g. database updates,
524
+ it is advisable to annotate it with `@retry(times=0)`.
525
+
526
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
527
+ decorator will execute a no-op task after all retries have been exhausted,
528
+ ensuring that the flow execution can continue.
573
529
 
574
530
  Parameters
575
531
  ----------
576
- sources : List[Union[str, Dict[str, Any]]], default: []
577
- List of secret specs, defining how the secrets are to be retrieved
532
+ times : int, default 3
533
+ Number of times to retry this task.
534
+ minutes_between_retries : int, default 2
535
+ Number of minutes between retries.
578
536
  """
579
537
  ...
580
538
 
@@ -636,221 +594,219 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
636
594
  ...
637
595
 
638
596
  @typing.overload
639
- 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]]]:
597
+ def secrets(*, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
640
598
  """
641
- Specifies that the step will success under all circumstances.
642
-
643
- The decorator will create an optional artifact, specified by `var`, which
644
- contains the exception raised. You can use it to detect the presence
645
- of errors, indicating that all happy-path artifacts produced by the step
646
- are missing.
599
+ Specifies secrets to be retrieved and injected as environment variables prior to
600
+ the execution of a step.
647
601
 
648
602
  Parameters
649
603
  ----------
650
- var : str, optional, default None
651
- Name of the artifact in which to store the caught exception.
652
- If not specified, the exception is not stored.
653
- print_exception : bool, default True
654
- Determines whether or not the exception is printed to
655
- stdout when caught.
604
+ sources : List[Union[str, Dict[str, Any]]], default: []
605
+ List of secret specs, defining how the secrets are to be retrieved
656
606
  """
657
607
  ...
658
608
 
659
609
  @typing.overload
660
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
610
+ def secrets(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
661
611
  ...
662
612
 
663
613
  @typing.overload
664
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
614
+ def secrets(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
665
615
  ...
666
616
 
667
- def catch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, var: typing.Optional[str] = None, print_exception: bool = True):
617
+ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, sources: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = []):
668
618
  """
669
- Specifies that the step will success under all circumstances.
670
-
671
- The decorator will create an optional artifact, specified by `var`, which
672
- contains the exception raised. You can use it to detect the presence
673
- of errors, indicating that all happy-path artifacts produced by the step
674
- are missing.
619
+ Specifies secrets to be retrieved and injected as environment variables prior to
620
+ the execution of a step.
675
621
 
676
622
  Parameters
677
623
  ----------
678
- var : str, optional, default None
679
- Name of the artifact in which to store the caught exception.
680
- If not specified, the exception is not stored.
681
- print_exception : bool, default True
682
- Determines whether or not the exception is printed to
683
- stdout when caught.
684
- """
685
- ...
686
-
687
- @typing.overload
688
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
689
- """
690
- Internal decorator to support Fast bakery
691
- """
692
- ...
693
-
694
- @typing.overload
695
- def fast_bakery_internal(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
696
- ...
697
-
698
- def fast_bakery_internal(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
699
- """
700
- Internal decorator to support Fast bakery
624
+ sources : List[Union[str, Dict[str, Any]]], default: []
625
+ List of secret specs, defining how the secrets are to be retrieved
701
626
  """
702
627
  ...
703
628
 
704
629
  @typing.overload
705
- 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]]]:
630
+ 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]]]:
706
631
  """
707
- Creates a human-readable report, a Metaflow Card, after this step completes.
632
+ Specifies a timeout for your step.
708
633
 
709
- Note that you may add multiple `@card` decorators in a step with different parameters.
634
+ This decorator is useful if this step may hang indefinitely.
710
635
 
711
- Parameters
712
- ----------
713
- type : str, default 'default'
714
- Card type.
715
- id : str, optional, default None
716
- If multiple cards are present, use this id to identify this card.
717
- options : Dict[str, Any], default {}
718
- Options passed to the card. The contents depend on the card type.
719
- timeout : int, default 45
720
- Interrupt reporting if it takes more than this many seconds.
636
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
637
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
638
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
721
639
 
640
+ Note that all the values specified in parameters are added together so if you specify
641
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
722
642
 
643
+ Parameters
644
+ ----------
645
+ seconds : int, default 0
646
+ Number of seconds to wait prior to timing out.
647
+ minutes : int, default 0
648
+ Number of minutes to wait prior to timing out.
649
+ hours : int, default 0
650
+ Number of hours to wait prior to timing out.
723
651
  """
724
652
  ...
725
653
 
726
654
  @typing.overload
727
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
655
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
728
656
  ...
729
657
 
730
658
  @typing.overload
731
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
659
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
732
660
  ...
733
661
 
734
- 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):
662
+ 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):
735
663
  """
736
- Creates a human-readable report, a Metaflow Card, after this step completes.
664
+ Specifies a timeout for your step.
737
665
 
738
- Note that you may add multiple `@card` decorators in a step with different parameters.
666
+ This decorator is useful if this step may hang indefinitely.
739
667
 
740
- Parameters
741
- ----------
742
- type : str, default 'default'
743
- Card type.
744
- id : str, optional, default None
745
- If multiple cards are present, use this id to identify this card.
746
- options : Dict[str, Any], default {}
747
- Options passed to the card. The contents depend on the card type.
748
- timeout : int, default 45
749
- Interrupt reporting if it takes more than this many seconds.
668
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
669
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
670
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
750
671
 
672
+ Note that all the values specified in parameters are added together so if you specify
673
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
751
674
 
675
+ Parameters
676
+ ----------
677
+ seconds : int, default 0
678
+ Number of seconds to wait prior to timing out.
679
+ minutes : int, default 0
680
+ Number of minutes to wait prior to timing out.
681
+ hours : int, default 0
682
+ Number of hours to wait prior to timing out.
752
683
  """
753
684
  ...
754
685
 
755
686
  @typing.overload
756
- 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]]]:
687
+ 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]]]:
757
688
  """
758
- Specifies the PyPI packages for the step.
759
-
760
- Information in this decorator will augment any
761
- attributes set in the `@pyi_base` flow-level decorator. Hence,
762
- you can use `@pypi_base` to set packages required by all
763
- steps and use `@pypi` to specify step-specific overrides.
689
+ Specifies environment variables to be set prior to the execution of a step.
764
690
 
765
691
  Parameters
766
692
  ----------
767
- packages : Dict[str, str], default: {}
768
- Packages to use for this step. The key is the name of the package
769
- and the value is the version to use.
770
- python : str, optional, default: None
771
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
772
- that the version used will correspond to the version of the Python interpreter used to start the run.
693
+ vars : Dict[str, str], default {}
694
+ Dictionary of environment variables to set.
773
695
  """
774
696
  ...
775
697
 
776
698
  @typing.overload
777
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
699
+ def environment(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
778
700
  ...
779
701
 
780
702
  @typing.overload
781
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
703
+ def environment(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
782
704
  ...
783
705
 
784
- 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):
706
+ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None, *, vars: typing.Dict[str, str] = {}):
785
707
  """
786
- Specifies the PyPI packages for the step.
787
-
788
- Information in this decorator will augment any
789
- attributes set in the `@pyi_base` flow-level decorator. Hence,
790
- you can use `@pypi_base` to set packages required by all
791
- steps and use `@pypi` to specify step-specific overrides.
708
+ Specifies environment variables to be set prior to the execution of a step.
792
709
 
793
710
  Parameters
794
711
  ----------
795
- packages : Dict[str, str], default: {}
796
- Packages to use for this step. The key is the name of the package
797
- and the value is the version to use.
798
- python : str, optional, default: None
799
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
800
- that the version used will correspond to the version of the Python interpreter used to start the run.
712
+ vars : Dict[str, str], default {}
713
+ Dictionary of environment variables to set.
801
714
  """
802
715
  ...
803
716
 
804
717
  @typing.overload
805
- 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]]]:
718
+ 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]]]:
806
719
  """
807
- Specifies the number of times the task corresponding
808
- to a step needs to be retried.
720
+ Specifies the resources needed when executing this step.
809
721
 
810
- This decorator is useful for handling transient errors, such as networking issues.
811
- If your task contains operations that can't be retried safely, e.g. database updates,
812
- it is advisable to annotate it with `@retry(times=0)`.
722
+ Use `@resources` to specify the resource requirements
723
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
813
724
 
814
- This can be used in conjunction with the `@catch` decorator. The `@catch`
815
- decorator will execute a no-op task after all retries have been exhausted,
816
- ensuring that the flow execution can continue.
725
+ You can choose the compute layer on the command line by executing e.g.
726
+ ```
727
+ python myflow.py run --with batch
728
+ ```
729
+ or
730
+ ```
731
+ python myflow.py run --with kubernetes
732
+ ```
733
+ which executes the flow on the desired system using the
734
+ requirements specified in `@resources`.
817
735
 
818
736
  Parameters
819
737
  ----------
820
- times : int, default 3
821
- Number of times to retry this task.
822
- minutes_between_retries : int, default 2
823
- Number of minutes between retries.
738
+ cpu : int, default 1
739
+ Number of CPUs required for this step.
740
+ gpu : int, default 0
741
+ Number of GPUs required for this step.
742
+ disk : int, optional, default None
743
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
744
+ memory : int, default 4096
745
+ Memory size (in MB) required for this step.
746
+ shared_memory : int, optional, default None
747
+ The value for the size (in MiB) of the /dev/shm volume for this step.
748
+ This parameter maps to the `--shm-size` option in Docker.
824
749
  """
825
750
  ...
826
751
 
827
752
  @typing.overload
828
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
753
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
829
754
  ...
830
755
 
831
756
  @typing.overload
832
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
757
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
833
758
  ...
834
759
 
835
- 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):
760
+ 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):
836
761
  """
837
- Specifies the number of times the task corresponding
838
- to a step needs to be retried.
762
+ Specifies the resources needed when executing this step.
839
763
 
840
- This decorator is useful for handling transient errors, such as networking issues.
841
- If your task contains operations that can't be retried safely, e.g. database updates,
842
- it is advisable to annotate it with `@retry(times=0)`.
764
+ Use `@resources` to specify the resource requirements
765
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
843
766
 
844
- This can be used in conjunction with the `@catch` decorator. The `@catch`
845
- decorator will execute a no-op task after all retries have been exhausted,
846
- ensuring that the flow execution can continue.
767
+ You can choose the compute layer on the command line by executing e.g.
768
+ ```
769
+ python myflow.py run --with batch
770
+ ```
771
+ or
772
+ ```
773
+ python myflow.py run --with kubernetes
774
+ ```
775
+ which executes the flow on the desired system using the
776
+ requirements specified in `@resources`.
847
777
 
848
778
  Parameters
849
779
  ----------
850
- times : int, default 3
851
- Number of times to retry this task.
852
- minutes_between_retries : int, default 2
853
- Number of minutes between retries.
780
+ cpu : int, default 1
781
+ Number of CPUs required for this step.
782
+ gpu : int, default 0
783
+ Number of GPUs required for this step.
784
+ disk : int, optional, default None
785
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
786
+ memory : int, default 4096
787
+ Memory size (in MB) required for this step.
788
+ shared_memory : int, optional, default None
789
+ The value for the size (in MiB) of the /dev/shm volume for this step.
790
+ This parameter maps to the `--shm-size` option in Docker.
791
+ """
792
+ ...
793
+
794
+ @typing.overload
795
+ def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
796
+ """
797
+ Decorator prototype for all step decorators. This function gets specialized
798
+ and imported for all decorators types by _import_plugin_decorators().
799
+ """
800
+ ...
801
+
802
+ @typing.overload
803
+ def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
804
+ ...
805
+
806
+ def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
807
+ """
808
+ Decorator prototype for all step decorators. This function gets specialized
809
+ and imported for all decorators types by _import_plugin_decorators().
854
810
  """
855
811
  ...
856
812
 
@@ -921,78 +877,241 @@ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: ty
921
877
  ...
922
878
 
923
879
  @typing.overload
924
- def parallel(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
880
+ 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]]]:
925
881
  """
926
- Decorator prototype for all step decorators. This function gets specialized
927
- and imported for all decorators types by _import_plugin_decorators().
882
+ Specifies the PyPI packages for the step.
883
+
884
+ Information in this decorator will augment any
885
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
886
+ you can use `@pypi_base` to set packages required by all
887
+ steps and use `@pypi` to specify step-specific overrides.
888
+
889
+ Parameters
890
+ ----------
891
+ packages : Dict[str, str], default: {}
892
+ Packages to use for this step. The key is the name of the package
893
+ and the value is the version to use.
894
+ python : str, optional, default: None
895
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
896
+ that the version used will correspond to the version of the Python interpreter used to start the run.
928
897
  """
929
898
  ...
930
899
 
931
900
  @typing.overload
932
- def parallel(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
901
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
933
902
  ...
934
903
 
935
- def parallel(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None], None] = None):
904
+ @typing.overload
905
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
906
+ ...
907
+
908
+ 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):
936
909
  """
937
- Decorator prototype for all step decorators. This function gets specialized
938
- and imported for all decorators types by _import_plugin_decorators().
910
+ Specifies the PyPI packages for the step.
911
+
912
+ Information in this decorator will augment any
913
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
914
+ you can use `@pypi_base` to set packages required by all
915
+ steps and use `@pypi` to specify step-specific overrides.
916
+
917
+ Parameters
918
+ ----------
919
+ packages : Dict[str, str], default: {}
920
+ Packages to use for this step. The key is the name of the package
921
+ and the value is the version to use.
922
+ python : str, optional, default: None
923
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
924
+ that the version used will correspond to the version of the Python interpreter used to start the run.
939
925
  """
940
926
  ...
941
927
 
942
928
  @typing.overload
943
- 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]]]:
929
+ 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]]]:
944
930
  """
945
- Specifies a timeout for your step.
931
+ Creates a human-readable report, a Metaflow Card, after this step completes.
946
932
 
947
- This decorator is useful if this step may hang indefinitely.
933
+ Note that you may add multiple `@card` decorators in a step with different parameters.
948
934
 
949
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
950
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
951
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
935
+ Parameters
936
+ ----------
937
+ type : str, default 'default'
938
+ Card type.
939
+ id : str, optional, default None
940
+ If multiple cards are present, use this id to identify this card.
941
+ options : Dict[str, Any], default {}
942
+ Options passed to the card. The contents depend on the card type.
943
+ timeout : int, default 45
944
+ Interrupt reporting if it takes more than this many seconds.
952
945
 
953
- Note that all the values specified in parameters are added together so if you specify
954
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
946
+
947
+ """
948
+ ...
949
+
950
+ @typing.overload
951
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
952
+ ...
953
+
954
+ @typing.overload
955
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
956
+ ...
957
+
958
+ 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):
959
+ """
960
+ Creates a human-readable report, a Metaflow Card, after this step completes.
961
+
962
+ Note that you may add multiple `@card` decorators in a step with different parameters.
955
963
 
956
964
  Parameters
957
965
  ----------
958
- seconds : int, default 0
959
- Number of seconds to wait prior to timing out.
960
- minutes : int, default 0
961
- Number of minutes to wait prior to timing out.
962
- hours : int, default 0
963
- Number of hours to wait prior to timing out.
966
+ type : str, default 'default'
967
+ Card type.
968
+ id : str, optional, default None
969
+ If multiple cards are present, use this id to identify this card.
970
+ options : Dict[str, Any], default {}
971
+ Options passed to the card. The contents depend on the card type.
972
+ timeout : int, default 45
973
+ Interrupt reporting if it takes more than this many seconds.
974
+
975
+
964
976
  """
965
977
  ...
966
978
 
967
979
  @typing.overload
968
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
980
+ 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]]]:
981
+ """
982
+ Enables checkpointing for a step.
983
+
984
+
985
+ Parameters
986
+ ----------
987
+ load_policy : str, default: "fresh"
988
+ The policy for loading the checkpoint. The following policies are supported:
989
+ - "eager": Loads the the latest available checkpoint within the namespace.
990
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
991
+ will be loaded at the start of the task.
992
+ - "none": Do not load any checkpoint
993
+ - "fresh": Loads the lastest checkpoint created within the running Task.
994
+ This mode helps loading checkpoints across various retry attempts of the same task.
995
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
996
+ created within the task will be loaded when the task is retries execution on failure.
997
+
998
+ temp_dir_root : str, default: None
999
+ The root directory under which `current.checkpoint.directory` will be created.
1000
+
1001
+
1002
+
1003
+ """
969
1004
  ...
970
1005
 
971
1006
  @typing.overload
972
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1007
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
973
1008
  ...
974
1009
 
975
- 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):
1010
+ @typing.overload
1011
+ def checkpoint(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1012
+ ...
1013
+
1014
+ 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):
976
1015
  """
977
- Specifies a timeout for your step.
1016
+ Enables checkpointing for a step.
978
1017
 
979
- This decorator is useful if this step may hang indefinitely.
980
1018
 
981
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
982
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
983
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
1019
+ Parameters
1020
+ ----------
1021
+ load_policy : str, default: "fresh"
1022
+ The policy for loading the checkpoint. The following policies are supported:
1023
+ - "eager": Loads the the latest available checkpoint within the namespace.
1024
+ With this mode, the latest checkpoint written by any previous task (can be even a different run) of the step
1025
+ will be loaded at the start of the task.
1026
+ - "none": Do not load any checkpoint
1027
+ - "fresh": Loads the lastest checkpoint created within the running Task.
1028
+ This mode helps loading checkpoints across various retry attempts of the same task.
1029
+ With this mode, no checkpoint will be loaded at the start of a task but any checkpoints
1030
+ created within the task will be loaded when the task is retries execution on failure.
1031
+
1032
+ temp_dir_root : str, default: None
1033
+ The root directory under which `current.checkpoint.directory` will be created.
1034
+
1035
+
1036
+
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.
984
1044
 
985
- Note that all the values specified in parameters are added together so if you specify
986
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
987
1045
 
988
1046
  Parameters
989
1047
  ----------
990
- seconds : int, default 0
991
- Number of seconds to wait prior to timing out.
992
- minutes : int, default 0
993
- Number of minutes to wait prior to timing out.
994
- hours : int, default 0
995
- Number of hours to wait prior to timing out.
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
996
1115
  """
997
1116
  ...
998
1117
 
@@ -1045,105 +1164,140 @@ def schedule(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, hourly:
1045
1164
  """
1046
1165
  ...
1047
1166
 
1048
- 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]]:
1167
+ @typing.overload
1168
+ def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1049
1169
  """
1050
- 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)
1051
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1052
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1053
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1054
- starts only after all sensors finish.
1170
+ Specifies the event(s) that this flow depends on.
1171
+
1172
+ ```
1173
+ @trigger(event='foo')
1174
+ ```
1175
+ or
1176
+ ```
1177
+ @trigger(events=['foo', 'bar'])
1178
+ ```
1179
+
1180
+ Additionally, you can specify the parameter mappings
1181
+ to map event payload to Metaflow parameters for the flow.
1182
+ ```
1183
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1184
+ ```
1185
+ or
1186
+ ```
1187
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1188
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1189
+ ```
1190
+
1191
+ 'parameters' can also be a list of strings and tuples like so:
1192
+ ```
1193
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1194
+ ```
1195
+ This is equivalent to:
1196
+ ```
1197
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1198
+ ```
1055
1199
 
1056
1200
  Parameters
1057
1201
  ----------
1058
- timeout : int
1059
- Time, in seconds before the task times out and fails. (Default: 3600)
1060
- poke_interval : int
1061
- Time in seconds that the job should wait in between each try. (Default: 60)
1062
- mode : str
1063
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1064
- exponential_backoff : bool
1065
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1066
- pool : str
1067
- the slot pool this task should run in,
1068
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1069
- soft_fail : bool
1070
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1071
- name : str
1072
- Name of the sensor on Airflow
1073
- description : str
1074
- Description of sensor in the Airflow UI
1075
- bucket_key : Union[str, List[str]]
1076
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1077
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1078
- bucket_name : str
1079
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1080
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1081
- wildcard_match : bool
1082
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1083
- aws_conn_id : str
1084
- a reference to the s3 connection on Airflow. (Default: None)
1085
- verify : bool
1086
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1202
+ event : Union[str, Dict[str, Any]], optional, default None
1203
+ Event dependency for this flow.
1204
+ events : List[Union[str, Dict[str, Any]]], default []
1205
+ Events dependency for this flow.
1206
+ options : Dict[str, Any], default {}
1207
+ Backend-specific configuration for tuning eventing behavior.
1208
+
1209
+
1087
1210
  """
1088
1211
  ...
1089
1212
 
1090
- 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]]:
1213
+ @typing.overload
1214
+ def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1215
+ ...
1216
+
1217
+ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
1091
1218
  """
1092
- 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.
1093
- 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.
1219
+ Specifies the event(s) that this flow depends on.
1220
+
1221
+ ```
1222
+ @trigger(event='foo')
1223
+ ```
1224
+ or
1225
+ ```
1226
+ @trigger(events=['foo', 'bar'])
1227
+ ```
1228
+
1229
+ Additionally, you can specify the parameter mappings
1230
+ to map event payload to Metaflow parameters for the flow.
1231
+ ```
1232
+ @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1233
+ ```
1234
+ or
1235
+ ```
1236
+ @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1237
+ {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1238
+ ```
1239
+
1240
+ 'parameters' can also be a list of strings and tuples like so:
1241
+ ```
1242
+ @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1243
+ ```
1244
+ This is equivalent to:
1245
+ ```
1246
+ @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1247
+ ```
1094
1248
 
1095
1249
  Parameters
1096
1250
  ----------
1097
- timeout : int
1098
- Time, in seconds before the task times out and fails. (Default: 3600)
1099
- poke_interval : int
1100
- Time in seconds that the job should wait in between each try. (Default: 60)
1101
- mode : str
1102
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1103
- exponential_backoff : bool
1104
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1105
- pool : str
1106
- the slot pool this task should run in,
1107
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1108
- soft_fail : bool
1109
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1110
- name : str
1111
- Name of the sensor on Airflow
1112
- description : str
1113
- Description of sensor in the Airflow UI
1114
- external_dag_id : str
1115
- The dag_id that contains the task you want to wait for.
1116
- external_task_ids : List[str]
1117
- The list of task_ids that you want to wait for.
1118
- If None (default value) the sensor waits for the DAG. (Default: None)
1119
- allowed_states : List[str]
1120
- Iterable of allowed states, (Default: ['success'])
1121
- failed_states : List[str]
1122
- Iterable of failed or dis-allowed states. (Default: None)
1123
- execution_delta : datetime.timedelta
1124
- time difference with the previous execution to look at,
1125
- the default is the same logical date as the current task or DAG. (Default: None)
1126
- check_existence: bool
1127
- Set to True to check if the external task exists or check if
1128
- the DAG to wait for exists. (Default: True)
1251
+ event : Union[str, Dict[str, Any]], optional, default None
1252
+ Event dependency for this flow.
1253
+ events : List[Union[str, Dict[str, Any]]], default []
1254
+ Events dependency for this flow.
1255
+ options : Dict[str, Any], default {}
1256
+ Backend-specific configuration for tuning eventing behavior.
1257
+
1258
+
1129
1259
  """
1130
1260
  ...
1131
1261
 
1132
- def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1262
+ 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
1263
  """
1134
- Specifies what flows belong to the same project.
1135
-
1136
- A project-specific namespace is created for all flows that
1137
- use the same `@project(name)`.
1264
+ 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)
1265
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1266
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1267
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1268
+ starts only after all sensors finish.
1138
1269
 
1139
1270
  Parameters
1140
1271
  ----------
1272
+ timeout : int
1273
+ Time, in seconds before the task times out and fails. (Default: 3600)
1274
+ poke_interval : int
1275
+ Time in seconds that the job should wait in between each try. (Default: 60)
1276
+ mode : str
1277
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1278
+ exponential_backoff : bool
1279
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1280
+ pool : str
1281
+ the slot pool this task should run in,
1282
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1283
+ soft_fail : bool
1284
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1141
1285
  name : str
1142
- Project name. Make sure that the name is unique amongst all
1143
- projects that use the same production scheduler. The name may
1144
- contain only lowercase alphanumeric characters and underscores.
1145
-
1146
-
1286
+ Name of the sensor on Airflow
1287
+ description : str
1288
+ Description of sensor in the Airflow UI
1289
+ bucket_key : Union[str, List[str]]
1290
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1291
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1292
+ bucket_name : str
1293
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1294
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1295
+ wildcard_match : bool
1296
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1297
+ aws_conn_id : str
1298
+ a reference to the s3 connection on Airflow. (Default: None)
1299
+ verify : bool
1300
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1147
1301
  """
1148
1302
  ...
1149
1303
 
@@ -1186,37 +1340,6 @@ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packag
1186
1340
  """
1187
1341
  ...
1188
1342
 
1189
- def nim(*, models: "list[NIM]", backend: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1190
- """
1191
- This decorator is used to run NIM containers in Metaflow tasks as sidecars.
1192
-
1193
- User code call
1194
- -----------
1195
- @nim(
1196
- models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
1197
- backend='managed'
1198
- )
1199
-
1200
- Valid backend options
1201
- ---------------------
1202
- - 'managed': Outerbounds selects a compute provider based on the model.
1203
- - 🚧 'dataplane': Run in your account.
1204
-
1205
- Valid model options
1206
- ----------------
1207
- - 'meta/llama3-8b-instruct': 8B parameter model
1208
- - 'meta/llama3-70b-instruct': 70B parameter model
1209
- - Upon request, any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
1210
-
1211
- Parameters
1212
- ----------
1213
- models: list[NIM]
1214
- List of NIM containers running models in sidecars.
1215
- backend: str
1216
- Compute provider to run the NIM container.
1217
- """
1218
- ...
1219
-
1220
1343
  @typing.overload
1221
1344
  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]]:
1222
1345
  """
@@ -1369,98 +1492,94 @@ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *
1369
1492
  """
1370
1493
  ...
1371
1494
 
1372
- @typing.overload
1373
- def trigger(*, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1495
+ def nim(*, models: "list[NIM]", backend: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1374
1496
  """
1375
- Specifies the event(s) that this flow depends on.
1497
+ This decorator is used to run NIM containers in Metaflow tasks as sidecars.
1376
1498
 
1377
- ```
1378
- @trigger(event='foo')
1379
- ```
1380
- or
1381
- ```
1382
- @trigger(events=['foo', 'bar'])
1383
- ```
1499
+ User code call
1500
+ -----------
1501
+ @nim(
1502
+ models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
1503
+ backend='managed'
1504
+ )
1384
1505
 
1385
- Additionally, you can specify the parameter mappings
1386
- to map event payload to Metaflow parameters for the flow.
1387
- ```
1388
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1389
- ```
1390
- or
1391
- ```
1392
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1393
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1394
- ```
1506
+ Valid backend options
1507
+ ---------------------
1508
+ - 'managed': Outerbounds selects a compute provider based on the model.
1509
+ - 🚧 'dataplane': Run in your account.
1395
1510
 
1396
- 'parameters' can also be a list of strings and tuples like so:
1397
- ```
1398
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1399
- ```
1400
- This is equivalent to:
1401
- ```
1402
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1403
- ```
1511
+ Valid model options
1512
+ ----------------
1513
+ - 'meta/llama3-8b-instruct': 8B parameter model
1514
+ - 'meta/llama3-70b-instruct': 70B parameter model
1515
+ - Upon request, any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
1404
1516
 
1405
1517
  Parameters
1406
1518
  ----------
1407
- event : Union[str, Dict[str, Any]], optional, default None
1408
- Event dependency for this flow.
1409
- events : List[Union[str, Dict[str, Any]]], default []
1410
- Events dependency for this flow.
1411
- options : Dict[str, Any], default {}
1412
- Backend-specific configuration for tuning eventing behavior.
1413
-
1414
-
1519
+ models: list[NIM]
1520
+ List of NIM containers running models in sidecars.
1521
+ backend: str
1522
+ Compute provider to run the NIM container.
1415
1523
  """
1416
1524
  ...
1417
1525
 
1418
- @typing.overload
1419
- def trigger(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1420
- ...
1421
-
1422
- def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: typing.Union[str, typing.Dict[str, typing.Any], None] = None, events: typing.List[typing.Union[str, typing.Dict[str, typing.Any]]] = [], options: typing.Dict[str, typing.Any] = {}):
1526
+ def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1423
1527
  """
1424
- Specifies the event(s) that this flow depends on.
1425
-
1426
- ```
1427
- @trigger(event='foo')
1428
- ```
1429
- or
1430
- ```
1431
- @trigger(events=['foo', 'bar'])
1432
- ```
1433
-
1434
- Additionally, you can specify the parameter mappings
1435
- to map event payload to Metaflow parameters for the flow.
1436
- ```
1437
- @trigger(event={'name':'foo', 'parameters':{'flow_param': 'event_field'}})
1438
- ```
1439
- or
1440
- ```
1441
- @trigger(events=[{'name':'foo', 'parameters':{'flow_param_1': 'event_field_1'},
1442
- {'name':'bar', 'parameters':{'flow_param_2': 'event_field_2'}])
1443
- ```
1528
+ Specifies what flows belong to the same project.
1444
1529
 
1445
- 'parameters' can also be a list of strings and tuples like so:
1446
- ```
1447
- @trigger(event={'name':'foo', 'parameters':['common_name', ('flow_param', 'event_field')]})
1448
- ```
1449
- This is equivalent to:
1450
- ```
1451
- @trigger(event={'name':'foo', 'parameters':{'common_name': 'common_name', 'flow_param': 'event_field'}})
1452
- ```
1530
+ A project-specific namespace is created for all flows that
1531
+ use the same `@project(name)`.
1453
1532
 
1454
1533
  Parameters
1455
1534
  ----------
1456
- event : Union[str, Dict[str, Any]], optional, default None
1457
- Event dependency for this flow.
1458
- events : List[Union[str, Dict[str, Any]]], default []
1459
- Events dependency for this flow.
1460
- options : Dict[str, Any], default {}
1461
- Backend-specific configuration for tuning eventing behavior.
1535
+ name : str
1536
+ Project name. Make sure that the name is unique amongst all
1537
+ projects that use the same production scheduler. The name may
1538
+ contain only lowercase alphanumeric characters and underscores.
1539
+
1462
1540
 
1541
+ """
1542
+ ...
1543
+
1544
+ 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]]:
1545
+ """
1546
+ 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.
1547
+ 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.
1463
1548
 
1549
+ Parameters
1550
+ ----------
1551
+ timeout : int
1552
+ Time, in seconds before the task times out and fails. (Default: 3600)
1553
+ poke_interval : int
1554
+ Time in seconds that the job should wait in between each try. (Default: 60)
1555
+ mode : str
1556
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1557
+ exponential_backoff : bool
1558
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1559
+ pool : str
1560
+ the slot pool this task should run in,
1561
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1562
+ soft_fail : bool
1563
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1564
+ name : str
1565
+ Name of the sensor on Airflow
1566
+ description : str
1567
+ Description of sensor in the Airflow UI
1568
+ external_dag_id : str
1569
+ The dag_id that contains the task you want to wait for.
1570
+ external_task_ids : List[str]
1571
+ The list of task_ids that you want to wait for.
1572
+ If None (default value) the sensor waits for the DAG. (Default: None)
1573
+ allowed_states : List[str]
1574
+ Iterable of allowed states, (Default: ['success'])
1575
+ failed_states : List[str]
1576
+ Iterable of failed or dis-allowed states. (Default: None)
1577
+ execution_delta : datetime.timedelta
1578
+ time difference with the previous execution to look at,
1579
+ the default is the same logical date as the current task or DAG. (Default: None)
1580
+ check_existence: bool
1581
+ Set to True to check if the external task exists or check if
1582
+ the DAG to wait for exists. (Default: True)
1464
1583
  """
1465
1584
  ...
1466
1585
 
@@ -2642,6 +2761,81 @@ class NBDeployer(object, metaclass=type):
2642
2761
  ...
2643
2762
  ...
2644
2763
 
2764
+ pkg_name: str
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
+
2645
2839
  def get_aws_client(module, with_error = False, role_arn = None, session_vars = None, client_params = None):
2646
2840
  ...
2647
2841