ob-metaflow-stubs 4.2__py2.py3-none-any.whl → 4.4__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 (145) hide show
  1. metaflow-stubs/__init__.pyi +601 -570
  2. metaflow-stubs/cards.pyi +4 -4
  3. metaflow-stubs/cli.pyi +2 -2
  4. metaflow-stubs/client/__init__.pyi +3 -3
  5. metaflow-stubs/client/core.pyi +7 -7
  6. metaflow-stubs/client/filecache.pyi +2 -2
  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 +6 -6
  11. metaflow-stubs/generated_for.txt +1 -1
  12. metaflow-stubs/includefile.pyi +5 -5
  13. metaflow-stubs/metadata/metadata.pyi +2 -2
  14. metaflow-stubs/metadata/util.pyi +2 -2
  15. metaflow-stubs/metaflow_config.pyi +2 -2
  16. metaflow-stubs/metaflow_current.pyi +17 -17
  17. metaflow-stubs/mflog/mflog.pyi +2 -2
  18. metaflow-stubs/multicore_utils.pyi +2 -2
  19. metaflow-stubs/parameters.pyi +2 -2
  20. metaflow-stubs/plugins/__init__.pyi +3 -3
  21. metaflow-stubs/plugins/airflow/__init__.pyi +2 -2
  22. metaflow-stubs/plugins/airflow/airflow.pyi +3 -3
  23. metaflow-stubs/plugins/airflow/airflow_cli.pyi +3 -3
  24. metaflow-stubs/plugins/airflow/airflow_decorator.pyi +2 -2
  25. metaflow-stubs/plugins/airflow/airflow_utils.pyi +2 -2
  26. metaflow-stubs/plugins/airflow/exception.pyi +2 -2
  27. metaflow-stubs/plugins/airflow/sensors/__init__.pyi +2 -2
  28. metaflow-stubs/plugins/airflow/sensors/base_sensor.pyi +2 -2
  29. metaflow-stubs/plugins/airflow/sensors/external_task_sensor.pyi +3 -3
  30. metaflow-stubs/plugins/airflow/sensors/s3_sensor.pyi +3 -3
  31. metaflow-stubs/plugins/argo/__init__.pyi +2 -2
  32. metaflow-stubs/plugins/argo/argo_client.pyi +2 -2
  33. metaflow-stubs/plugins/argo/argo_events.pyi +2 -2
  34. metaflow-stubs/plugins/argo/argo_workflows.pyi +3 -3
  35. metaflow-stubs/plugins/argo/argo_workflows_cli.pyi +3 -3
  36. metaflow-stubs/plugins/argo/argo_workflows_decorator.pyi +4 -4
  37. metaflow-stubs/plugins/aws/__init__.pyi +2 -2
  38. metaflow-stubs/plugins/aws/aws_client.pyi +2 -2
  39. metaflow-stubs/plugins/aws/aws_utils.pyi +2 -2
  40. metaflow-stubs/plugins/aws/batch/__init__.pyi +2 -2
  41. metaflow-stubs/plugins/aws/batch/batch.pyi +2 -2
  42. metaflow-stubs/plugins/aws/batch/batch_cli.pyi +2 -2
  43. metaflow-stubs/plugins/aws/batch/batch_client.pyi +2 -2
  44. metaflow-stubs/plugins/aws/batch/batch_decorator.pyi +3 -3
  45. metaflow-stubs/plugins/aws/secrets_manager/__init__.pyi +2 -2
  46. metaflow-stubs/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.pyi +3 -3
  47. metaflow-stubs/plugins/aws/step_functions/__init__.pyi +2 -2
  48. metaflow-stubs/plugins/aws/step_functions/dynamo_db_client.pyi +2 -2
  49. metaflow-stubs/plugins/aws/step_functions/event_bridge_client.pyi +2 -2
  50. metaflow-stubs/plugins/aws/step_functions/production_token.pyi +2 -2
  51. metaflow-stubs/plugins/aws/step_functions/schedule_decorator.pyi +2 -2
  52. metaflow-stubs/plugins/aws/step_functions/step_functions.pyi +2 -2
  53. metaflow-stubs/plugins/aws/step_functions/step_functions_cli.pyi +3 -3
  54. metaflow-stubs/plugins/aws/step_functions/step_functions_client.pyi +2 -2
  55. metaflow-stubs/plugins/aws/step_functions/step_functions_decorator.pyi +2 -2
  56. metaflow-stubs/plugins/azure/__init__.pyi +2 -2
  57. metaflow-stubs/plugins/azure/azure_credential.pyi +2 -2
  58. metaflow-stubs/plugins/azure/azure_exceptions.pyi +2 -2
  59. metaflow-stubs/plugins/azure/azure_secret_manager_secrets_provider.pyi +3 -3
  60. metaflow-stubs/plugins/azure/azure_utils.pyi +2 -2
  61. metaflow-stubs/plugins/azure/blob_service_client_factory.pyi +2 -2
  62. metaflow-stubs/plugins/azure/includefile_support.pyi +2 -2
  63. metaflow-stubs/plugins/cards/__init__.pyi +2 -2
  64. metaflow-stubs/plugins/cards/card_cli.pyi +5 -5
  65. metaflow-stubs/plugins/cards/card_client.pyi +3 -3
  66. metaflow-stubs/plugins/cards/card_creator.pyi +2 -2
  67. metaflow-stubs/plugins/cards/card_datastore.pyi +2 -2
  68. metaflow-stubs/plugins/cards/card_decorator.pyi +2 -2
  69. metaflow-stubs/plugins/cards/card_modules/__init__.pyi +2 -2
  70. metaflow-stubs/plugins/cards/card_modules/basic.pyi +2 -2
  71. metaflow-stubs/plugins/cards/card_modules/card.pyi +2 -2
  72. metaflow-stubs/plugins/cards/card_modules/chevron/__init__.pyi +2 -2
  73. metaflow-stubs/plugins/cards/card_modules/chevron/main.pyi +2 -2
  74. metaflow-stubs/plugins/cards/card_modules/chevron/metadata.pyi +2 -2
  75. metaflow-stubs/plugins/cards/card_modules/chevron/renderer.pyi +2 -2
  76. metaflow-stubs/plugins/cards/card_modules/chevron/tokenizer.pyi +2 -2
  77. metaflow-stubs/plugins/cards/card_modules/components.pyi +3 -3
  78. metaflow-stubs/plugins/cards/card_modules/convert_to_native_type.pyi +2 -2
  79. metaflow-stubs/plugins/cards/card_modules/renderer_tools.pyi +2 -2
  80. metaflow-stubs/plugins/cards/card_modules/test_cards.pyi +2 -2
  81. metaflow-stubs/plugins/cards/card_resolver.pyi +2 -2
  82. metaflow-stubs/plugins/cards/component_serializer.pyi +3 -3
  83. metaflow-stubs/plugins/cards/exception.pyi +2 -2
  84. metaflow-stubs/plugins/catch_decorator.pyi +3 -3
  85. metaflow-stubs/plugins/datatools/__init__.pyi +4 -4
  86. metaflow-stubs/plugins/datatools/local.pyi +2 -2
  87. metaflow-stubs/plugins/datatools/s3/__init__.pyi +3 -3
  88. metaflow-stubs/plugins/datatools/s3/s3.pyi +6 -6
  89. metaflow-stubs/plugins/datatools/s3/s3tail.pyi +2 -2
  90. metaflow-stubs/plugins/datatools/s3/s3util.pyi +2 -2
  91. metaflow-stubs/plugins/debug_logger.pyi +2 -2
  92. metaflow-stubs/plugins/debug_monitor.pyi +2 -2
  93. metaflow-stubs/plugins/environment_decorator.pyi +2 -2
  94. metaflow-stubs/plugins/events_decorator.pyi +2 -2
  95. metaflow-stubs/plugins/frameworks/__init__.pyi +2 -2
  96. metaflow-stubs/plugins/frameworks/pytorch.pyi +3 -3
  97. metaflow-stubs/plugins/gcp/__init__.pyi +2 -2
  98. metaflow-stubs/plugins/gcp/gcp_secret_manager_secrets_provider.pyi +3 -3
  99. metaflow-stubs/plugins/gcp/gs_exceptions.pyi +2 -2
  100. metaflow-stubs/plugins/gcp/gs_storage_client_factory.pyi +2 -2
  101. metaflow-stubs/plugins/gcp/gs_utils.pyi +2 -2
  102. metaflow-stubs/plugins/gcp/includefile_support.pyi +2 -2
  103. metaflow-stubs/plugins/kubernetes/__init__.pyi +2 -2
  104. metaflow-stubs/plugins/kubernetes/kubernetes.pyi +3 -3
  105. metaflow-stubs/plugins/kubernetes/kubernetes_cli.pyi +3 -3
  106. metaflow-stubs/plugins/kubernetes/kubernetes_client.pyi +2 -2
  107. metaflow-stubs/plugins/kubernetes/kubernetes_decorator.pyi +3 -3
  108. metaflow-stubs/plugins/kubernetes/kubernetes_jobsets.pyi +3 -3
  109. metaflow-stubs/plugins/logs_cli.pyi +3 -3
  110. metaflow-stubs/plugins/package_cli.pyi +2 -2
  111. metaflow-stubs/plugins/parallel_decorator.pyi +2 -2
  112. metaflow-stubs/plugins/perimeters.pyi +24 -0
  113. metaflow-stubs/plugins/project_decorator.pyi +2 -2
  114. metaflow-stubs/plugins/pypi/__init__.pyi +2 -2
  115. metaflow-stubs/plugins/pypi/conda_decorator.pyi +2 -2
  116. metaflow-stubs/plugins/pypi/conda_environment.pyi +4 -4
  117. metaflow-stubs/plugins/pypi/pypi_decorator.pyi +2 -2
  118. metaflow-stubs/plugins/pypi/pypi_environment.pyi +2 -2
  119. metaflow-stubs/plugins/pypi/utils.pyi +2 -2
  120. metaflow-stubs/plugins/resources_decorator.pyi +2 -2
  121. metaflow-stubs/plugins/retry_decorator.pyi +2 -2
  122. metaflow-stubs/plugins/secrets/__init__.pyi +2 -2
  123. metaflow-stubs/plugins/secrets/inline_secrets_provider.pyi +3 -3
  124. metaflow-stubs/plugins/secrets/secrets_decorator.pyi +2 -2
  125. metaflow-stubs/plugins/storage_executor.pyi +2 -2
  126. metaflow-stubs/plugins/tag_cli.pyi +5 -5
  127. metaflow-stubs/plugins/test_unbounded_foreach_decorator.pyi +2 -2
  128. metaflow-stubs/plugins/timeout_decorator.pyi +2 -2
  129. metaflow-stubs/procpoll.pyi +2 -2
  130. metaflow-stubs/profilers/__init__.pyi +2 -2
  131. metaflow-stubs/pylint_wrapper.pyi +2 -2
  132. metaflow-stubs/runner/__init__.pyi +2 -2
  133. metaflow-stubs/runner/metaflow_runner.pyi +4 -4
  134. metaflow-stubs/runner/nbrun.pyi +2 -2
  135. metaflow-stubs/runner/subprocess_manager.pyi +2 -2
  136. metaflow-stubs/system/__init__.pyi +3 -3
  137. metaflow-stubs/system/system_logger.pyi +3 -3
  138. metaflow-stubs/system/system_monitor.pyi +2 -2
  139. metaflow-stubs/tagging_util.pyi +2 -2
  140. metaflow-stubs/tuple_util.pyi +2 -2
  141. {ob_metaflow_stubs-4.2.dist-info → ob_metaflow_stubs-4.4.dist-info}/METADATA +1 -1
  142. ob_metaflow_stubs-4.4.dist-info/RECORD +145 -0
  143. ob_metaflow_stubs-4.2.dist-info/RECORD +0 -144
  144. {ob_metaflow_stubs-4.2.dist-info → ob_metaflow_stubs-4.4.dist-info}/WHEEL +0 -0
  145. {ob_metaflow_stubs-4.2.dist-info → ob_metaflow_stubs-4.4.dist-info}/top_level.txt +0 -0
