prefect-client 2.16.9__py3-none-any.whl → 2.17.0__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.
- prefect/__init__.py +0 -18
- prefect/_internal/compatibility/deprecated.py +108 -5
- prefect/_internal/pydantic/__init__.py +4 -0
- prefect/_internal/pydantic/_base_model.py +36 -4
- prefect/_internal/pydantic/_compat.py +33 -2
- prefect/_internal/pydantic/_flags.py +3 -0
- prefect/_internal/pydantic/utilities/config_dict.py +72 -0
- prefect/_internal/pydantic/utilities/field_validator.py +135 -0
- prefect/_internal/pydantic/utilities/model_fields_set.py +29 -0
- prefect/_internal/pydantic/utilities/model_validator.py +79 -0
- prefect/agent.py +1 -1
- prefect/blocks/notifications.py +18 -18
- prefect/blocks/webhook.py +1 -1
- prefect/client/base.py +7 -0
- prefect/client/orchestration.py +44 -4
- prefect/client/schemas/actions.py +27 -20
- prefect/client/schemas/filters.py +28 -28
- prefect/client/schemas/objects.py +31 -21
- prefect/client/schemas/responses.py +17 -11
- prefect/client/schemas/schedules.py +6 -8
- prefect/context.py +2 -1
- prefect/deployments/base.py +2 -10
- prefect/deployments/deployments.py +34 -9
- prefect/deployments/runner.py +2 -2
- prefect/engine.py +32 -596
- prefect/events/clients.py +45 -13
- prefect/events/filters.py +19 -2
- prefect/events/utilities.py +12 -4
- prefect/events/worker.py +26 -8
- prefect/exceptions.py +3 -8
- prefect/filesystems.py +7 -7
- prefect/flows.py +4 -3
- prefect/manifests.py +1 -8
- prefect/profiles.toml +1 -1
- prefect/pydantic/__init__.py +27 -1
- prefect/pydantic/main.py +26 -2
- prefect/settings.py +33 -10
- prefect/task_server.py +2 -2
- prefect/utilities/dispatch.py +1 -0
- prefect/utilities/engine.py +629 -0
- prefect/utilities/pydantic.py +1 -1
- prefect/utilities/visualization.py +1 -1
- prefect/variables.py +88 -12
- prefect/workers/base.py +1 -1
- prefect/workers/block.py +1 -1
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.0.dist-info}/METADATA +3 -3
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.0.dist-info}/RECORD +50 -45
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.0.dist-info}/LICENSE +0 -0
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.0.dist-info}/WHEEL +0 -0
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.0.dist-info}/top_level.txt +0 -0
@@ -48,7 +48,7 @@ class FlowFilterName(PrefectBaseModel):
|
|
48
48
|
any_: Optional[List[str]] = Field(
|
49
49
|
default=None,
|
50
50
|
description="A list of flow names to include",
|
51
|
-
|
51
|
+
examples=[["my-flow-1", "my-flow-2"]],
|
52
52
|
)
|
53
53
|
|
54
54
|
like_: Optional[str] = Field(
|
@@ -58,7 +58,7 @@ class FlowFilterName(PrefectBaseModel):
|
|
58
58
|
" passing 'marvin' will match "
|
59
59
|
"'marvin', 'sad-Marvin', and 'marvin-robot'."
|
60
60
|
),
|
61
|
-
|
61
|
+
examples=["marvin"],
|
62
62
|
)
|
63
63
|
|
64
64
|
|
@@ -67,7 +67,7 @@ class FlowFilterTags(PrefectBaseModel, OperatorMixin):
|
|
67
67
|
|
68
68
|
all_: Optional[List[str]] = Field(
|
69
69
|
default=None,
|
70
|
-
|
70
|
+
examples=[["tag-1", "tag-2"]],
|
71
71
|
description=(
|
72
72
|
"A list of tags. Flows will be returned only if their tags are a superset"
|
73
73
|
" of the list"
|
@@ -109,7 +109,7 @@ class FlowRunFilterName(PrefectBaseModel):
|
|
109
109
|
any_: Optional[List[str]] = Field(
|
110
110
|
default=None,
|
111
111
|
description="A list of flow run names to include",
|
112
|
-
|
112
|
+
examples=[["my-flow-run-1", "my-flow-run-2"]],
|
113
113
|
)
|
114
114
|
|
115
115
|
like_: Optional[str] = Field(
|
@@ -119,7 +119,7 @@ class FlowRunFilterName(PrefectBaseModel):
|
|
119
119
|
" passing 'marvin' will match "
|
120
120
|
"'marvin', 'sad-Marvin', and 'marvin-robot'."
|
121
121
|
),
|
122
|
-
|
122
|
+
examples=["marvin"],
|
123
123
|
)
|
124
124
|
|
125
125
|
|
@@ -128,7 +128,7 @@ class FlowRunFilterTags(PrefectBaseModel, OperatorMixin):
|
|
128
128
|
|
129
129
|
all_: Optional[List[str]] = Field(
|
130
130
|
default=None,
|
131
|
-
|
131
|
+
examples=[["tag-1", "tag-2"]],
|
132
132
|
description=(
|
133
133
|
"A list of tags. Flow runs will be returned only if their tags are a"
|
134
134
|
" superset of the list"
|
@@ -157,7 +157,7 @@ class FlowRunFilterWorkQueueName(PrefectBaseModel, OperatorMixin):
|
|
157
157
|
any_: Optional[List[str]] = Field(
|
158
158
|
default=None,
|
159
159
|
description="A list of work queue names to include",
|
160
|
-
|
160
|
+
examples=[["work_queue_1", "work_queue_2"]],
|
161
161
|
)
|
162
162
|
is_null_: Optional[bool] = Field(
|
163
163
|
default=None,
|
@@ -343,7 +343,7 @@ class TaskRunFilterName(PrefectBaseModel):
|
|
343
343
|
any_: Optional[List[str]] = Field(
|
344
344
|
default=None,
|
345
345
|
description="A list of task run names to include",
|
346
|
-
|
346
|
+
examples=[["my-task-run-1", "my-task-run-2"]],
|
347
347
|
)
|
348
348
|
|
349
349
|
like_: Optional[str] = Field(
|
@@ -353,7 +353,7 @@ class TaskRunFilterName(PrefectBaseModel):
|
|
353
353
|
" passing 'marvin' will match "
|
354
354
|
"'marvin', 'sad-Marvin', and 'marvin-robot'."
|
355
355
|
),
|
356
|
-
|
356
|
+
examples=["marvin"],
|
357
357
|
)
|
358
358
|
|
359
359
|
|
@@ -362,7 +362,7 @@ class TaskRunFilterTags(PrefectBaseModel, OperatorMixin):
|
|
362
362
|
|
363
363
|
all_: Optional[List[str]] = Field(
|
364
364
|
default=None,
|
365
|
-
|
365
|
+
examples=[["tag-1", "tag-2"]],
|
366
366
|
description=(
|
367
367
|
"A list of tags. Task runs will be returned only if their tags are a"
|
368
368
|
" superset of the list"
|
@@ -460,7 +460,7 @@ class DeploymentFilterName(PrefectBaseModel):
|
|
460
460
|
any_: Optional[List[str]] = Field(
|
461
461
|
default=None,
|
462
462
|
description="A list of deployment names to include",
|
463
|
-
|
463
|
+
examples=[["my-deployment-1", "my-deployment-2"]],
|
464
464
|
)
|
465
465
|
|
466
466
|
like_: Optional[str] = Field(
|
@@ -470,7 +470,7 @@ class DeploymentFilterName(PrefectBaseModel):
|
|
470
470
|
" passing 'marvin' will match "
|
471
471
|
"'marvin', 'sad-Marvin', and 'marvin-robot'."
|
472
472
|
),
|
473
|
-
|
473
|
+
examples=["marvin"],
|
474
474
|
)
|
475
475
|
|
476
476
|
|
@@ -480,7 +480,7 @@ class DeploymentFilterWorkQueueName(PrefectBaseModel):
|
|
480
480
|
any_: Optional[List[str]] = Field(
|
481
481
|
default=None,
|
482
482
|
description="A list of work queue names to include",
|
483
|
-
|
483
|
+
examples=[["work_queue_1", "work_queue_2"]],
|
484
484
|
)
|
485
485
|
|
486
486
|
|
@@ -498,7 +498,7 @@ class DeploymentFilterTags(PrefectBaseModel, OperatorMixin):
|
|
498
498
|
|
499
499
|
all_: Optional[List[str]] = Field(
|
500
500
|
default=None,
|
501
|
-
|
501
|
+
examples=[["tag-1", "tag-2"]],
|
502
502
|
description=(
|
503
503
|
"A list of tags. Deployments will be returned only if their tags are a"
|
504
504
|
" superset of the list"
|
@@ -535,7 +535,7 @@ class LogFilterName(PrefectBaseModel):
|
|
535
535
|
any_: Optional[List[str]] = Field(
|
536
536
|
default=None,
|
537
537
|
description="A list of log names to include",
|
538
|
-
|
538
|
+
examples=[["prefect.logger.flow_runs", "prefect.logger.task_runs"]],
|
539
539
|
)
|
540
540
|
|
541
541
|
|
@@ -545,13 +545,13 @@ class LogFilterLevel(PrefectBaseModel):
|
|
545
545
|
ge_: Optional[int] = Field(
|
546
546
|
default=None,
|
547
547
|
description="Include logs with a level greater than or equal to this level",
|
548
|
-
|
548
|
+
examples=[20],
|
549
549
|
)
|
550
550
|
|
551
551
|
le_: Optional[int] = Field(
|
552
552
|
default=None,
|
553
553
|
description="Include logs with a level less than or equal to this level",
|
554
|
-
|
554
|
+
examples=[50],
|
555
555
|
)
|
556
556
|
|
557
557
|
|
@@ -629,7 +629,7 @@ class BlockTypeFilterName(PrefectBaseModel):
|
|
629
629
|
" passing 'marvin' will match "
|
630
630
|
"'marvin', 'sad-Marvin', and 'marvin-robot'."
|
631
631
|
),
|
632
|
-
|
632
|
+
examples=["marvin"],
|
633
633
|
)
|
634
634
|
|
635
635
|
|
@@ -674,7 +674,7 @@ class BlockSchemaFilterCapabilities(PrefectBaseModel):
|
|
674
674
|
|
675
675
|
all_: Optional[List[str]] = Field(
|
676
676
|
default=None,
|
677
|
-
|
677
|
+
examples=[["write-storage", "read-storage"]],
|
678
678
|
description=(
|
679
679
|
"A list of block capabilities. Block entities will be returned only if an"
|
680
680
|
" associated block schema has a superset of the defined capabilities."
|
@@ -687,7 +687,7 @@ class BlockSchemaFilterVersion(PrefectBaseModel):
|
|
687
687
|
|
688
688
|
any_: Optional[List[str]] = Field(
|
689
689
|
default=None,
|
690
|
-
|
690
|
+
examples=[["2.0.0", "2.1.0"]],
|
691
691
|
description="A list of block schema versions.",
|
692
692
|
)
|
693
693
|
|
@@ -748,7 +748,7 @@ class BlockDocumentFilterName(PrefectBaseModel):
|
|
748
748
|
"A string to match block names against. This can include "
|
749
749
|
"SQL wildcard characters like `%` and `_`."
|
750
750
|
),
|
751
|
-
|
751
|
+
examples=["my-block%"],
|
752
752
|
)
|
753
753
|
|
754
754
|
|
@@ -809,7 +809,7 @@ class WorkQueueFilterName(PrefectBaseModel):
|
|
809
809
|
any_: Optional[List[str]] = Field(
|
810
810
|
default=None,
|
811
811
|
description="A list of work queue names to include",
|
812
|
-
|
812
|
+
examples=[["wq-1", "wq-2"]],
|
813
813
|
)
|
814
814
|
|
815
815
|
startswith_: Optional[List[str]] = Field(
|
@@ -819,7 +819,7 @@ class WorkQueueFilterName(PrefectBaseModel):
|
|
819
819
|
" passing 'marvin' will match "
|
820
820
|
"'marvin', and 'Marvin-robot', but not 'sad-marvin'."
|
821
821
|
),
|
822
|
-
|
822
|
+
examples=[["marvin", "Marvin-robot"]],
|
823
823
|
)
|
824
824
|
|
825
825
|
|
@@ -929,7 +929,7 @@ class ArtifactFilterKey(PrefectBaseModel):
|
|
929
929
|
"A string to match artifact keys against. This can include "
|
930
930
|
"SQL wildcard characters like `%` and `_`."
|
931
931
|
),
|
932
|
-
|
932
|
+
examples=["my-artifact-%"],
|
933
933
|
)
|
934
934
|
|
935
935
|
exists_: Optional[bool] = Field(
|
@@ -1009,7 +1009,7 @@ class ArtifactCollectionFilterKey(PrefectBaseModel):
|
|
1009
1009
|
"A string to match artifact keys against. This can include "
|
1010
1010
|
"SQL wildcard characters like `%` and `_`."
|
1011
1011
|
),
|
1012
|
-
|
1012
|
+
examples=["my-artifact-%"],
|
1013
1013
|
)
|
1014
1014
|
|
1015
1015
|
exists_: Optional[bool] = Field(
|
@@ -1089,7 +1089,7 @@ class VariableFilterName(PrefectBaseModel):
|
|
1089
1089
|
"A string to match variable names against. This can include "
|
1090
1090
|
"SQL wildcard characters like `%` and `_`."
|
1091
1091
|
),
|
1092
|
-
|
1092
|
+
examples=["my_variable_%"],
|
1093
1093
|
)
|
1094
1094
|
|
1095
1095
|
|
@@ -1105,7 +1105,7 @@ class VariableFilterValue(PrefectBaseModel):
|
|
1105
1105
|
"A string to match variable value against. This can include "
|
1106
1106
|
"SQL wildcard characters like `%` and `_`."
|
1107
1107
|
),
|
1108
|
-
|
1108
|
+
examples=["my-value-%"],
|
1109
1109
|
)
|
1110
1110
|
|
1111
1111
|
|
@@ -1114,7 +1114,7 @@ class VariableFilterTags(PrefectBaseModel, OperatorMixin):
|
|
1114
1114
|
|
1115
1115
|
all_: Optional[List[str]] = Field(
|
1116
1116
|
default=None,
|
1117
|
-
|
1117
|
+
examples=[["tag-1", "tag-2"]],
|
1118
1118
|
description=(
|
1119
1119
|
"A list of tags. Variables will be returned only if their tags are a"
|
1120
1120
|
" superset of the list"
|
@@ -15,6 +15,9 @@ from uuid import UUID
|
|
15
15
|
import orjson
|
16
16
|
import pendulum
|
17
17
|
|
18
|
+
from prefect._internal.compatibility.deprecated import (
|
19
|
+
DeprecatedInfraOverridesField,
|
20
|
+
)
|
18
21
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
19
22
|
|
20
23
|
if HAS_PYDANTIC_V2:
|
@@ -142,7 +145,7 @@ class State(ObjectBaseModel, Generic[R]):
|
|
142
145
|
type: StateType
|
143
146
|
name: Optional[str] = Field(default=None)
|
144
147
|
timestamp: DateTimeTZ = Field(default_factory=lambda: pendulum.now("UTC"))
|
145
|
-
message: Optional[str] = Field(default=None,
|
148
|
+
message: Optional[str] = Field(default=None, examples=["Run started"])
|
146
149
|
state_details: StateDetails = Field(default_factory=StateDetails)
|
147
150
|
data: Union["BaseResult[R]", "DataDocument[R]", Any] = Field(
|
148
151
|
default=None,
|
@@ -410,7 +413,7 @@ class FlowRun(ObjectBaseModel):
|
|
410
413
|
description=(
|
411
414
|
"The name of the flow run. Defaults to a random slug if not specified."
|
412
415
|
),
|
413
|
-
|
416
|
+
examples=["my-flow-run"],
|
414
417
|
)
|
415
418
|
flow_id: UUID = Field(default=..., description="The id of the flow being run.")
|
416
419
|
state_id: Optional[UUID] = Field(
|
@@ -422,13 +425,18 @@ class FlowRun(ObjectBaseModel):
|
|
422
425
|
"The id of the deployment associated with this flow run, if available."
|
423
426
|
),
|
424
427
|
)
|
428
|
+
deployment_version: Optional[str] = Field(
|
429
|
+
default=None,
|
430
|
+
description="The version of the deployment associated with this flow run.",
|
431
|
+
examples=["1.0"],
|
432
|
+
)
|
425
433
|
work_queue_name: Optional[str] = Field(
|
426
434
|
default=None, description="The work queue that handled this flow run."
|
427
435
|
)
|
428
436
|
flow_version: Optional[str] = Field(
|
429
437
|
default=None,
|
430
438
|
description="The version of the flow executed in this flow run.",
|
431
|
-
|
439
|
+
examples=["1.0"],
|
432
440
|
)
|
433
441
|
parameters: Dict[str, Any] = Field(
|
434
442
|
default_factory=dict, description="Parameters for the flow run."
|
@@ -443,7 +451,7 @@ class FlowRun(ObjectBaseModel):
|
|
443
451
|
context: Dict[str, Any] = Field(
|
444
452
|
default_factory=dict,
|
445
453
|
description="Additional context for the flow run.",
|
446
|
-
|
454
|
+
examples=[{"my_var": "my_val"}],
|
447
455
|
)
|
448
456
|
empirical_policy: FlowRunPolicy = Field(
|
449
457
|
default_factory=FlowRunPolicy,
|
@@ -451,7 +459,7 @@ class FlowRun(ObjectBaseModel):
|
|
451
459
|
tags: List[str] = Field(
|
452
460
|
default_factory=list,
|
453
461
|
description="A list of tags on the flow run",
|
454
|
-
|
462
|
+
examples=[["tag-1", "tag-2"]],
|
455
463
|
)
|
456
464
|
parent_task_run_id: Optional[UUID] = Field(
|
457
465
|
default=None,
|
@@ -518,12 +526,12 @@ class FlowRun(ObjectBaseModel):
|
|
518
526
|
work_pool_name: Optional[str] = Field(
|
519
527
|
default=None,
|
520
528
|
description="The name of the flow run's work pool.",
|
521
|
-
|
529
|
+
examples=["my-work-pool"],
|
522
530
|
)
|
523
531
|
state: Optional[State] = Field(
|
524
532
|
default=None,
|
525
533
|
description="The state of the flow run.",
|
526
|
-
|
534
|
+
examples=[State(type=StateType.COMPLETED)],
|
527
535
|
)
|
528
536
|
job_variables: Optional[dict] = Field(
|
529
537
|
default=None, description="Job variables for the flow run."
|
@@ -634,7 +642,9 @@ class Constant(TaskRunInput):
|
|
634
642
|
|
635
643
|
|
636
644
|
class TaskRun(ObjectBaseModel):
|
637
|
-
name: str = Field(
|
645
|
+
name: str = Field(
|
646
|
+
default_factory=lambda: generate_slug(2), examples=["my-task-run"]
|
647
|
+
)
|
638
648
|
flow_run_id: Optional[UUID] = Field(
|
639
649
|
default=None, description="The flow run id of the task run."
|
640
650
|
)
|
@@ -668,7 +678,7 @@ class TaskRun(ObjectBaseModel):
|
|
668
678
|
tags: List[str] = Field(
|
669
679
|
default_factory=list,
|
670
680
|
description="A list of tags for the task run.",
|
671
|
-
|
681
|
+
examples=[["tag-1", "tag-2"]],
|
672
682
|
)
|
673
683
|
state_id: Optional[UUID] = Field(
|
674
684
|
default=None, description="The id of the current task run state."
|
@@ -731,7 +741,7 @@ class TaskRun(ObjectBaseModel):
|
|
731
741
|
state: Optional[State] = Field(
|
732
742
|
default=None,
|
733
743
|
description="The state of the flow run.",
|
734
|
-
|
744
|
+
examples=[State(type=StateType.COMPLETED)],
|
735
745
|
)
|
736
746
|
|
737
747
|
@validator("name", pre=True)
|
@@ -884,12 +894,12 @@ class Flow(ObjectBaseModel):
|
|
884
894
|
"""An ORM representation of flow data."""
|
885
895
|
|
886
896
|
name: str = Field(
|
887
|
-
default=..., description="The name of the flow",
|
897
|
+
default=..., description="The name of the flow", examples=["my-flow"]
|
888
898
|
)
|
889
899
|
tags: List[str] = Field(
|
890
900
|
default_factory=list,
|
891
901
|
description="A list of flow tags",
|
892
|
-
|
902
|
+
examples=[["tag-1", "tag-2"]],
|
893
903
|
)
|
894
904
|
|
895
905
|
@validator("name", check_fields=False)
|
@@ -919,7 +929,7 @@ class DeploymentSchedule(ObjectBaseModel):
|
|
919
929
|
)
|
920
930
|
|
921
931
|
|
922
|
-
class Deployment(ObjectBaseModel):
|
932
|
+
class Deployment(DeprecatedInfraOverridesField, ObjectBaseModel):
|
923
933
|
"""An ORM representation of deployment data."""
|
924
934
|
|
925
935
|
name: str = Field(default=..., description="The name of the deployment.")
|
@@ -944,9 +954,9 @@ class Deployment(ObjectBaseModel):
|
|
944
954
|
schedules: List[DeploymentSchedule] = Field(
|
945
955
|
default_factory=list, description="A list of schedules for the deployment."
|
946
956
|
)
|
947
|
-
|
957
|
+
job_variables: Dict[str, Any] = Field(
|
948
958
|
default_factory=dict,
|
949
|
-
description="Overrides to apply to
|
959
|
+
description="Overrides to apply to flow run infrastructure at runtime.",
|
950
960
|
)
|
951
961
|
parameters: Dict[str, Any] = Field(
|
952
962
|
default_factory=dict,
|
@@ -959,7 +969,7 @@ class Deployment(ObjectBaseModel):
|
|
959
969
|
tags: List[str] = Field(
|
960
970
|
default_factory=list,
|
961
971
|
description="A list of tags for the deployment",
|
962
|
-
|
972
|
+
examples=[["tag-1", "tag-2"]],
|
963
973
|
)
|
964
974
|
work_queue_name: Optional[str] = Field(
|
965
975
|
default=None,
|
@@ -1295,10 +1305,10 @@ class FlowRunNotificationPolicy(ObjectBaseModel):
|
|
1295
1305
|
" Valid variables include:"
|
1296
1306
|
f" {listrepr(sorted(FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS), sep=', ')}"
|
1297
1307
|
),
|
1298
|
-
|
1308
|
+
examples=[
|
1299
1309
|
"Flow run {flow_run_name} with id {flow_run_id} entered state"
|
1300
1310
|
" {flow_run_state_name}."
|
1301
|
-
|
1311
|
+
],
|
1302
1312
|
)
|
1303
1313
|
|
1304
1314
|
@validator("message_template")
|
@@ -1479,19 +1489,19 @@ class Variable(ObjectBaseModel):
|
|
1479
1489
|
name: str = Field(
|
1480
1490
|
default=...,
|
1481
1491
|
description="The name of the variable",
|
1482
|
-
|
1492
|
+
examples=["my_variable"],
|
1483
1493
|
max_length=MAX_VARIABLE_NAME_LENGTH,
|
1484
1494
|
)
|
1485
1495
|
value: str = Field(
|
1486
1496
|
default=...,
|
1487
1497
|
description="The value of the variable",
|
1488
|
-
|
1498
|
+
examples=["my_value"],
|
1489
1499
|
max_length=MAX_VARIABLE_VALUE_LENGTH,
|
1490
1500
|
)
|
1491
1501
|
tags: List[str] = Field(
|
1492
1502
|
default_factory=list,
|
1493
1503
|
description="A list of variable tags",
|
1494
|
-
|
1504
|
+
examples=[["tag-1", "tag-2"]],
|
1495
1505
|
)
|
1496
1506
|
|
1497
1507
|
|
@@ -2,6 +2,7 @@ import datetime
|
|
2
2
|
from typing import Any, Dict, List, Optional, TypeVar, Union
|
3
3
|
from uuid import UUID
|
4
4
|
|
5
|
+
from prefect._internal.compatibility.deprecated import DeprecatedInfraOverridesField
|
5
6
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
6
7
|
|
7
8
|
if HAS_PYDANTIC_V2:
|
@@ -160,7 +161,7 @@ class FlowRunResponse(ObjectBaseModel):
|
|
160
161
|
description=(
|
161
162
|
"The name of the flow run. Defaults to a random slug if not specified."
|
162
163
|
),
|
163
|
-
|
164
|
+
examples=["my-flow-run"],
|
164
165
|
)
|
165
166
|
flow_id: UUID = Field(default=..., description="The id of the flow being run.")
|
166
167
|
state_id: Optional[UUID] = Field(
|
@@ -172,13 +173,18 @@ class FlowRunResponse(ObjectBaseModel):
|
|
172
173
|
"The id of the deployment associated with this flow run, if available."
|
173
174
|
),
|
174
175
|
)
|
176
|
+
deployment_version: Optional[str] = Field(
|
177
|
+
default=None,
|
178
|
+
description="The version of the deployment associated with this flow run.",
|
179
|
+
examples=["1.0"],
|
180
|
+
)
|
175
181
|
work_queue_name: Optional[str] = Field(
|
176
182
|
default=None, description="The work queue that handled this flow run."
|
177
183
|
)
|
178
184
|
flow_version: Optional[str] = Field(
|
179
185
|
default=None,
|
180
186
|
description="The version of the flow executed in this flow run.",
|
181
|
-
|
187
|
+
examples=["1.0"],
|
182
188
|
)
|
183
189
|
parameters: Dict[str, Any] = Field(
|
184
190
|
default_factory=dict, description="Parameters for the flow run."
|
@@ -193,7 +199,7 @@ class FlowRunResponse(ObjectBaseModel):
|
|
193
199
|
context: Dict[str, Any] = Field(
|
194
200
|
default_factory=dict,
|
195
201
|
description="Additional context for the flow run.",
|
196
|
-
|
202
|
+
examples=[{"my_var": "my_val"}],
|
197
203
|
)
|
198
204
|
empirical_policy: objects.FlowRunPolicy = Field(
|
199
205
|
default_factory=objects.FlowRunPolicy,
|
@@ -201,7 +207,7 @@ class FlowRunResponse(ObjectBaseModel):
|
|
201
207
|
tags: List[str] = Field(
|
202
208
|
default_factory=list,
|
203
209
|
description="A list of tags on the flow run",
|
204
|
-
|
210
|
+
examples=[["tag-1", "tag-2"]],
|
205
211
|
)
|
206
212
|
parent_task_run_id: Optional[UUID] = Field(
|
207
213
|
default=None,
|
@@ -268,12 +274,12 @@ class FlowRunResponse(ObjectBaseModel):
|
|
268
274
|
work_pool_name: Optional[str] = Field(
|
269
275
|
default=None,
|
270
276
|
description="The name of the flow run's work pool.",
|
271
|
-
|
277
|
+
examples=["my-work-pool"],
|
272
278
|
)
|
273
279
|
state: Optional[objects.State] = Field(
|
274
280
|
default=None,
|
275
281
|
description="The state of the flow run.",
|
276
|
-
|
282
|
+
examples=[objects.State(type=objects.StateType.COMPLETED)],
|
277
283
|
)
|
278
284
|
job_variables: Optional[dict] = Field(
|
279
285
|
default=None, description="Job variables for the flow run."
|
@@ -304,7 +310,7 @@ class FlowRunResponse(ObjectBaseModel):
|
|
304
310
|
return super().__eq__(other)
|
305
311
|
|
306
312
|
|
307
|
-
class DeploymentResponse(ObjectBaseModel):
|
313
|
+
class DeploymentResponse(DeprecatedInfraOverridesField, ObjectBaseModel):
|
308
314
|
name: str = Field(default=..., description="The name of the deployment.")
|
309
315
|
version: Optional[str] = Field(
|
310
316
|
default=None, description="An optional version for the deployment."
|
@@ -327,9 +333,9 @@ class DeploymentResponse(ObjectBaseModel):
|
|
327
333
|
schedules: List[objects.DeploymentSchedule] = Field(
|
328
334
|
default_factory=list, description="A list of schedules for the deployment."
|
329
335
|
)
|
330
|
-
|
336
|
+
job_variables: Dict[str, Any] = Field(
|
331
337
|
default_factory=dict,
|
332
|
-
description="Overrides to apply to
|
338
|
+
description="Overrides to apply to flow run infrastructure at runtime.",
|
333
339
|
)
|
334
340
|
parameters: Dict[str, Any] = Field(
|
335
341
|
default_factory=dict,
|
@@ -342,7 +348,7 @@ class DeploymentResponse(ObjectBaseModel):
|
|
342
348
|
tags: List[str] = Field(
|
343
349
|
default_factory=list,
|
344
350
|
description="A list of tags for the deployment",
|
345
|
-
|
351
|
+
examples=[["tag-1", "tag-2"]],
|
346
352
|
)
|
347
353
|
work_queue_name: Optional[str] = Field(
|
348
354
|
default=None,
|
@@ -418,7 +424,7 @@ class DeploymentResponse(ObjectBaseModel):
|
|
418
424
|
|
419
425
|
class MinimalConcurrencyLimitResponse(PrefectBaseModel):
|
420
426
|
class Config:
|
421
|
-
extra = "ignore"
|
427
|
+
extra = "ignore" # 2024/4/1
|
422
428
|
|
423
429
|
id: UUID
|
424
430
|
name: str
|
@@ -10,6 +10,8 @@ import dateutil.rrule
|
|
10
10
|
import pendulum
|
11
11
|
|
12
12
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
13
|
+
from prefect._internal.schemas.bases import PrefectBaseModel
|
14
|
+
from prefect._internal.schemas.fields import DateTimeTZ
|
13
15
|
from prefect._internal.schemas.validators import (
|
14
16
|
default_anchor_date,
|
15
17
|
default_timezone,
|
@@ -24,10 +26,6 @@ if HAS_PYDANTIC_V2:
|
|
24
26
|
else:
|
25
27
|
from pydantic import Field, validator
|
26
28
|
|
27
|
-
|
28
|
-
from prefect._internal.schemas.bases import PrefectBaseModel
|
29
|
-
from prefect._internal.schemas.fields import DateTimeTZ
|
30
|
-
|
31
29
|
MAX_ITERATIONS = 1000
|
32
30
|
# approx. 1 years worth of RDATEs + buffer
|
33
31
|
MAX_RRULE_LENGTH = 6500
|
@@ -68,7 +66,7 @@ class IntervalSchedule(PrefectBaseModel):
|
|
68
66
|
|
69
67
|
interval: datetime.timedelta
|
70
68
|
anchor_date: DateTimeTZ = None
|
71
|
-
timezone: Optional[str] = Field(default=None,
|
69
|
+
timezone: Optional[str] = Field(default=None, examples=["America/New_York"])
|
72
70
|
|
73
71
|
@validator("interval")
|
74
72
|
def validate_interval_schedule(cls, v):
|
@@ -111,8 +109,8 @@ class CronSchedule(PrefectBaseModel):
|
|
111
109
|
class Config:
|
112
110
|
extra = "forbid"
|
113
111
|
|
114
|
-
cron: str = Field(default=...,
|
115
|
-
timezone: Optional[str] = Field(default=None,
|
112
|
+
cron: str = Field(default=..., examples=["0 0 * * *"])
|
113
|
+
timezone: Optional[str] = Field(default=None, examples=["America/New_York"])
|
116
114
|
day_or: bool = Field(
|
117
115
|
default=True,
|
118
116
|
description=(
|
@@ -156,7 +154,7 @@ class RRuleSchedule(PrefectBaseModel):
|
|
156
154
|
extra = "forbid"
|
157
155
|
|
158
156
|
rrule: str
|
159
|
-
timezone: Optional[str] = Field(default=None,
|
157
|
+
timezone: Optional[str] = Field(default=None, examples=["America/New_York"])
|
160
158
|
|
161
159
|
@validator("rrule")
|
162
160
|
def validate_rrule_str(cls, v):
|
prefect/context.py
CHANGED
@@ -19,6 +19,7 @@ from typing import (
|
|
19
19
|
Any,
|
20
20
|
ContextManager,
|
21
21
|
Dict,
|
22
|
+
Generator,
|
22
23
|
List,
|
23
24
|
Optional,
|
24
25
|
Set,
|
@@ -395,7 +396,7 @@ def get_settings_context() -> SettingsContext:
|
|
395
396
|
|
396
397
|
|
397
398
|
@contextmanager
|
398
|
-
def tags(*new_tags: str) -> Set[str]:
|
399
|
+
def tags(*new_tags: str) -> Generator[Set[str], None, None]:
|
399
400
|
"""
|
400
401
|
Context manager to add tags to flow and task run calls.
|
401
402
|
|
prefect/deployments/base.py
CHANGED
@@ -18,14 +18,6 @@ from typing import Any, Dict, List, Optional, cast
|
|
18
18
|
|
19
19
|
import anyio
|
20
20
|
import yaml
|
21
|
-
|
22
|
-
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
23
|
-
|
24
|
-
if HAS_PYDANTIC_V2:
|
25
|
-
from pydantic.v1 import BaseModel
|
26
|
-
else:
|
27
|
-
from pydantic import BaseModel
|
28
|
-
|
29
21
|
from ruamel.yaml import YAML
|
30
22
|
|
31
23
|
from prefect.client.schemas.objects import MinimalDeploymentSchedule
|
@@ -409,7 +401,7 @@ def _format_deployment_for_saving_to_prefect_file(
|
|
409
401
|
if deployment.get("schedule"):
|
410
402
|
if isinstance(deployment["schedule"], IntervalSchedule):
|
411
403
|
deployment["schedule"] = _interval_schedule_to_dict(deployment["schedule"])
|
412
|
-
|
404
|
+
else: # all valid SCHEDULE_TYPES are subclasses of BaseModel
|
413
405
|
deployment["schedule"] = deployment["schedule"].dict()
|
414
406
|
|
415
407
|
if "is_schedule_active" in deployment:
|
@@ -424,7 +416,7 @@ def _format_deployment_for_saving_to_prefect_file(
|
|
424
416
|
schedule_config = _interval_schedule_to_dict(
|
425
417
|
deployment_schedule.schedule
|
426
418
|
)
|
427
|
-
|
419
|
+
else: # all valid SCHEDULE_TYPES are subclasses of BaseModel
|
428
420
|
schedule_config = deployment_schedule.schedule.dict()
|
429
421
|
|
430
422
|
schedule_config["active"] = deployment_schedule.active
|