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