@@ -1,25 +1,25 @@
1
1
  ##################################################################################
2
2
  # Auto-generated Metaflow stub file #
3
- # MF version: 2.12.7.1+nim(0.0.1);ob(v1) #
4
- # Generated on 2024-07-08T23:52:24.906750 #
3
+ # MF version: 2.12.7.1+ob(v1) #
4
+ # Generated on 2024-07-11T17:01:16.236498 #
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
11
  import metaflow.events
13
- import metaflow.metaflow_current
14
- import metaflow.parameters
15
- import metaflow.datastore.inputs
16
- import datetime
17
- import metaflow.flowspec
18
12
  import metaflow.client.core
13
+ import typing
14
+ import metaflow.flowspec
19
15
  import metaflow.plugins.datatools.s3.s3
16
+ import metaflow.parameters
20
17
  import metaflow.runner.metaflow_runner
21
- import typing
22
18
  import io
19
+ import metaflow._vendor.click.types
20
+ import datetime
21
+ import metaflow.datastore.inputs
22
+ import metaflow.metaflow_current
23
23
  FlowSpecDerived = typing.TypeVar("FlowSpecDerived", bound="FlowSpec", contravariant=False, covariant=False)
24
24
  StepFlag = typing.NewType("StepFlag", bool)
25
25
 
