319
320
321
322
@@ -10223,7 +10248,30 @@
1020
1021
1022
-1023 | @experimental_field(
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
| @experimental_field(
"work_pool_name",
group="work_pools",
when=lambda x: x is not None and x != DEFAULT_AGENT_WORK_POOL_NAME,
@@ -10560,11 +10608,17 @@
cls._validate_schedule(value)
return value
- @validator("schedules")
- def validate_schedules(cls, value):
- for schedule in value:
- cls._validate_schedule(schedule.schedule)
- return value
+ @root_validator(pre=True)
+ def validate_schedules(cls, values):
+ if "schedules" in values:
+ values["schedules"] = normalize_to_minimal_deployment_schedules(
+ values["schedules"]
+ )
+
+ for schedule in values["schedules"]:
+ cls._validate_schedule(schedule.schedule)
+
+ return values
@classmethod
@sync_compatible
@@ -10847,6 +10901,7 @@
ignore_file: str = ".prefectignore",
apply: bool = False,
load_existing: bool = True,
+ schedules: Optional[FlexibleScheduleList] = None,
**kwargs,
) -> "Deployment":
"""
@@ -10866,6 +10921,14 @@
load_existing: if True, load any settings that may already be configured for
the named deployment server-side (e.g., schedules, default parameter
values, etc.)
+ schedules: An optional list of schedules. Each item in the list can be:
+ - An instance of `MinimalDeploymentSchedule`.
+ - A dictionary with a `schedule` key, and optionally, an
+ `active` key. The `schedule` key should correspond to a
+ schedule type, and `active` is a boolean indicating whether
+ the schedule is active or not.
+ - An instance of one of the predefined schedule types:
+ `IntervalSchedule`, `CronSchedule`, or `RRuleSchedule`.
**kwargs: other keyword arguments to pass to the constructor for the
`Deployment` class
"""
@@ -10874,7 +10937,11 @@
# note that `deployment.load` only updates settings that were *not*
# provided at initialization
- deployment = cls(name=name, **kwargs)
+ deployment = cls(
+ name=name,
+ schedules=schedules,
+ **kwargs,
+ )
deployment.flow_name = flow.name
if not deployment.entrypoint:
## first see if an entrypoint can be determined
@@ -11037,17 +11104,7 @@
Source code in prefect/deployments/deployments.py
- 829
-830
-831
-832
-833
-834
-835
-836
-837
-838
-839
+ 839
840
841
842
@@ -11134,7 +11191,17 @@ 923
924
925
-926 | @sync_compatible
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
| @sync_compatible
async def apply(
self, upload: bool = False, work_queue_concurrency: int = None
) -> UUID:
@@ -11375,6 +11442,27 @@ Optional[FlexibleScheduleList]
+
|
+
+
+ An optional list of schedules. Each item in the list can be:
+ - An instance of MinimalDeploymentSchedule .
+ - A dictionary with a schedule key, and optionally, an
+ active key. The schedule key should correspond to a
+ schedule type, and active is a boolean indicating whether
+ the schedule is active or not.
+ - An instance of one of the predefined schedule types:
+ IntervalSchedule , CronSchedule , or RRuleSchedule .
+
+ |
+
+ None
+ |
+
**kwargs |
@@ -11394,17 +11482,7 @@
Source code in prefect/deployments/deployments.py
- 928
- 929
- 930
- 931
- 932
- 933
- 934
- 935
- 936
- 937
- 938
+ 938
939
940
941
@@ -11489,7 +11567,30 @@ 1020
1021
1022
-1023 | @classmethod
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
| @classmethod
@sync_compatible
async def build_from_flow(
cls,
@@ -11500,6 +11601,7 @@ ignore_file: str = ".prefectignore",
apply: bool = False,
load_existing: bool = True,
+ schedules: Optional[FlexibleScheduleList] = None,
**kwargs,
) -> "Deployment":
"""
@@ -11519,6 +11621,14 @@ load_existing: if True, load any settings that may already be configured for
the named deployment server-side (e.g., schedules, default parameter
values, etc.)
+ schedules: An optional list of schedules. Each item in the list can be:
+ - An instance of `MinimalDeploymentSchedule`.
+ - A dictionary with a `schedule` key, and optionally, an
+ `active` key. The `schedule` key should correspond to a
+ schedule type, and `active` is a boolean indicating whether
+ the schedule is active or not.
+ - An instance of one of the predefined schedule types:
+ `IntervalSchedule`, `CronSchedule`, or `RRuleSchedule`.
**kwargs: other keyword arguments to pass to the constructor for the
`Deployment` class
"""
@@ -11527,7 +11637,11 @@ # note that `deployment.load` only updates settings that were *not*
# provided at initialization
- deployment = cls(name=name, **kwargs)
+ deployment = cls(
+ name=name,
+ schedules=schedules,
+ **kwargs,
+ )
deployment.flow_name = flow.name
if not deployment.entrypoint:
## first see if an entrypoint can be determined
@@ -11608,14 +11722,14 @@
Source code in prefect/deployments/deployments.py
- 612
-613
-614
-615
-616
+ | @validator("parameter_openapi_schema", pre=True)
+619
+620
+621
+622
+623
| @validator("parameter_openapi_schema", pre=True)
def handle_openapi_schema(cls, value):
"""
This method ensures setting a value of `None` is handled gracefully.
@@ -11676,17 +11790,7 @@
Source code in prefect/deployments/deployments.py
- 681
-682
-683
-684
-685
-686
-687
-688
-689
-690
-691
+ 691
692
693
694
@@ -11756,7 +11860,17 @@ 758
759
760
-761 | @sync_compatible
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
| @sync_compatible
async def load(self) -> bool:
"""
Queries the API for a deployment with this name for this flow, and if found,
@@ -11895,24 +12009,24 @@
Source code in prefect/deployments/deployments.py
- 763
-764
-765
-766
-767
-768
-769
-770
-771
-772
-773
+ 773
774
775
776
777
778
779
-780 | @sync_compatible
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
| @sync_compatible
async def update(self, ignore_none: bool = False, **kwargs):
"""
Performs an in-place update with the provided settings.
@@ -12005,17 +12119,7 @@
Source code in prefect/deployments/deployments.py
- 782
-783
-784
-785
-786
-787
-788
-789
-790
-791
-792
+ 792
793
794
795
@@ -12050,7 +12154,17 @@ 824
825
826
-827 | @sync_compatible
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
| @sync_compatible
async def upload_to_storage(
self, storage_block: str = None, ignore_file: str = ".prefectignore"
) -> Optional[int]:
@@ -12119,14 +12233,14 @@
Source code in prefect/deployments/deployments.py
- 621
-622
-623
-624
-625
+ | @validator("triggers")
+628
+629
+630
+631
+632
| @validator("triggers")
def validate_automation_names(cls, field_value, values, field, config):
"""Ensure that each trigger has a name for its automation if none is provided."""
for i, trigger in enumerate(field_value, start=1):
@@ -12167,11 +12281,7 @@
Source code in prefect/deployments/deployments.py
- 292
-293
-294
-295
-296
+ 296
297
298
299
@@ -12187,7 +12297,11 @@ 309
310
311
-312 | def load_deployments_from_yaml(
+312
+313
+314
+315
+316
| def load_deployments_from_yaml(
path: str,
) -> PrefectObjectRegistry:
"""
@@ -12237,11 +12351,7 @@
Source code in prefect/deployments/deployments.py
- 211
-212
-213
-214
-215
+ 215
216
217
218
@@ -12315,7 +12425,11 @@ 286
287
288
-289 | @inject_client
+289
+290
+291
+292
+293
| @inject_client
async def load_flow_from_flow_run(
flow_run: FlowRun,
client: PrefectClient,
@@ -12596,11 +12710,7 @@
Source code in prefect/deployments/deployments.py
- 60
- 61
- 62
- 63
- 64
+ 64
65
66
67
@@ -12744,7 +12854,11 @@
205
206
207
-208 | @sync_compatible
+208
+209
+210
+211
+212
| @sync_compatible
@inject_client
async def run_deployment(
name: Union[str, UUID],
diff --git a/versions/unreleased/api-ref/prefect/deployments/runner/index.html b/versions/unreleased/api-ref/prefect/deployments/runner/index.html
index 493617835e..afa0863fd1 100644
--- a/versions/unreleased/api-ref/prefect/deployments/runner/index.html
+++ b/versions/unreleased/api-ref/prefect/deployments/runner/index.html
@@ -16,7 +16,7 @@
-
+
@@ -4657,6 +4657,8 @@
+
+
@@ -4947,6 +4949,33 @@
+
+
+
+
+
+
+
+ schedules
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -9204,10 +9233,10 @@
Source code in prefect/deployments/runner.py
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|