@@ -727,55 +727,6 @@ def step(f: typing.Union[typing.Callable[[FlowSpecDerived], None], typing.Callab
727
727
  """
728
728
  ...
729
729
 
730
- @typing.overload
731
- 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]]]:
732
- """
733
- Specifies that the step will success under all circumstances.
734
-
735
- The decorator will create an optional artifact, specified by `var`, which
736
- contains the exception raised. You can use it to detect the presence
737
- of errors, indicating that all happy-path artifacts produced by the step
738
- are missing.
739
-
740
- Parameters
741
- ----------
742
- var : str, optional, default None
743
- Name of the artifact in which to store the caught exception.
744
- If not specified, the exception is not stored.
745
- print_exception : bool, default True
746
- Determines whether or not the exception is printed to
747
- stdout when caught.
748
- """
749
- ...
750
-
751
- @typing.overload
752
- def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
753
- ...
754
-
755
- @typing.overload
756
- def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
757
- ...
758
-
759
- 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):
760
- """
761
- Specifies that the step will success under all circumstances.
762
-
763
- The decorator will create an optional artifact, specified by `var`, which
764
- contains the exception raised. You can use it to detect the presence
765
- of errors, indicating that all happy-path artifacts produced by the step
766
- are missing.
767
-
768
- Parameters
769
- ----------
770
- var : str, optional, default None
771
- Name of the artifact in which to store the caught exception.
772
- If not specified, the exception is not stored.
773
- print_exception : bool, default True
774
- Determines whether or not the exception is printed to
775
- stdout when caught.
776
- """
777
- ...
778
-
779
730
  @typing.overload
780
731
  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]]]:
781
732
  """
@@ -833,166 +784,60 @@ def conda(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
833
784
  """
834
785
  ...
835
786
 
836
- def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = "KUBERNETES_IMAGE_PULL_POLICY", service_account: str = "METAFLOW_KUBERNETES_SERVICE_ACCOUNT", secrets: typing.Optional[typing.List[str]] = None, namespace: str = "METAFLOW_KUBERNETES_NAMESPACE", gpu: typing.Optional[int] = None, gpu_vendor: str = "KUBERNETES_GPU_VENDOR", tolerations: typing.List[str] = [], use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = "/metaflow_temp", persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None) -> 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]]]:
837
- """
838
- Specifies that this step should execute on Kubernetes.
839
-
840
- Parameters
841
- ----------
842
- cpu : int, default 1
843
- Number of CPUs required for this step. If `@resources` is
844
- also present, the maximum value from all decorators is used.
845
- memory : int, default 4096
846
- Memory size (in MB) required for this step. If
847
- `@resources` is also present, the maximum value from all decorators is
848
- used.
849
- disk : int, default 10240
850
- Disk size (in MB) required for this step. If
851
- `@resources` is also present, the maximum value from all decorators is
852
- used.
853
- image : str, optional, default None
854
- Docker image to use when launching on Kubernetes. If not specified, and
855
- METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
856
- not, a default Docker image mapping to the current version of Python is used.
857
- image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
858
- If given, the imagePullPolicy to be applied to the Docker image of the step.
859
- service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
860
- Kubernetes service account to use when launching pod in Kubernetes.
861
- secrets : List[str], optional, default None
862
- Kubernetes secrets to use when launching pod in Kubernetes. These
863
- secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
864
- in Metaflow configuration.
865
- namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
866
- Kubernetes namespace to use when launching pod in Kubernetes.
867
- gpu : int, optional, default None
868
- Number of GPUs required for this step. A value of zero implies that
869
- the scheduled node should not have GPUs.
870
- gpu_vendor : str, default KUBERNETES_GPU_VENDOR
871
- The vendor of the GPUs to be used for this step.
872
- tolerations : List[str], default []
873
- The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
874
- Kubernetes tolerations to use when launching pod in Kubernetes.
875
- use_tmpfs : bool, default False
876
- This enables an explicit tmpfs mount for this step.
877
- tmpfs_tempdir : bool, default True
878
- sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
879
- tmpfs_size : int, optional, default: None
880
- The value for the size (in MiB) of the tmpfs mount for this step.
881
- This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
882
- memory allocated for this step.
883
- tmpfs_path : str, optional, default /metaflow_temp
884
- Path to tmpfs mount for this step.
885
- persistent_volume_claims : Dict[str, str], optional, default None
886
- A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
887
- volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
888
- shared_memory: int, optional
889
- Shared memory size (in MiB) required for this step
890
- port: int, optional
891
- Port number to specify in the Kubernetes job object
892
- """
893
- ...
894
-
895
787
  @typing.overload
896
- 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]]]:
788
+ 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]]]:
897
789
  """
898
- Specifies the number of times the task corresponding
899
- to a step needs to be retried.
790
+ Specifies a timeout for your step.
900
791
 
901
- This decorator is useful for handling transient errors, such as networking issues.
902
- If your task contains operations that can't be retried safely, e.g. database updates,
903
- it is advisable to annotate it with `@retry(times=0)`.
792
+ This decorator is useful if this step may hang indefinitely.
904
793
 
905
- This can be used in conjunction with the `@catch` decorator. The `@catch`
906
- decorator will execute a no-op task after all retries have been exhausted,
907
- ensuring that the flow execution can continue.
794
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
795
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
796
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
797
+
798
+ Note that all the values specified in parameters are added together so if you specify
799
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
908
800
 
909
801
  Parameters
910
802
  ----------
911
- times : int, default 3
912
- Number of times to retry this task.
913
- minutes_between_retries : int, default 2
914
- Number of minutes between retries.
803
+ seconds : int, default 0
804
+ Number of seconds to wait prior to timing out.
805
+ minutes : int, default 0
806
+ Number of minutes to wait prior to timing out.
807
+ hours : int, default 0
808
+ Number of hours to wait prior to timing out.
915
809
  """
916
810
  ...
917
811
 
918
812
  @typing.overload
919
- def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
813
+ def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
920
814
  ...
921
815
 
922
816
  @typing.overload
923
- def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
924
- ...
925
-
926
- 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):
927
- """
928
- Specifies the number of times the task corresponding
929
- to a step needs to be retried.
930
-
931
- This decorator is useful for handling transient errors, such as networking issues.
932
- If your task contains operations that can't be retried safely, e.g. database updates,
933
- it is advisable to annotate it with `@retry(times=0)`.
934
-
935
- This can be used in conjunction with the `@catch` decorator. The `@catch`
936
- decorator will execute a no-op task after all retries have been exhausted,
937
- ensuring that the flow execution can continue.
938
-
939
- Parameters
940
- ----------
941
- times : int, default 3
942
- Number of times to retry this task.
943
- minutes_between_retries : int, default 2
944
- Number of minutes between retries.
945
- """
817
+ def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
946
818
  ...
947
819
 
948
- @typing.overload
949
- 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]]]:
820
+ 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):
950
821
  """
951
- Creates a human-readable report, a Metaflow Card, after this step completes.
952
-
953
- Note that you may add multiple `@card` decorators in a step with different parameters.
954
-
955
- Parameters
956
- ----------
957
- type : str, default 'default'
958
- Card type.
959
- id : str, optional, default None
960
- If multiple cards are present, use this id to identify this card.
961
- options : Dict[str, Any], default {}
962
- Options passed to the card. The contents depend on the card type.
963
- timeout : int, default 45
964
- Interrupt reporting if it takes more than this many seconds.
822
+ Specifies a timeout for your step.
965
823
 
824
+ This decorator is useful if this step may hang indefinitely.
966
825
 
967
- """
968
- ...
969
-
970
- @typing.overload
971
- def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
972
- ...
973
-
974
- @typing.overload
975
- def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
976
- ...
977
-
978
- 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):
979
- """
980
- Creates a human-readable report, a Metaflow Card, after this step completes.
826
+ This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
827
+ A timeout is considered to be an exception thrown by the step. It will cause the step to be
828
+ retried if needed and the exception will be caught by the `@catch` decorator, if present.
981
829
 
982
- Note that you may add multiple `@card` decorators in a step with different parameters.
830
+ Note that all the values specified in parameters are added together so if you specify
831
+ 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
983
832
 
984
833
  Parameters
985
834
  ----------
986
- type : str, default 'default'
987
- Card type.
988
- id : str, optional, default None
989
- If multiple cards are present, use this id to identify this card.
990
- options : Dict[str, Any], default {}
991
- Options passed to the card. The contents depend on the card type.
992
- timeout : int, default 45
993
- Interrupt reporting if it takes more than this many seconds.
994
-
995
-
835
+ seconds : int, default 0
836
+ Number of seconds to wait prior to timing out.
837
+ minutes : int, default 0
838
+ Number of minutes to wait prior to timing out.
839
+ hours : int, default 0
840
+ Number of hours to wait prior to timing out.
996
841
  """
997
842
  ...
998
843
 
@@ -1030,149 +875,15 @@ def secrets(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None],
1030
875
  ...
1031
876
 
1032
877
  @typing.overload
1033
- 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]]]:
878
+ def batch(*, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = "METAFLOW_BATCH_JOB_QUEUE", iam_role: str = "METAFLOW_ECS_S3_ACCESS_IAM_ROLE", execution_role: str = "METAFLOW_ECS_FARGATE_EXECUTION_ROLE", shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
1034
879
  """
1035
- Specifies the resources needed when executing this step.
1036
-
1037
- Use `@resources` to specify the resource requirements
1038
- independently of the specific compute layer (`@batch`, `@kubernetes`).
1039
-
1040
- You can choose the compute layer on the command line by executing e.g.
1041
- ```
1042
- python myflow.py run --with batch
1043
- ```
1044
- or
1045
- ```
1046
- python myflow.py run --with kubernetes
1047
- ```
1048
- which executes the flow on the desired system using the
1049
- requirements specified in `@resources`.
880
+ Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
1050
881
 
1051
882
  Parameters
1052
883
  ----------
1053
884
  cpu : int, default 1
1054
- Number of CPUs required for this step.
1055
- gpu : int, default 0
1056
- Number of GPUs required for this step.
1057
- disk : int, optional, default None
1058
- Disk size (in MB) required for this step. Only applies on Kubernetes.
1059
- memory : int, default 4096
1060
- Memory size (in MB) required for this step.
1061
- shared_memory : int, optional, default None
1062
- The value for the size (in MiB) of the /dev/shm volume for this step.
1063
- This parameter maps to the `--shm-size` option in Docker.
1064
- """
1065
- ...
1066
-
1067
- @typing.overload
1068
- def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1069
- ...
1070
-
1071
- @typing.overload
1072
- def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1073
- ...
1074
-
1075
- 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):
1076
- """
1077
- Specifies the resources needed when executing this step.
1078
-
1079
- Use `@resources` to specify the resource requirements
1080
- independently of the specific compute layer (`@batch`, `@kubernetes`).
1081
-
1082
- You can choose the compute layer on the command line by executing e.g.
1083
- ```
1084
- python myflow.py run --with batch
1085
- ```
1086
- or
1087
- ```
1088
- python myflow.py run --with kubernetes
1089
- ```
1090
- which executes the flow on the desired system using the
1091
- requirements specified in `@resources`.
1092
-
1093
- Parameters
1094
- ----------
1095
- cpu : int, default 1
1096
- Number of CPUs required for this step.
1097
- gpu : int, default 0
1098
- Number of GPUs required for this step.
1099
- disk : int, optional, default None
1100
- Disk size (in MB) required for this step. Only applies on Kubernetes.
1101
- memory : int, default 4096
1102
- Memory size (in MB) required for this step.
1103
- shared_memory : int, optional, default None
1104
- The value for the size (in MiB) of the /dev/shm volume for this step.
1105
- This parameter maps to the `--shm-size` option in Docker.
1106
- """
1107
- ...
1108
-
1109
- @typing.overload
1110
- 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]]]:
1111
- """
1112
- Specifies a timeout for your step.
1113
-
1114
- This decorator is useful if this step may hang indefinitely.
1115
-
1116
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
1117
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
1118
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
1119
-
1120
- Note that all the values specified in parameters are added together so if you specify
1121
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
1122
-
1123
- Parameters
1124
- ----------
1125
- seconds : int, default 0
1126
- Number of seconds to wait prior to timing out.
1127
- minutes : int, default 0
1128
- Number of minutes to wait prior to timing out.
1129
- hours : int, default 0
1130
- Number of hours to wait prior to timing out.
1131
- """
1132
- ...
1133
-
1134
- @typing.overload
1135
- def timeout(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1136
- ...
1137
-
1138
- @typing.overload
1139
- def timeout(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1140
- ...
1141
-
1142
- 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):
1143
- """
1144
- Specifies a timeout for your step.
1145
-
1146
- This decorator is useful if this step may hang indefinitely.
1147
-
1148
- This can be used in conjunction with the `@retry` decorator as well as the `@catch` decorator.
1149
- A timeout is considered to be an exception thrown by the step. It will cause the step to be
1150
- retried if needed and the exception will be caught by the `@catch` decorator, if present.
1151
-
1152
- Note that all the values specified in parameters are added together so if you specify
1153
- 60 seconds and 1 hour, the decorator will have an effective timeout of 1 hour and 1 minute.
1154
-
1155
- Parameters
1156
- ----------
1157
- seconds : int, default 0
1158
- Number of seconds to wait prior to timing out.
1159
- minutes : int, default 0
1160
- Number of minutes to wait prior to timing out.
1161
- hours : int, default 0
1162
- Number of hours to wait prior to timing out.
1163
- """
1164
- ...
1165
-
1166
- @typing.overload
1167
- def batch(*, cpu: int = 1, gpu: int = 0, memory: int = 4096, image: typing.Optional[str] = None, queue: str = "METAFLOW_BATCH_JOB_QUEUE", iam_role: str = "METAFLOW_ECS_S3_ACCESS_IAM_ROLE", execution_role: str = "METAFLOW_ECS_FARGATE_EXECUTION_ROLE", shared_memory: typing.Optional[int] = None, max_swap: typing.Optional[int] = None, swappiness: typing.Optional[int] = None, use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = None, inferentia: int = 0, trainium: int = None, efa: int = 0, ephemeral_storage: int = None, log_driver: typing.Optional[str] = None, log_options: typing.Optional[typing.List[str]] = None) -> typing.Callable[[typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]], typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]]]:
1168
- """
1169
- Specifies that this step should execute on [AWS Batch](https://aws.amazon.com/batch/).
1170
-
1171
- Parameters
1172
- ----------
1173
- cpu : int, default 1
1174
- Number of CPUs required for this step. If `@resources` is
1175
- also present, the maximum value from all decorators is used.
885
+ Number of CPUs required for this step. If `@resources` is
886
+ also present, the maximum value from all decorators is used.
1176
887
  gpu : int, default 0
1177
888
  Number of GPUs required for this step. If `@resources` is
1178
889
  also present, the maximum value from all decorators is used.
@@ -1310,6 +1021,65 @@ def batch(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], None], ty
1310
1021
  """
1311
1022
  ...
1312
1023
 
1024
+ def kubernetes(*, cpu: int = 1, memory: int = 4096, disk: int = 10240, image: typing.Optional[str] = None, image_pull_policy: str = "KUBERNETES_IMAGE_PULL_POLICY", service_account: str = "METAFLOW_KUBERNETES_SERVICE_ACCOUNT", secrets: typing.Optional[typing.List[str]] = None, namespace: str = "METAFLOW_KUBERNETES_NAMESPACE", gpu: typing.Optional[int] = None, gpu_vendor: str = "KUBERNETES_GPU_VENDOR", tolerations: typing.List[str] = [], use_tmpfs: bool = False, tmpfs_tempdir: bool = True, tmpfs_size: typing.Optional[int] = None, tmpfs_path: typing.Optional[str] = "/metaflow_temp", persistent_volume_claims: typing.Optional[typing.Dict[str, str]] = None, shared_memory: typing.Optional[int] = None, port: typing.Optional[int] = None) -> 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]]]:
1025
+ """
1026
+ Specifies that this step should execute on Kubernetes.
1027
+
1028
+ Parameters
1029
+ ----------
1030
+ cpu : int, default 1
1031
+ Number of CPUs required for this step. If `@resources` is
1032
+ also present, the maximum value from all decorators is used.
1033
+ memory : int, default 4096
1034
+ Memory size (in MB) required for this step. If
1035
+ `@resources` is also present, the maximum value from all decorators is
1036
+ used.
1037
+ disk : int, default 10240
1038
+ Disk size (in MB) required for this step. If
1039
+ `@resources` is also present, the maximum value from all decorators is
1040
+ used.
1041
+ image : str, optional, default None
1042
+ Docker image to use when launching on Kubernetes. If not specified, and
1043
+ METAFLOW_KUBERNETES_CONTAINER_IMAGE is specified, that image is used. If
1044
+ not, a default Docker image mapping to the current version of Python is used.
1045
+ image_pull_policy: str, default KUBERNETES_IMAGE_PULL_POLICY
1046
+ If given, the imagePullPolicy to be applied to the Docker image of the step.
1047
+ service_account : str, default METAFLOW_KUBERNETES_SERVICE_ACCOUNT
1048
+ Kubernetes service account to use when launching pod in Kubernetes.
1049
+ secrets : List[str], optional, default None
1050
+ Kubernetes secrets to use when launching pod in Kubernetes. These
1051
+ secrets are in addition to the ones defined in `METAFLOW_KUBERNETES_SECRETS`
1052
+ in Metaflow configuration.
1053
+ namespace : str, default METAFLOW_KUBERNETES_NAMESPACE
1054
+ Kubernetes namespace to use when launching pod in Kubernetes.
1055
+ gpu : int, optional, default None
1056
+ Number of GPUs required for this step. A value of zero implies that
1057
+ the scheduled node should not have GPUs.
1058
+ gpu_vendor : str, default KUBERNETES_GPU_VENDOR
1059
+ The vendor of the GPUs to be used for this step.
1060
+ tolerations : List[str], default []
1061
+ The default is extracted from METAFLOW_KUBERNETES_TOLERATIONS.
1062
+ Kubernetes tolerations to use when launching pod in Kubernetes.
1063
+ use_tmpfs : bool, default False
1064
+ This enables an explicit tmpfs mount for this step.
1065
+ tmpfs_tempdir : bool, default True
1066
+ sets METAFLOW_TEMPDIR to tmpfs_path if set for this step.
1067
+ tmpfs_size : int, optional, default: None
1068
+ The value for the size (in MiB) of the tmpfs mount for this step.
1069
+ This parameter maps to the `--tmpfs` option in Docker. Defaults to 50% of the
1070
+ memory allocated for this step.
1071
+ tmpfs_path : str, optional, default /metaflow_temp
1072
+ Path to tmpfs mount for this step.
1073
+ persistent_volume_claims : Dict[str, str], optional, default None
1074
+ A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
1075
+ volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
1076
+ shared_memory: int, optional
1077
+ Shared memory size (in MiB) required for this step
1078
+ port: int, optional
1079
+ Port number to specify in the Kubernetes job object
1080
+ """
1081
+ ...
1082
+
1313
1083
  @typing.overload
1314
1084
  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]]]:
1315
1085
  """
@@ -1342,344 +1112,338 @@ def environment(f: typing.Union[typing.Callable[[FlowSpecDerived, StepFlag], Non
1342
1112
  ...
1343
1113
 
1344
1114
  @typing.overload
1345
- 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]]]:
1115
+ 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]]]:
1346
1116
  """
1347
- Specifies the PyPI packages for the step.
1117
+ Specifies the resources needed when executing this step.
1348
1118
 
1349
- Information in this decorator will augment any
1350
- attributes set in the `@pyi_base` flow-level decorator. Hence,
1351
- you can use `@pypi_base` to set packages required by all
1352
- steps and use `@pypi` to specify step-specific overrides.
1119
+ Use `@resources` to specify the resource requirements
1120
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
1121
+
1122
+ You can choose the compute layer on the command line by executing e.g.
1123
+ ```
1124
+ python myflow.py run --with batch
1125
+ ```
1126
+ or
1127
+ ```
1128
+ python myflow.py run --with kubernetes
1129
+ ```
1130
+ which executes the flow on the desired system using the
1131
+ requirements specified in `@resources`.
1353
1132
 
1354
1133
  Parameters
1355
1134
  ----------
1356
- packages : Dict[str, str], default: {}
1357
- Packages to use for this step. The key is the name of the package
1358
- and the value is the version to use.
1359
- python : str, optional, default: None
1360
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1361
- that the version used will correspond to the version of the Python interpreter used to start the run.
1135
+ cpu : int, default 1
1136
+ Number of CPUs required for this step.
1137
+ gpu : int, default 0
1138
+ Number of GPUs required for this step.
1139
+ disk : int, optional, default None
1140
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
1141
+ memory : int, default 4096
1142
+ Memory size (in MB) required for this step.
1143
+ shared_memory : int, optional, default None
1144
+ The value for the size (in MiB) of the /dev/shm volume for this step.
1145
+ This parameter maps to the `--shm-size` option in Docker.
1362
1146
  """
1363
1147
  ...
1364
1148
 
1365
1149
  @typing.overload
1366
- def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1150
+ def resources(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1367
1151
  ...
1368
1152
 
1369
1153
  @typing.overload
1370
- def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1154
+ def resources(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1371
1155
  ...
1372
1156
 
1373
- 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):
1157
+ 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):
1374
1158
  """
1375
- Specifies the PyPI packages for the step.
1376
-
1377
- Information in this decorator will augment any
1378
- attributes set in the `@pyi_base` flow-level decorator. Hence,
1379
- you can use `@pypi_base` to set packages required by all
1380
- steps and use `@pypi` to specify step-specific overrides.
1159
+ Specifies the resources needed when executing this step.
1381
1160
 
1382
- Parameters
1383
- ----------
1384
- packages : Dict[str, str], default: {}
1385
- Packages to use for this step. The key is the name of the package
1386
- and the value is the version to use.
1387
- python : str, optional, default: None
1388
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1389
- that the version used will correspond to the version of the Python interpreter used to start the run.
1390
- """
1391
- ...
1392
-
1393
- @typing.overload
1394
- def trigger_on_finish(*, flow: typing.Union[str, typing.Dict[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]]:
1395
- """
1396
- Specifies the flow(s) that this flow depends on.
1161
+ Use `@resources` to specify the resource requirements
1162
+ independently of the specific compute layer (`@batch`, `@kubernetes`).
1397
1163
 
1164
+ You can choose the compute layer on the command line by executing e.g.
1398
1165
  ```
1399
- @trigger_on_finish(flow='FooFlow')
1166
+ python myflow.py run --with batch
1400
1167
  ```
1401
1168
  or
1402
1169
  ```
1403
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1170
+ python myflow.py run --with kubernetes
1404
1171
  ```
1405
- This decorator respects the @project decorator and triggers the flow
1406
- when upstream runs within the same namespace complete successfully
1172
+ which executes the flow on the desired system using the
1173
+ requirements specified in `@resources`.
1407
1174
 
1408
- Additionally, you can specify project aware upstream flow dependencies
1409
- by specifying the fully qualified project_flow_name.
1410
- ```
1411
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1412
- ```
1413
- or
1414
- ```
1415
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1416
- ```
1175
+ Parameters
1176
+ ----------
1177
+ cpu : int, default 1
1178
+ Number of CPUs required for this step.
1179
+ gpu : int, default 0
1180
+ Number of GPUs required for this step.
1181
+ disk : int, optional, default None
1182
+ Disk size (in MB) required for this step. Only applies on Kubernetes.
1183
+ memory : int, default 4096
1184
+ Memory size (in MB) required for this step.
1185
+ shared_memory : int, optional, default None
1186
+ The value for the size (in MiB) of the /dev/shm volume for this step.
1187
+ This parameter maps to the `--shm-size` option in Docker.
1188
+ """
1189
+ ...
1190
+
1191
+ @typing.overload
1192
+ 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]]]:
1193
+ """
1194
+ Specifies that the step will success under all circumstances.
1417
1195
 
1418
- You can also specify just the project or project branch (other values will be
1419
- inferred from the current project or project branch):
1420
- ```
1421
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1422
- ```
1196
+ The decorator will create an optional artifact, specified by `var`, which
1197
+ contains the exception raised. You can use it to detect the presence
1198
+ of errors, indicating that all happy-path artifacts produced by the step
1199
+ are missing.
1423
1200
 
1424
- Note that `branch` is typically one of:
1425
- - `prod`
1426
- - `user.bob`
1427
- - `test.my_experiment`
1428
- - `prod.staging`
1201
+ Parameters
1202
+ ----------
1203
+ var : str, optional, default None
1204
+ Name of the artifact in which to store the caught exception.
1205
+ If not specified, the exception is not stored.
1206
+ print_exception : bool, default True
1207
+ Determines whether or not the exception is printed to
1208
+ stdout when caught.
1209
+ """
1210
+ ...
1211
+
1212
+ @typing.overload
1213
+ def catch(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1214
+ ...
1215
+
1216
+ @typing.overload
1217
+ def catch(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1218
+ ...
1219
+
1220
+ 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):
1221
+ """
1222
+ Specifies that the step will success under all circumstances.
1223
+
1224
+ The decorator will create an optional artifact, specified by `var`, which
1225
+ contains the exception raised. You can use it to detect the presence
1226
+ of errors, indicating that all happy-path artifacts produced by the step
1227
+ are missing.
1429
1228
 
1430
1229
  Parameters
1431
1230
  ----------
1432
- flow : Union[str, Dict[str, str]], optional, default None
1433
- Upstream flow dependency for this flow.
1434
- flows : List[Union[str, Dict[str, str]]], default []
1435
- Upstream flow dependencies for this flow.
1231
+ var : str, optional, default None
1232
+ Name of the artifact in which to store the caught exception.
1233
+ If not specified, the exception is not stored.
1234
+ print_exception : bool, default True
1235
+ Determines whether or not the exception is printed to
1236
+ stdout when caught.
1237
+ """
1238
+ ...
1239
+
1240
+ @typing.overload
1241
+ 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]]]:
1242
+ """
1243
+ Creates a human-readable report, a Metaflow Card, after this step completes.
1244
+
1245
+ Note that you may add multiple `@card` decorators in a step with different parameters.
1246
+
1247
+ Parameters
1248
+ ----------
1249
+ type : str, default 'default'
1250
+ Card type.
1251
+ id : str, optional, default None
1252
+ If multiple cards are present, use this id to identify this card.
1436
1253
  options : Dict[str, Any], default {}
1437
- Backend-specific configuration for tuning eventing behavior.
1254
+ Options passed to the card. The contents depend on the card type.
1255
+ timeout : int, default 45
1256
+ Interrupt reporting if it takes more than this many seconds.
1438
1257
 
1439
1258
 
1440
1259
  """
1441
1260
  ...
1442
1261
 
1443
1262
  @typing.overload
1444
- def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1263
+ def card(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1445
1264
  ...
1446
1265
 
1447
- def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[str, typing.Dict[str, str], None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1266
+ @typing.overload
1267
+ def card(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1268
+ ...
1269
+
1270
+ 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):
1448
1271
  """
1449
- Specifies the flow(s) that this flow depends on.
1450
-
1451
- ```
1452
- @trigger_on_finish(flow='FooFlow')
1453
- ```
1454
- or
1455
- ```
1456
- @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1457
- ```
1458
- This decorator respects the @project decorator and triggers the flow
1459
- when upstream runs within the same namespace complete successfully
1460
-
1461
- Additionally, you can specify project aware upstream flow dependencies
1462
- by specifying the fully qualified project_flow_name.
1463
- ```
1464
- @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1465
- ```
1466
- or
1467
- ```
1468
- @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1469
- ```
1470
-
1471
- You can also specify just the project or project branch (other values will be
1472
- inferred from the current project or project branch):
1473
- ```
1474
- @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1475
- ```
1272
+ Creates a human-readable report, a Metaflow Card, after this step completes.
1476
1273
 
1477
- Note that `branch` is typically one of:
1478
- - `prod`
1479
- - `user.bob`
1480
- - `test.my_experiment`
1481
- - `prod.staging`
1274
+ Note that you may add multiple `@card` decorators in a step with different parameters.
1482
1275
 
1483
1276
  Parameters
1484
1277
  ----------
1485
- flow : Union[str, Dict[str, str]], optional, default None
1486
- Upstream flow dependency for this flow.
1487
- flows : List[Union[str, Dict[str, str]]], default []
1488
- Upstream flow dependencies for this flow.
1278
+ type : str, default 'default'
1279
+ Card type.
1280
+ id : str, optional, default None
1281
+ If multiple cards are present, use this id to identify this card.
1489
1282
  options : Dict[str, Any], default {}
1490
- Backend-specific configuration for tuning eventing behavior.
1283
+ Options passed to the card. The contents depend on the card type.
1284
+ timeout : int, default 45
1285
+ Interrupt reporting if it takes more than this many seconds.
1491
1286
 
1492
1287
 
1493
1288
  """
1494
1289
  ...
1495
1290
 
1496
1291
  @typing.overload
1497
- def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1292
+ 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]]]:
1498
1293
  """
1499
- Specifies the PyPI packages for all steps of the flow.
1294
+ Specifies the number of times the task corresponding
1295
+ to a step needs to be retried.
1296
+
1297
+ This decorator is useful for handling transient errors, such as networking issues.
1298
+ If your task contains operations that can't be retried safely, e.g. database updates,
1299
+ it is advisable to annotate it with `@retry(times=0)`.
1300
+
1301
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
1302
+ decorator will execute a no-op task after all retries have been exhausted,
1303
+ ensuring that the flow execution can continue.
1500
1304
 
1501
- Use `@pypi_base` to set common packages required by all
1502
- steps and use `@pypi` to specify step-specific overrides.
1503
1305
  Parameters
1504
1306
  ----------
1505
- packages : Dict[str, str], default: {}
1506
- Packages to use for this flow. The key is the name of the package
1507
- and the value is the version to use.
1508
- python : str, optional, default: None
1509
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1510
- that the version used will correspond to the version of the Python interpreter used to start the run.
1307
+ times : int, default 3
1308
+ Number of times to retry this task.
1309
+ minutes_between_retries : int, default 2
1310
+ Number of minutes between retries.
1511
1311
  """
1512
1312
  ...
1513
1313
 
1514
1314
  @typing.overload
1515
- def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1315
+ def retry(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1516
1316
  ...
1517
1317
 
1518
- def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1318
+ @typing.overload
1319
+ def retry(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1320
+ ...
1321
+
1322
+ 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):
1519
1323
  """
1520
- Specifies the PyPI packages for all steps of the flow.
1324
+ Specifies the number of times the task corresponding
1325
+ to a step needs to be retried.
1326
+
1327
+ This decorator is useful for handling transient errors, such as networking issues.
1328
+ If your task contains operations that can't be retried safely, e.g. database updates,
1329
+ it is advisable to annotate it with `@retry(times=0)`.
1330
+
1331
+ This can be used in conjunction with the `@catch` decorator. The `@catch`
1332
+ decorator will execute a no-op task after all retries have been exhausted,
1333
+ ensuring that the flow execution can continue.
1521
1334
 
1522
- Use `@pypi_base` to set common packages required by all
1523
- steps and use `@pypi` to specify step-specific overrides.
1524
1335
  Parameters
1525
1336
  ----------
1526
- packages : Dict[str, str], default: {}
1527
- Packages to use for this flow. The key is the name of the package
1528
- and the value is the version to use.
1529
- python : str, optional, default: None
1530
- Version of Python to use, e.g. '3.7.4'. A default value of None implies
1531
- that the version used will correspond to the version of the Python interpreter used to start the run.
1337
+ times : int, default 3
1338
+ Number of times to retry this task.
1339
+ minutes_between_retries : int, default 2
1340
+ Number of minutes between retries.
1532
1341
  """
1533
1342
  ...
1534
1343
 
1535
- def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1344
+ @typing.overload
1345
+ 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]]]:
1536
1346
  """
1537
- Specifies what flows belong to the same project.
1347
+ Specifies the PyPI packages for the step.
1538
1348
 
1539
- A project-specific namespace is created for all flows that
1540
- use the same `@project(name)`.
1349
+ Information in this decorator will augment any
1350
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
1351
+ you can use `@pypi_base` to set packages required by all
1352
+ steps and use `@pypi` to specify step-specific overrides.
1541
1353
 
1542
1354
  Parameters
1543
1355
  ----------
1544
- name : str
1545
- Project name. Make sure that the name is unique amongst all
1546
- projects that use the same production scheduler. The name may
1547
- contain only lowercase alphanumeric characters and underscores.
1548
-
1549
-
1356
+ packages : Dict[str, str], default: {}
1357
+ Packages to use for this step. The key is the name of the package
1358
+ and the value is the version to use.
1359
+ python : str, optional, default: None
1360
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1361
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1550
1362
  """
1551
1363
  ...
1552
1364
 
1553
- 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]]:
1365
+ @typing.overload
1366
+ def pypi(f: typing.Callable[[FlowSpecDerived, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, StepFlag], None]:
1367
+ ...
1368
+
1369
+ @typing.overload
1370
+ def pypi(f: typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]) -> typing.Callable[[FlowSpecDerived, typing.Any, StepFlag], None]:
1371
+ ...
1372
+
1373
+ 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):
1554
1374
  """
1555
- 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)
1556
- before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1557
- and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1558
- added as a flow decorators. Adding more than one decorator will ensure that `start` step
1559
- starts only after all sensors finish.
1375
+ Specifies the PyPI packages for the step.
1376
+
1377
+ Information in this decorator will augment any
1378
+ attributes set in the `@pyi_base` flow-level decorator. Hence,
1379
+ you can use `@pypi_base` to set packages required by all
1380
+ steps and use `@pypi` to specify step-specific overrides.
1560
1381
 
1561
1382
  Parameters
1562
1383
  ----------
1563
- timeout : int
1564
- Time, in seconds before the task times out and fails. (Default: 3600)
1565
- poke_interval : int
1566
- Time in seconds that the job should wait in between each try. (Default: 60)
1567
- mode : str
1568
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1569
- exponential_backoff : bool
1570
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1571
- pool : str
1572
- the slot pool this task should run in,
1573
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1574
- soft_fail : bool
1575
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1576
- name : str
1577
- Name of the sensor on Airflow
1578
- description : str
1579
- Description of sensor in the Airflow UI
1580
- bucket_key : Union[str, List[str]]
1581
- The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1582
- When it's specified as a full s3:// url, please leave `bucket_name` as None
1583
- bucket_name : str
1584
- Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1585
- When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1586
- wildcard_match : bool
1587
- whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1588
- aws_conn_id : str
1589
- a reference to the s3 connection on Airflow. (Default: None)
1590
- verify : bool
1591
- Whether or not to verify SSL certificates for S3 connection. (Default: None)
1384
+ packages : Dict[str, str], default: {}
1385
+ Packages to use for this step. The key is the name of the package
1386
+ and the value is the version to use.
1387
+ python : str, optional, default: None
1388
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1389
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1592
1390
  """
1593
1391
  ...
1594
1392
 
1595
1393
  @typing.overload
1596
- def schedule(*, hourly: bool = False, daily: bool = True, weekly: bool = False, cron: typing.Optional[str] = None, timezone: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1394
+ def pypi_base(*, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1597
1395
  """
1598
- Specifies the times when the flow should be run when running on a
1599
- production scheduler.
1396
+ Specifies the PyPI packages for all steps of the flow.
1600
1397
 
1398
+ Use `@pypi_base` to set common packages required by all
1399
+ steps and use `@pypi` to specify step-specific overrides.
1601
1400
  Parameters
1602
1401
  ----------
1603
- hourly : bool, default False
1604
- Run the workflow hourly.
1605
- daily : bool, default True
1606
- Run the workflow daily.
1607
- weekly : bool, default False
1608
- Run the workflow weekly.
1609
- cron : str, optional, default None
1610
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1611
- specified by this expression.
1612
- timezone : str, optional, default None
1613
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1614
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1402
+ packages : Dict[str, str], default: {}
1403
+ Packages to use for this flow. The key is the name of the package
1404
+ and the value is the version to use.
1405
+ python : str, optional, default: None
1406
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1407
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1615
1408
  """
1616
1409
  ...
1617
1410
 
1618
1411
  @typing.overload
1619
- def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1412
+ def pypi_base(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1620
1413
  ...
1621
1414
 
1622
- 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):
1415
+ def pypi_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packages: typing.Dict[str, str] = {}, python: typing.Optional[str] = None):
1623
1416
  """
1624
- Specifies the times when the flow should be run when running on a
1625
- production scheduler.
1417
+ Specifies the PyPI packages for all steps of the flow.
1626
1418
 
1419
+ Use `@pypi_base` to set common packages required by all
1420
+ steps and use `@pypi` to specify step-specific overrides.
1627
1421
  Parameters
1628
1422
  ----------
1629
- hourly : bool, default False
1630
- Run the workflow hourly.
1631
- daily : bool, default True
1632
- Run the workflow daily.
1633
- weekly : bool, default False
1634
- Run the workflow weekly.
1635
- cron : str, optional, default None
1636
- Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1637
- specified by this expression.
1638
- timezone : str, optional, default None
1639
- Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1640
- which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1423
+ packages : Dict[str, str], default: {}
1424
+ Packages to use for this flow. The key is the name of the package
1425
+ and the value is the version to use.
1426
+ python : str, optional, default: None
1427
+ Version of Python to use, e.g. '3.7.4'. A default value of None implies
1428
+ that the version used will correspond to the version of the Python interpreter used to start the run.
1641
1429
  """
1642
1430
  ...
1643
1431
 
1644
- 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]]:
1432
+ def project(*, name: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1645
1433
  """
1646
- 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.
1647
- 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.
1434
+ Specifies what flows belong to the same project.
1435
+
1436
+ A project-specific namespace is created for all flows that
1437
+ use the same `@project(name)`.
1438
+
1439
+ Parameters
1440
+ ----------
1441
+ name : str
1442
+ Project name. Make sure that the name is unique amongst all
1443
+ projects that use the same production scheduler. The name may
1444
+ contain only lowercase alphanumeric characters and underscores.
1445
+
1648
1446
 
1649
- Parameters
1650
- ----------
1651
- timeout : int
1652
- Time, in seconds before the task times out and fails. (Default: 3600)
1653
- poke_interval : int
1654
- Time in seconds that the job should wait in between each try. (Default: 60)
1655
- mode : str
1656
- How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1657
- exponential_backoff : bool
1658
- allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1659
- pool : str
1660
- the slot pool this task should run in,
1661
- slot pools are a way to limit concurrency for certain tasks. (Default:None)
1662
- soft_fail : bool
1663
- Set to true to mark the task as SKIPPED on failure. (Default: False)
1664
- name : str
1665
- Name of the sensor on Airflow
1666
- description : str
1667
- Description of sensor in the Airflow UI
1668
- external_dag_id : str
1669
- The dag_id that contains the task you want to wait for.
1670
- external_task_ids : List[str]
1671
- The list of task_ids that you want to wait for.
1672
- If None (default value) the sensor waits for the DAG. (Default: None)
1673
- allowed_states : List[str]
1674
- Iterable of allowed states, (Default: ['success'])
1675
- failed_states : List[str]
1676
- Iterable of failed or dis-allowed states. (Default: None)
1677
- execution_delta : datetime.timedelta
1678
- time difference with the previous execution to look at,
1679
- the default is the same logical date as the current task or DAG. (Default: None)
1680
- check_existence: bool
1681
- Set to True to check if the external task exists or check if
1682
- the DAG to wait for exists. (Default: True)
1683
1447
  """
1684
1448
  ...
1685
1449
 
@@ -1732,6 +1496,90 @@ def conda_base(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, packa
1732
1496
  """
1733
1497
  ...
1734
1498
 
1499
+ 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]]:
1500
+ """
1501
+ 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.
1502
+ 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.
1503
+
1504
+ Parameters
1505
+ ----------
1506
+ timeout : int
1507
+ Time, in seconds before the task times out and fails. (Default: 3600)
1508
+ poke_interval : int
1509
+ Time in seconds that the job should wait in between each try. (Default: 60)
1510
+ mode : str
1511
+ How the sensor operates. Options are: { poke | reschedule }. (Default: "poke")
1512
+ exponential_backoff : bool
1513
+ allow progressive longer waits between pokes by using exponential backoff algorithm. (Default: True)
1514
+ pool : str
1515
+ the slot pool this task should run in,
1516
+ slot pools are a way to limit concurrency for certain tasks. (Default:None)
1517
+ soft_fail : bool
1518
+ Set to true to mark the task as SKIPPED on failure. (Default: False)
1519
+ name : str
1520
+ Name of the sensor on Airflow
1521
+ description : str
1522
+ Description of sensor in the Airflow UI
1523
+ external_dag_id : str
1524
+ The dag_id that contains the task you want to wait for.
1525
+ external_task_ids : List[str]
1526
+ The list of task_ids that you want to wait for.
1527
+ If None (default value) the sensor waits for the DAG. (Default: None)
1528
+ allowed_states : List[str]
1529
+ Iterable of allowed states, (Default: ['success'])
1530
+ failed_states : List[str]
1531
+ Iterable of failed or dis-allowed states. (Default: None)
1532
+ execution_delta : datetime.timedelta
1533
+ time difference with the previous execution to look at,
1534
+ the default is the same logical date as the current task or DAG. (Default: None)
1535
+ check_existence: bool
1536
+ Set to True to check if the external task exists or check if
1537
+ the DAG to wait for exists. (Default: True)
1538
+ """
1539
+ ...
1540
+
1541
+ 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]]:
1542
+ """
1543
+ 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)
1544
+ before the start step of the flow. This decorator only works when a flow is scheduled on Airflow
1545
+ and is compiled using `airflow create`. More than one `@airflow_s3_key_sensor` can be
1546
+ added as a flow decorators. Adding more than one decorator will ensure that `start` step
1547
+ starts only after all sensors finish.
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
+ bucket_key : Union[str, List[str]]
1569
+ The key(s) being waited on. Supports full s3:// style url or relative path from root level.
1570
+ When it's specified as a full s3:// url, please leave `bucket_name` as None
1571
+ bucket_name : str
1572
+ Name of the S3 bucket. Only needed when bucket_key is not provided as a full s3:// url.
1573
+ When specified, all the keys passed to bucket_key refers to this bucket. (Default:None)
1574
+ wildcard_match : bool
1575
+ whether the bucket_key should be interpreted as a Unix wildcard pattern. (Default: False)
1576
+ aws_conn_id : str
1577
+ a reference to the s3 connection on Airflow. (Default: None)
1578
+ verify : bool
1579
+ Whether or not to verify SSL certificates for S3 connection. (Default: None)
1580
+ """
1581
+ ...
1582
+
1735
1583
  @typing.overload
1736
1584
  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]]:
1737
1585
  """
@@ -1827,6 +1675,189 @@ def trigger(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, event: t
1827
1675
  """
1828
1676
  ...
1829
1677
 
1678
+ @typing.overload
1679
+ 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]]:
1680
+ """
1681
+ Specifies the times when the flow should be run when running on a
1682
+ production scheduler.
1683
+
1684
+ Parameters
1685
+ ----------
1686
+ hourly : bool, default False
1687
+ Run the workflow hourly.
1688
+ daily : bool, default True
1689
+ Run the workflow daily.
1690
+ weekly : bool, default False
1691
+ Run the workflow weekly.
1692
+ cron : str, optional, default None
1693
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1694
+ specified by this expression.
1695
+ timezone : str, optional, default None
1696
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1697
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1698
+ """
1699
+ ...
1700
+
1701
+ @typing.overload
1702
+ def schedule(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1703
+ ...
1704
+
1705
+ 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):
1706
+ """
1707
+ Specifies the times when the flow should be run when running on a
1708
+ production scheduler.
1709
+
1710
+ Parameters
1711
+ ----------
1712
+ hourly : bool, default False
1713
+ Run the workflow hourly.
1714
+ daily : bool, default True
1715
+ Run the workflow daily.
1716
+ weekly : bool, default False
1717
+ Run the workflow weekly.
1718
+ cron : str, optional, default None
1719
+ Run the workflow at [a custom Cron schedule](https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html#cron-expressions)
1720
+ specified by this expression.
1721
+ timezone : str, optional, default None
1722
+ Timezone on which the schedule runs (default: None). Currently supported only for Argo workflows,
1723
+ which accepts timezones in [IANA format](https://nodatime.org/TimeZones).
1724
+ """
1725
+ ...
1726
+
1727
+ def nim(*, models: "list[NIM]", backend: str) -> typing.Callable[[typing.Type[FlowSpecDerived]], typing.Type[FlowSpecDerived]]:
1728
+ """
1729
+ This decorator is used to run NIM containers in Metaflow tasks as sidecars.
1730
+
1731
+ User code call
1732
+ -----------
1733
+ @nim(
1734
+ models=['meta/llama3-8b-instruct', 'meta/llama3-70b-instruct'],
1735
+ backend='managed'
1736
+ )
1737
+
1738
+ Valid backend options
1739
+ ---------------------
1740
+ - 'managed': Outerbounds selects a compute provider based on the model.
1741
+ - 🚧 'dataplane': Run in your account.
1742
+
1743
+ Valid model options
1744
+ ----------------
1745
+ - 'meta/llama3-8b-instruct': 8B parameter model
1746
+ - 'meta/llama3-70b-instruct': 70B parameter model
1747
+ - Upon request, any model here: https://nvcf.ngc.nvidia.com/functions?filter=nvidia-functions
1748
+
1749
+ Parameters
1750
+ ----------
1751
+ models: list[NIM]
1752
+ List of NIM containers running models in sidecars.
1753
+ backend: str
1754
+ Compute provider to run the NIM container.
1755
+ """
1756
+ ...
1757
+
1758
+ @typing.overload
1759
+ def trigger_on_finish(*, flow: typing.Union[str, typing.Dict[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]]:
1760
+ """
1761
+ Specifies the flow(s) that this flow depends on.
1762
+
1763
+ ```
1764
+ @trigger_on_finish(flow='FooFlow')
1765
+ ```
1766
+ or
1767
+ ```
1768
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1769
+ ```
1770
+ This decorator respects the @project decorator and triggers the flow
1771
+ when upstream runs within the same namespace complete successfully
1772
+
1773
+ Additionally, you can specify project aware upstream flow dependencies
1774
+ by specifying the fully qualified project_flow_name.
1775
+ ```
1776
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1777
+ ```
1778
+ or
1779
+ ```
1780
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1781
+ ```
1782
+
1783
+ You can also specify just the project or project branch (other values will be
1784
+ inferred from the current project or project branch):
1785
+ ```
1786
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1787
+ ```
1788
+
1789
+ Note that `branch` is typically one of:
1790
+ - `prod`
1791
+ - `user.bob`
1792
+ - `test.my_experiment`
1793
+ - `prod.staging`
1794
+
1795
+ Parameters
1796
+ ----------
1797
+ flow : Union[str, Dict[str, str]], optional, default None
1798
+ Upstream flow dependency for this flow.
1799
+ flows : List[Union[str, Dict[str, str]]], default []
1800
+ Upstream flow dependencies for this flow.
1801
+ options : Dict[str, Any], default {}
1802
+ Backend-specific configuration for tuning eventing behavior.
1803
+
1804
+
1805
+ """
1806
+ ...
1807
+
1808
+ @typing.overload
1809
+ def trigger_on_finish(f: typing.Type[FlowSpecDerived]) -> typing.Type[FlowSpecDerived]:
1810
+ ...
1811
+
1812
+ def trigger_on_finish(f: typing.Optional[typing.Type[FlowSpecDerived]] = None, *, flow: typing.Union[str, typing.Dict[str, str], None] = None, flows: typing.List[typing.Union[str, typing.Dict[str, str]]] = [], options: typing.Dict[str, typing.Any] = {}):
1813
+ """
1814
+ Specifies the flow(s) that this flow depends on.
1815
+
1816
+ ```
1817
+ @trigger_on_finish(flow='FooFlow')
1818
+ ```
1819
+ or
1820
+ ```
1821
+ @trigger_on_finish(flows=['FooFlow', 'BarFlow'])
1822
+ ```
1823
+ This decorator respects the @project decorator and triggers the flow
1824
+ when upstream runs within the same namespace complete successfully
1825
+
1826
+ Additionally, you can specify project aware upstream flow dependencies
1827
+ by specifying the fully qualified project_flow_name.
1828
+ ```
1829
+ @trigger_on_finish(flow='my_project.branch.my_branch.FooFlow')
1830
+ ```
1831
+ or
1832
+ ```
1833
+ @trigger_on_finish(flows=['my_project.branch.my_branch.FooFlow', 'BarFlow'])
1834
+ ```
1835
+
1836
+ You can also specify just the project or project branch (other values will be
1837
+ inferred from the current project or project branch):
1838
+ ```
1839
+ @trigger_on_finish(flow={"name": "FooFlow", "project": "my_project", "project_branch": "branch"})
1840
+ ```
1841
+
1842
+ Note that `branch` is typically one of:
1843
+ - `prod`
1844
+ - `user.bob`
1845
+ - `test.my_experiment`
1846
+ - `prod.staging`
1847
+
1848
+ Parameters
1849
+ ----------
1850
+ flow : Union[str, Dict[str, str]], optional, default None
1851
+ Upstream flow dependency for this flow.
1852
+ flows : List[Union[str, Dict[str, str]]], default []
1853
+ Upstream flow dependencies for this flow.
1854
+ options : Dict[str, Any], default {}
1855
+ Backend-specific configuration for tuning eventing behavior.
1856
+
1857
+
1858
+ """
1859
+ ...
1860
+
1830
1861
  def namespace(ns: typing.Optional[str]) -> typing.Optional[str]:
1831
1862
  """
1832
1863
  Switch namespace to the one provided.