prefect-client 2.16.7__py3-none-any.whl → 2.16.9__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/_internal/compatibility/experimental.py +9 -8
- prefect/_internal/concurrency/api.py +23 -42
- prefect/_internal/concurrency/waiters.py +25 -22
- prefect/_internal/pydantic/__init__.py +12 -3
- prefect/_internal/pydantic/_base_model.py +7 -4
- prefect/_internal/pydantic/_compat.py +39 -453
- prefect/_internal/pydantic/_flags.py +2 -0
- prefect/_internal/pydantic/_types.py +8 -0
- prefect/_internal/pydantic/utilities/__init__.py +0 -0
- prefect/_internal/pydantic/utilities/model_construct.py +56 -0
- prefect/_internal/pydantic/utilities/model_copy.py +55 -0
- prefect/_internal/pydantic/utilities/model_dump.py +136 -0
- prefect/_internal/pydantic/utilities/model_dump_json.py +112 -0
- prefect/_internal/pydantic/utilities/model_fields.py +50 -0
- prefect/_internal/pydantic/utilities/model_json_schema.py +82 -0
- prefect/_internal/pydantic/utilities/model_rebuild.py +80 -0
- prefect/_internal/pydantic/utilities/model_validate.py +75 -0
- prefect/_internal/pydantic/utilities/model_validate_json.py +68 -0
- prefect/_internal/pydantic/utilities/type_adapter.py +71 -0
- prefect/_internal/schemas/bases.py +1 -17
- prefect/_internal/schemas/validators.py +425 -4
- prefect/blocks/kubernetes.py +7 -3
- prefect/client/cloud.py +1 -1
- prefect/client/orchestration.py +8 -8
- prefect/client/schemas/actions.py +348 -285
- prefect/client/schemas/objects.py +47 -126
- prefect/client/schemas/responses.py +231 -57
- prefect/concurrency/events.py +2 -2
- prefect/context.py +2 -1
- prefect/deployments/base.py +4 -3
- prefect/deployments/runner.py +7 -25
- prefect/deprecated/packaging/base.py +5 -6
- prefect/deprecated/packaging/docker.py +19 -25
- prefect/deprecated/packaging/file.py +10 -5
- prefect/deprecated/packaging/orion.py +9 -4
- prefect/deprecated/packaging/serializers.py +8 -58
- prefect/engine.py +23 -22
- prefect/events/actions.py +16 -1
- prefect/events/related.py +4 -4
- prefect/events/schemas/automations.py +13 -2
- prefect/events/schemas/deployment_triggers.py +73 -5
- prefect/events/schemas/events.py +1 -1
- prefect/flows.py +3 -0
- prefect/infrastructure/provisioners/ecs.py +1 -0
- prefect/logging/configuration.py +2 -2
- prefect/pydantic/__init__.py +48 -2
- prefect/pydantic/main.py +2 -2
- prefect/serializers.py +6 -31
- prefect/settings.py +40 -17
- prefect/software/python.py +3 -5
- prefect/utilities/callables.py +1 -1
- prefect/utilities/collections.py +2 -1
- prefect/utilities/schema_tools/validation.py +2 -2
- prefect/workers/base.py +19 -10
- prefect/workers/block.py +3 -7
- prefect/workers/process.py +2 -5
- {prefect_client-2.16.7.dist-info → prefect_client-2.16.9.dist-info}/METADATA +3 -2
- {prefect_client-2.16.7.dist-info → prefect_client-2.16.9.dist-info}/RECORD +61 -50
- prefect/_internal/schemas/transformations.py +0 -106
- {prefect_client-2.16.7.dist-info → prefect_client-2.16.9.dist-info}/LICENSE +0 -0
- {prefect_client-2.16.7.dist-info → prefect_client-2.16.9.dist-info}/WHEEL +0 -0
- {prefect_client-2.16.7.dist-info → prefect_client-2.16.9.dist-info}/top_level.txt +0 -0
@@ -1,29 +1,31 @@
|
|
1
|
-
import
|
2
|
-
from copy import copy, deepcopy
|
1
|
+
from copy import deepcopy
|
3
2
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeVar, Union
|
4
|
-
from uuid import UUID
|
3
|
+
from uuid import UUID, uuid4
|
5
4
|
|
6
5
|
import jsonschema
|
7
6
|
|
8
7
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
9
8
|
|
10
9
|
if HAS_PYDANTIC_V2:
|
11
|
-
from pydantic.v1 import Field, root_validator, validator
|
10
|
+
from pydantic.v1 import Field, conint, root_validator, validator
|
12
11
|
else:
|
13
|
-
from pydantic import Field, root_validator, validator
|
12
|
+
from pydantic import Field, conint, root_validator, validator
|
14
13
|
|
15
14
|
import prefect.client.schemas.objects as objects
|
16
|
-
from prefect._internal.compatibility.experimental import experimental_field
|
17
15
|
from prefect._internal.schemas.bases import ActionBaseModel
|
18
16
|
from prefect._internal.schemas.fields import DateTimeTZ
|
19
17
|
from prefect._internal.schemas.serializers import orjson_dumps_extra_compatible
|
20
|
-
from prefect._internal.schemas.transformations import FieldFrom, copy_model_fields
|
21
18
|
from prefect._internal.schemas.validators import (
|
22
19
|
raise_on_name_alphanumeric_dashes_only,
|
23
20
|
raise_on_name_alphanumeric_underscores_only,
|
21
|
+
remove_old_deployment_fields,
|
22
|
+
return_none_schedule,
|
23
|
+
validate_message_template_variables,
|
24
|
+
validate_name_present_on_nonanonymous_blocks,
|
24
25
|
)
|
25
26
|
from prefect.client.schemas.objects import StateDetails, StateType
|
26
|
-
from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
27
|
+
from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
28
|
+
from prefect.utilities.collections import listrepr
|
27
29
|
from prefect.utilities.pydantic import get_class_fields_only
|
28
30
|
|
29
31
|
if TYPE_CHECKING:
|
@@ -67,79 +69,58 @@ class StateCreate(ActionBaseModel):
|
|
67
69
|
)
|
68
70
|
|
69
71
|
|
70
|
-
@copy_model_fields
|
71
72
|
class FlowCreate(ActionBaseModel):
|
72
73
|
"""Data used by the Prefect REST API to create a flow."""
|
73
74
|
|
74
|
-
name: str =
|
75
|
-
|
75
|
+
name: str = Field(
|
76
|
+
default=..., description="The name of the flow", example="my-flow"
|
77
|
+
)
|
78
|
+
tags: List[str] = Field(
|
79
|
+
default_factory=list,
|
80
|
+
description="A list of flow tags",
|
81
|
+
example=["tag-1", "tag-2"],
|
82
|
+
)
|
76
83
|
|
77
84
|
|
78
|
-
@copy_model_fields
|
79
85
|
class FlowUpdate(ActionBaseModel):
|
80
86
|
"""Data used by the Prefect REST API to update a flow."""
|
81
87
|
|
82
|
-
tags: List[str] =
|
88
|
+
tags: List[str] = Field(
|
89
|
+
default_factory=list,
|
90
|
+
description="A list of flow tags",
|
91
|
+
example=["tag-1", "tag-2"],
|
92
|
+
)
|
83
93
|
|
84
94
|
|
85
|
-
@copy_model_fields
|
86
95
|
class DeploymentScheduleCreate(ActionBaseModel):
|
87
|
-
|
88
|
-
|
96
|
+
schedule: SCHEDULE_TYPES = Field(
|
97
|
+
default=..., description="The schedule for the deployment."
|
98
|
+
)
|
99
|
+
active: bool = Field(
|
100
|
+
default=True, description="Whether or not the schedule is active."
|
101
|
+
)
|
89
102
|
|
90
103
|
|
91
|
-
@copy_model_fields
|
92
104
|
class DeploymentScheduleUpdate(ActionBaseModel):
|
93
|
-
|
94
|
-
|
105
|
+
schedule: Optional[SCHEDULE_TYPES] = Field(
|
106
|
+
default=None, description="The schedule for the deployment."
|
107
|
+
)
|
108
|
+
active: bool = Field(
|
109
|
+
default=True, description="Whether or not the schedule is active."
|
110
|
+
)
|
95
111
|
|
96
112
|
|
97
|
-
@experimental_field(
|
98
|
-
"work_pool_name",
|
99
|
-
group="work_pools",
|
100
|
-
when=lambda x: x is not None,
|
101
|
-
)
|
102
|
-
@copy_model_fields
|
103
113
|
class DeploymentCreate(ActionBaseModel):
|
104
114
|
"""Data used by the Prefect REST API to create a deployment."""
|
105
115
|
|
106
116
|
@root_validator(pre=True)
|
107
117
|
def remove_old_fields(cls, values):
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
worker_pool_name = values_copy.pop("worker_pool_name", None)
|
115
|
-
worker_pool_queue_name = values_copy.pop("worker_pool_queue_name", None)
|
116
|
-
work_pool_queue_name = values_copy.pop("work_pool_queue_name", None)
|
117
|
-
if worker_pool_queue_id:
|
118
|
-
warnings.warn(
|
119
|
-
(
|
120
|
-
"`worker_pool_queue_id` is no longer supported for creating "
|
121
|
-
"deployments. Please use `work_pool_name` and "
|
122
|
-
"`work_queue_name` instead."
|
123
|
-
),
|
124
|
-
UserWarning,
|
125
|
-
)
|
126
|
-
if worker_pool_name or worker_pool_queue_name or work_pool_queue_name:
|
127
|
-
warnings.warn(
|
128
|
-
(
|
129
|
-
"`worker_pool_name`, `worker_pool_queue_name`, and "
|
130
|
-
"`work_pool_name` are"
|
131
|
-
"no longer supported for creating "
|
132
|
-
"deployments. Please use `work_pool_name` and "
|
133
|
-
"`work_queue_name` instead."
|
134
|
-
),
|
135
|
-
UserWarning,
|
136
|
-
)
|
137
|
-
return values_copy
|
138
|
-
|
139
|
-
name: str = FieldFrom(objects.Deployment)
|
140
|
-
flow_id: UUID = FieldFrom(objects.Deployment)
|
141
|
-
is_schedule_active: Optional[bool] = FieldFrom(objects.Deployment)
|
142
|
-
paused: Optional[bool] = FieldFrom(objects.Deployment)
|
118
|
+
return remove_old_deployment_fields(values)
|
119
|
+
|
120
|
+
name: str = Field(..., description="The name of the deployment.")
|
121
|
+
flow_id: UUID = Field(..., description="The ID of the flow to deploy.")
|
122
|
+
is_schedule_active: Optional[bool] = Field(None)
|
123
|
+
paused: Optional[bool] = Field(None)
|
143
124
|
schedules: List[DeploymentScheduleCreate] = Field(
|
144
125
|
default_factory=list,
|
145
126
|
description="A list of schedules for the deployment.",
|
@@ -150,26 +131,29 @@ class DeploymentCreate(ActionBaseModel):
|
|
150
131
|
"Whether or not the deployment should enforce the parameter schema."
|
151
132
|
),
|
152
133
|
)
|
153
|
-
parameter_openapi_schema: Optional[Dict[str, Any]] =
|
154
|
-
parameters: Dict[str, Any] =
|
155
|
-
|
156
|
-
|
134
|
+
parameter_openapi_schema: Optional[Dict[str, Any]] = Field(None)
|
135
|
+
parameters: Dict[str, Any] = Field(
|
136
|
+
default_factory=dict,
|
137
|
+
description="Parameters for flow runs scheduled by the deployment.",
|
138
|
+
)
|
139
|
+
tags: List[str] = Field(default_factory=list)
|
140
|
+
pull_steps: Optional[List[dict]] = Field(None)
|
157
141
|
|
158
|
-
manifest_path: Optional[str] =
|
159
|
-
work_queue_name: Optional[str] =
|
142
|
+
manifest_path: Optional[str] = Field(None)
|
143
|
+
work_queue_name: Optional[str] = Field(None)
|
160
144
|
work_pool_name: Optional[str] = Field(
|
161
145
|
default=None,
|
162
146
|
description="The name of the deployment's work pool.",
|
163
147
|
example="my-work-pool",
|
164
148
|
)
|
165
|
-
storage_document_id: Optional[UUID] =
|
166
|
-
infrastructure_document_id: Optional[UUID] =
|
167
|
-
schedule: Optional[SCHEDULE_TYPES] =
|
168
|
-
description: Optional[str] =
|
169
|
-
path: Optional[str] =
|
170
|
-
version: Optional[str] =
|
171
|
-
entrypoint: Optional[str] =
|
172
|
-
infra_overrides: Optional[Dict[str, Any]] =
|
149
|
+
storage_document_id: Optional[UUID] = Field(None)
|
150
|
+
infrastructure_document_id: Optional[UUID] = Field(None)
|
151
|
+
schedule: Optional[SCHEDULE_TYPES] = Field(None)
|
152
|
+
description: Optional[str] = Field(None)
|
153
|
+
path: Optional[str] = Field(None)
|
154
|
+
version: Optional[str] = Field(None)
|
155
|
+
entrypoint: Optional[str] = Field(None)
|
156
|
+
infra_overrides: Optional[Dict[str, Any]] = Field(None)
|
173
157
|
|
174
158
|
def check_valid_configuration(self, base_job_template: dict):
|
175
159
|
"""Check that the combination of base_job_template defaults
|
@@ -191,75 +175,38 @@ class DeploymentCreate(ActionBaseModel):
|
|
191
175
|
jsonschema.validate(self.infra_overrides, variables_schema)
|
192
176
|
|
193
177
|
|
194
|
-
@experimental_field(
|
195
|
-
"work_pool_name",
|
196
|
-
group="work_pools",
|
197
|
-
when=lambda x: x is not None,
|
198
|
-
)
|
199
|
-
@copy_model_fields
|
200
178
|
class DeploymentUpdate(ActionBaseModel):
|
201
179
|
"""Data used by the Prefect REST API to update a deployment."""
|
202
180
|
|
203
181
|
@root_validator(pre=True)
|
204
182
|
def remove_old_fields(cls, values):
|
205
|
-
|
206
|
-
# worker_pool_queue_name. Those fields were later renamed to work_pool_name
|
207
|
-
# and work_queue_name. This validator removes old fields provided
|
208
|
-
# by older clients to avoid 422 errors.
|
209
|
-
values_copy = copy(values)
|
210
|
-
worker_pool_queue_id = values_copy.pop("worker_pool_queue_id", None)
|
211
|
-
worker_pool_name = values_copy.pop("worker_pool_name", None)
|
212
|
-
worker_pool_queue_name = values_copy.pop("worker_pool_queue_name", None)
|
213
|
-
work_pool_queue_name = values_copy.pop("work_pool_queue_name", None)
|
214
|
-
if worker_pool_queue_id:
|
215
|
-
warnings.warn(
|
216
|
-
(
|
217
|
-
"`worker_pool_queue_id` is no longer supported for updating "
|
218
|
-
"deployments. Please use `work_pool_name` and "
|
219
|
-
"`work_queue_name` instead."
|
220
|
-
),
|
221
|
-
UserWarning,
|
222
|
-
)
|
223
|
-
if worker_pool_name or worker_pool_queue_name or work_pool_queue_name:
|
224
|
-
warnings.warn(
|
225
|
-
(
|
226
|
-
"`worker_pool_name`, `worker_pool_queue_name`, and "
|
227
|
-
"`work_pool_name` are"
|
228
|
-
"no longer supported for creating "
|
229
|
-
"deployments. Please use `work_pool_name` and "
|
230
|
-
"`work_queue_name` instead."
|
231
|
-
),
|
232
|
-
UserWarning,
|
233
|
-
)
|
234
|
-
return values_copy
|
183
|
+
return remove_old_deployment_fields(values)
|
235
184
|
|
236
185
|
@validator("schedule")
|
237
|
-
def
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
description: Optional[str] = FieldFrom(objects.Deployment)
|
245
|
-
is_schedule_active: bool = FieldFrom(objects.Deployment)
|
186
|
+
def validate_none_schedule(cls, v):
|
187
|
+
return return_none_schedule(v)
|
188
|
+
|
189
|
+
version: Optional[str] = Field(None)
|
190
|
+
schedule: Optional[SCHEDULE_TYPES] = Field(None)
|
191
|
+
description: Optional[str] = Field(None)
|
192
|
+
is_schedule_active: bool = Field(None)
|
246
193
|
parameters: Optional[Dict[str, Any]] = Field(
|
247
194
|
default=None,
|
248
195
|
description="Parameters for flow runs scheduled by the deployment.",
|
249
196
|
)
|
250
|
-
tags: List[str] =
|
251
|
-
work_queue_name: Optional[str] =
|
197
|
+
tags: List[str] = Field(default_factory=list)
|
198
|
+
work_queue_name: Optional[str] = Field(None)
|
252
199
|
work_pool_name: Optional[str] = Field(
|
253
200
|
default=None,
|
254
201
|
description="The name of the deployment's work pool.",
|
255
202
|
example="my-work-pool",
|
256
203
|
)
|
257
|
-
path: Optional[str] =
|
258
|
-
infra_overrides: Optional[Dict[str, Any]] =
|
259
|
-
entrypoint: Optional[str] =
|
260
|
-
manifest_path: Optional[str] =
|
261
|
-
storage_document_id: Optional[UUID] =
|
262
|
-
infrastructure_document_id: Optional[UUID] =
|
204
|
+
path: Optional[str] = Field(None)
|
205
|
+
infra_overrides: Optional[Dict[str, Any]] = Field(None)
|
206
|
+
entrypoint: Optional[str] = Field(None)
|
207
|
+
manifest_path: Optional[str] = Field(None)
|
208
|
+
storage_document_id: Optional[UUID] = Field(None)
|
209
|
+
infrastructure_document_id: Optional[UUID] = Field(None)
|
263
210
|
enforce_parameter_schema: Optional[bool] = Field(
|
264
211
|
default=None,
|
265
212
|
description=(
|
@@ -288,20 +235,20 @@ class DeploymentUpdate(ActionBaseModel):
|
|
288
235
|
jsonschema.validate(self.infra_overrides, variables_schema)
|
289
236
|
|
290
237
|
|
291
|
-
@copy_model_fields
|
292
238
|
class FlowRunUpdate(ActionBaseModel):
|
293
239
|
"""Data used by the Prefect REST API to update a flow run."""
|
294
240
|
|
295
|
-
name: Optional[str] =
|
296
|
-
flow_version: Optional[str] =
|
297
|
-
parameters:
|
298
|
-
empirical_policy: objects.FlowRunPolicy =
|
299
|
-
|
300
|
-
|
301
|
-
|
241
|
+
name: Optional[str] = Field(None)
|
242
|
+
flow_version: Optional[str] = Field(None)
|
243
|
+
parameters: Optional[Dict[str, Any]] = Field(None)
|
244
|
+
empirical_policy: objects.FlowRunPolicy = Field(
|
245
|
+
default_factory=objects.FlowRunPolicy
|
246
|
+
)
|
247
|
+
tags: List[str] = Field(default_factory=list)
|
248
|
+
infrastructure_pid: Optional[str] = Field(None)
|
249
|
+
job_variables: Optional[Dict[str, Any]] = Field(None)
|
302
250
|
|
303
251
|
|
304
|
-
@copy_model_fields
|
305
252
|
class TaskRunCreate(ActionBaseModel):
|
306
253
|
"""Data used by the Prefect REST API to create a task run"""
|
307
254
|
|
@@ -310,15 +257,28 @@ class TaskRunCreate(ActionBaseModel):
|
|
310
257
|
default=None, description="The state of the task run to create"
|
311
258
|
)
|
312
259
|
|
313
|
-
name: str =
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
260
|
+
name: Optional[str] = Field(
|
261
|
+
default=None,
|
262
|
+
description="The name of the task run",
|
263
|
+
)
|
264
|
+
flow_run_id: Optional[UUID] = Field(None)
|
265
|
+
task_key: str = Field(
|
266
|
+
default=..., description="A unique identifier for the task being run."
|
267
|
+
)
|
268
|
+
dynamic_key: str = Field(
|
269
|
+
default=...,
|
270
|
+
description=(
|
271
|
+
"A dynamic key used to differentiate between multiple runs of the same task"
|
272
|
+
" within the same flow run."
|
273
|
+
),
|
274
|
+
)
|
275
|
+
cache_key: Optional[str] = Field(None)
|
276
|
+
cache_expiration: Optional[objects.DateTimeTZ] = Field(None)
|
277
|
+
task_version: Optional[str] = Field(None)
|
278
|
+
empirical_policy: objects.TaskRunPolicy = Field(
|
279
|
+
default_factory=objects.TaskRunPolicy,
|
280
|
+
)
|
281
|
+
tags: List[str] = Field(default_factory=list)
|
322
282
|
task_inputs: Dict[
|
323
283
|
str,
|
324
284
|
List[
|
@@ -328,17 +288,15 @@ class TaskRunCreate(ActionBaseModel):
|
|
328
288
|
objects.Constant,
|
329
289
|
]
|
330
290
|
],
|
331
|
-
] =
|
291
|
+
] = Field(default_factory=dict)
|
332
292
|
|
333
293
|
|
334
|
-
@copy_model_fields
|
335
294
|
class TaskRunUpdate(ActionBaseModel):
|
336
295
|
"""Data used by the Prefect REST API to update a task run"""
|
337
296
|
|
338
|
-
name: str =
|
297
|
+
name: Optional[str] = Field(None)
|
339
298
|
|
340
299
|
|
341
|
-
@copy_model_fields
|
342
300
|
class FlowRunCreate(ActionBaseModel):
|
343
301
|
"""Data used by the Prefect REST API to create a flow run."""
|
344
302
|
|
@@ -347,23 +305,28 @@ class FlowRunCreate(ActionBaseModel):
|
|
347
305
|
default=None, description="The state of the flow run to create"
|
348
306
|
)
|
349
307
|
|
350
|
-
name: str =
|
351
|
-
flow_id: UUID =
|
352
|
-
deployment_id: Optional[UUID] =
|
353
|
-
flow_version: Optional[str] =
|
354
|
-
parameters:
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
308
|
+
name: Optional[str] = Field(default=None, description="The name of the flow run.")
|
309
|
+
flow_id: UUID = Field(default=..., description="The id of the flow being run.")
|
310
|
+
deployment_id: Optional[UUID] = Field(None)
|
311
|
+
flow_version: Optional[str] = Field(None)
|
312
|
+
parameters: Dict[str, Any] = Field(
|
313
|
+
default_factory=dict, description="The parameters for the flow run."
|
314
|
+
)
|
315
|
+
context: Dict[str, Any] = Field(
|
316
|
+
default_factory=dict, description="The context for the flow run."
|
317
|
+
)
|
318
|
+
parent_task_run_id: Optional[UUID] = Field(None)
|
319
|
+
infrastructure_document_id: Optional[UUID] = Field(None)
|
320
|
+
empirical_policy: objects.FlowRunPolicy = Field(
|
321
|
+
default_factory=objects.FlowRunPolicy
|
322
|
+
)
|
323
|
+
tags: List[str] = Field(default_factory=list)
|
324
|
+
idempotency_key: Optional[str] = Field(None)
|
361
325
|
|
362
326
|
class Config(ActionBaseModel.Config):
|
363
327
|
json_dumps = orjson_dumps_extra_compatible
|
364
328
|
|
365
329
|
|
366
|
-
@copy_model_fields
|
367
330
|
class DeploymentFlowRunCreate(ActionBaseModel):
|
368
331
|
"""Data used by the Prefect REST API to create a flow run from a deployment."""
|
369
332
|
|
@@ -372,44 +335,61 @@ class DeploymentFlowRunCreate(ActionBaseModel):
|
|
372
335
|
default=None, description="The state of the flow run to create"
|
373
336
|
)
|
374
337
|
|
375
|
-
name: Optional[str] =
|
376
|
-
parameters:
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
338
|
+
name: Optional[str] = Field(default=None, description="The name of the flow run.")
|
339
|
+
parameters: Dict[str, Any] = Field(
|
340
|
+
default_factory=dict, description="The parameters for the flow run."
|
341
|
+
)
|
342
|
+
context: Dict[str, Any] = Field(
|
343
|
+
default_factory=dict, description="The context for the flow run."
|
344
|
+
)
|
345
|
+
infrastructure_document_id: Optional[UUID] = Field(None)
|
346
|
+
empirical_policy: objects.FlowRunPolicy = Field(
|
347
|
+
default_factory=objects.FlowRunPolicy
|
348
|
+
)
|
349
|
+
tags: List[str] = Field(default_factory=list)
|
350
|
+
idempotency_key: Optional[str] = Field(None)
|
351
|
+
parent_task_run_id: Optional[UUID] = Field(None)
|
352
|
+
work_queue_name: Optional[str] = Field(None)
|
353
|
+
job_variables: Optional[dict] = Field(None)
|
385
354
|
|
386
355
|
|
387
|
-
@copy_model_fields
|
388
356
|
class SavedSearchCreate(ActionBaseModel):
|
389
357
|
"""Data used by the Prefect REST API to create a saved search."""
|
390
358
|
|
391
|
-
name: str =
|
392
|
-
filters: List[objects.SavedSearchFilter] =
|
359
|
+
name: str = Field(default=..., description="The name of the saved search.")
|
360
|
+
filters: List[objects.SavedSearchFilter] = Field(
|
361
|
+
default_factory=list, description="The filter set for the saved search."
|
362
|
+
)
|
393
363
|
|
394
364
|
|
395
|
-
@copy_model_fields
|
396
365
|
class ConcurrencyLimitCreate(ActionBaseModel):
|
397
366
|
"""Data used by the Prefect REST API to create a concurrency limit."""
|
398
367
|
|
399
|
-
tag: str =
|
400
|
-
|
368
|
+
tag: str = Field(
|
369
|
+
default=..., description="A tag the concurrency limit is applied to."
|
370
|
+
)
|
371
|
+
concurrency_limit: int = Field(default=..., description="The concurrency limit.")
|
401
372
|
|
402
373
|
|
403
|
-
@copy_model_fields
|
404
374
|
class BlockTypeCreate(ActionBaseModel):
|
405
375
|
"""Data used by the Prefect REST API to create a block type."""
|
406
376
|
|
407
|
-
name: str =
|
408
|
-
slug: str =
|
409
|
-
logo_url: Optional[objects.HttpUrl] =
|
410
|
-
|
411
|
-
|
412
|
-
|
377
|
+
name: str = Field(default=..., description="A block type's name")
|
378
|
+
slug: str = Field(default=..., description="A block type's slug")
|
379
|
+
logo_url: Optional[objects.HttpUrl] = Field(
|
380
|
+
default=None, description="Web URL for the block type's logo"
|
381
|
+
)
|
382
|
+
documentation_url: Optional[objects.HttpUrl] = Field(
|
383
|
+
default=None, description="Web URL for the block type's documentation"
|
384
|
+
)
|
385
|
+
description: Optional[str] = Field(
|
386
|
+
default=None,
|
387
|
+
description="A short blurb about the corresponding block's intended use",
|
388
|
+
)
|
389
|
+
code_example: Optional[str] = Field(
|
390
|
+
default=None,
|
391
|
+
description="A code snippet demonstrating use of the corresponding block",
|
392
|
+
)
|
413
393
|
|
414
394
|
# validators
|
415
395
|
_validate_slug_format = validator("slug", allow_reuse=True)(
|
@@ -417,39 +397,58 @@ class BlockTypeCreate(ActionBaseModel):
|
|
417
397
|
)
|
418
398
|
|
419
399
|
|
420
|
-
@copy_model_fields
|
421
400
|
class BlockTypeUpdate(ActionBaseModel):
|
422
401
|
"""Data used by the Prefect REST API to update a block type."""
|
423
402
|
|
424
|
-
logo_url: Optional[objects.HttpUrl] =
|
425
|
-
documentation_url: Optional[objects.HttpUrl] =
|
426
|
-
description: Optional[str] =
|
427
|
-
code_example: Optional[str] =
|
403
|
+
logo_url: Optional[objects.HttpUrl] = Field(None)
|
404
|
+
documentation_url: Optional[objects.HttpUrl] = Field(None)
|
405
|
+
description: Optional[str] = Field(None)
|
406
|
+
code_example: Optional[str] = Field(None)
|
428
407
|
|
429
408
|
@classmethod
|
430
409
|
def updatable_fields(cls) -> set:
|
431
410
|
return get_class_fields_only(cls)
|
432
411
|
|
433
412
|
|
434
|
-
@copy_model_fields
|
435
413
|
class BlockSchemaCreate(ActionBaseModel):
|
436
414
|
"""Data used by the Prefect REST API to create a block schema."""
|
437
415
|
|
438
|
-
fields:
|
439
|
-
|
440
|
-
|
441
|
-
|
416
|
+
fields: Dict[str, Any] = Field(
|
417
|
+
default_factory=dict, description="The block schema's field schema"
|
418
|
+
)
|
419
|
+
block_type_id: Optional[UUID] = Field(None)
|
420
|
+
capabilities: List[str] = Field(
|
421
|
+
default_factory=list,
|
422
|
+
description="A list of Block capabilities",
|
423
|
+
)
|
424
|
+
version: str = Field(
|
425
|
+
default=objects.DEFAULT_BLOCK_SCHEMA_VERSION,
|
426
|
+
description="Human readable identifier for the block schema",
|
427
|
+
)
|
442
428
|
|
443
429
|
|
444
|
-
@copy_model_fields
|
445
430
|
class BlockDocumentCreate(ActionBaseModel):
|
446
431
|
"""Data used by the Prefect REST API to create a block document."""
|
447
432
|
|
448
|
-
name: Optional[str] =
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
433
|
+
name: Optional[str] = Field(
|
434
|
+
default=None, description="The name of the block document"
|
435
|
+
)
|
436
|
+
data: Dict[str, Any] = Field(
|
437
|
+
default_factory=dict, description="The block document's data"
|
438
|
+
)
|
439
|
+
block_schema_id: UUID = Field(
|
440
|
+
default=..., description="The block schema ID for the block document"
|
441
|
+
)
|
442
|
+
block_type_id: UUID = Field(
|
443
|
+
default=..., description="The block type ID for the block document"
|
444
|
+
)
|
445
|
+
is_anonymous: bool = Field(
|
446
|
+
default=False,
|
447
|
+
description=(
|
448
|
+
"Whether the block is anonymous (anonymous blocks are usually created by"
|
449
|
+
" Prefect automatically)"
|
450
|
+
),
|
451
|
+
)
|
453
452
|
|
454
453
|
_validate_name_format = validator("name", allow_reuse=True)(
|
455
454
|
validate_block_document_name
|
@@ -457,75 +456,95 @@ class BlockDocumentCreate(ActionBaseModel):
|
|
457
456
|
|
458
457
|
@root_validator
|
459
458
|
def validate_name_is_present_if_not_anonymous(cls, values):
|
460
|
-
|
461
|
-
if not values.get("is_anonymous") and not values.get("name"):
|
462
|
-
raise ValueError("Names must be provided for block documents.")
|
463
|
-
return values
|
459
|
+
return validate_name_present_on_nonanonymous_blocks(values)
|
464
460
|
|
465
461
|
|
466
|
-
@copy_model_fields
|
467
462
|
class BlockDocumentUpdate(ActionBaseModel):
|
468
463
|
"""Data used by the Prefect REST API to update a block document."""
|
469
464
|
|
470
465
|
block_schema_id: Optional[UUID] = Field(
|
471
466
|
default=None, description="A block schema ID"
|
472
467
|
)
|
473
|
-
data:
|
474
|
-
|
468
|
+
data: Dict[str, Any] = Field(
|
469
|
+
default_factory=dict, description="The block document's data"
|
470
|
+
)
|
471
|
+
merge_existing_data: bool = Field(
|
472
|
+
default=True,
|
473
|
+
description="Whether to merge the existing data with the new data or replace it",
|
474
|
+
)
|
475
475
|
|
476
476
|
|
477
|
-
@copy_model_fields
|
478
477
|
class BlockDocumentReferenceCreate(ActionBaseModel):
|
479
478
|
"""Data used to create block document reference."""
|
480
479
|
|
481
|
-
id: UUID =
|
482
|
-
parent_block_document_id: UUID =
|
483
|
-
|
484
|
-
|
480
|
+
id: UUID = Field(default_factory=uuid4)
|
481
|
+
parent_block_document_id: UUID = Field(
|
482
|
+
default=..., description="ID of block document the reference is nested within"
|
483
|
+
)
|
484
|
+
reference_block_document_id: UUID = Field(
|
485
|
+
default=..., description="ID of the nested block document"
|
486
|
+
)
|
487
|
+
name: str = Field(
|
488
|
+
default=..., description="The name that the reference is nested under"
|
489
|
+
)
|
485
490
|
|
486
491
|
|
487
|
-
@copy_model_fields
|
488
492
|
class LogCreate(ActionBaseModel):
|
489
493
|
"""Data used by the Prefect REST API to create a log."""
|
490
494
|
|
491
|
-
name: str =
|
492
|
-
level: int =
|
493
|
-
message: str =
|
494
|
-
timestamp:
|
495
|
-
flow_run_id: Optional[UUID] =
|
496
|
-
task_run_id: Optional[UUID] =
|
495
|
+
name: str = Field(default=..., description="The logger name.")
|
496
|
+
level: int = Field(default=..., description="The log level.")
|
497
|
+
message: str = Field(default=..., description="The log message.")
|
498
|
+
timestamp: DateTimeTZ = Field(default=..., description="The log timestamp.")
|
499
|
+
flow_run_id: Optional[UUID] = Field(None)
|
500
|
+
task_run_id: Optional[UUID] = Field(None)
|
497
501
|
|
498
502
|
|
499
|
-
@copy_model_fields
|
500
503
|
class WorkPoolCreate(ActionBaseModel):
|
501
504
|
"""Data used by the Prefect REST API to create a work pool."""
|
502
505
|
|
503
|
-
name: str =
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
506
|
+
name: str = Field(
|
507
|
+
description="The name of the work pool.",
|
508
|
+
)
|
509
|
+
description: Optional[str] = Field(None)
|
510
|
+
type: str = Field(
|
511
|
+
description="The work pool type.", default="prefect-agent"
|
512
|
+
) # TODO: change default
|
513
|
+
base_job_template: Dict[str, Any] = Field(
|
514
|
+
default_factory=dict,
|
515
|
+
description="The base job template for the work pool.",
|
516
|
+
)
|
517
|
+
is_paused: bool = Field(
|
518
|
+
default=False,
|
519
|
+
description="Whether the work pool is paused.",
|
520
|
+
)
|
521
|
+
concurrency_limit: Optional[conint(ge=0)] = Field(
|
522
|
+
default=None, description="A concurrency limit for the work pool."
|
523
|
+
)
|
509
524
|
|
510
525
|
|
511
|
-
@copy_model_fields
|
512
526
|
class WorkPoolUpdate(ActionBaseModel):
|
513
527
|
"""Data used by the Prefect REST API to update a work pool."""
|
514
528
|
|
515
|
-
description: Optional[str] =
|
516
|
-
is_paused: Optional[bool] =
|
517
|
-
base_job_template: Optional[Dict[str, Any]] =
|
518
|
-
concurrency_limit: Optional[int] =
|
529
|
+
description: Optional[str] = Field(None)
|
530
|
+
is_paused: Optional[bool] = Field(None)
|
531
|
+
base_job_template: Optional[Dict[str, Any]] = Field(None)
|
532
|
+
concurrency_limit: Optional[int] = Field(None)
|
519
533
|
|
520
534
|
|
521
|
-
@copy_model_fields
|
522
535
|
class WorkQueueCreate(ActionBaseModel):
|
523
536
|
"""Data used by the Prefect REST API to create a work queue."""
|
524
537
|
|
525
|
-
name: str =
|
526
|
-
description: Optional[str] =
|
527
|
-
is_paused: bool =
|
528
|
-
|
538
|
+
name: str = Field(default=..., description="The name of the work queue.")
|
539
|
+
description: Optional[str] = Field(None)
|
540
|
+
is_paused: bool = Field(
|
541
|
+
default=False,
|
542
|
+
description="Whether the work queue is paused.",
|
543
|
+
)
|
544
|
+
concurrency_limit: Optional[int] = Field(
|
545
|
+
default=None,
|
546
|
+
description="A concurrency limit for the work queue.",
|
547
|
+
)
|
529
548
|
priority: Optional[int] = Field(
|
530
549
|
default=None,
|
531
550
|
description=(
|
@@ -542,16 +561,17 @@ class WorkQueueCreate(ActionBaseModel):
|
|
542
561
|
)
|
543
562
|
|
544
563
|
|
545
|
-
@copy_model_fields
|
546
564
|
class WorkQueueUpdate(ActionBaseModel):
|
547
565
|
"""Data used by the Prefect REST API to update a work queue."""
|
548
566
|
|
549
|
-
name: str =
|
550
|
-
description: Optional[str] =
|
551
|
-
is_paused: bool =
|
552
|
-
|
553
|
-
|
554
|
-
|
567
|
+
name: Optional[str] = Field(None)
|
568
|
+
description: Optional[str] = Field(None)
|
569
|
+
is_paused: bool = Field(
|
570
|
+
default=False, description="Whether or not the work queue is paused."
|
571
|
+
)
|
572
|
+
concurrency_limit: Optional[int] = Field(None)
|
573
|
+
priority: Optional[int] = Field(None)
|
574
|
+
last_polled: Optional[DateTimeTZ] = Field(None)
|
555
575
|
|
556
576
|
# DEPRECATED
|
557
577
|
|
@@ -562,67 +582,95 @@ class WorkQueueUpdate(ActionBaseModel):
|
|
562
582
|
)
|
563
583
|
|
564
584
|
|
565
|
-
@copy_model_fields
|
566
585
|
class FlowRunNotificationPolicyCreate(ActionBaseModel):
|
567
586
|
"""Data used by the Prefect REST API to create a flow run notification policy."""
|
568
587
|
|
569
|
-
is_active: bool =
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
588
|
+
is_active: bool = Field(
|
589
|
+
default=True, description="Whether the policy is currently active"
|
590
|
+
)
|
591
|
+
state_names: List[str] = Field(
|
592
|
+
default=..., description="The flow run states that trigger notifications"
|
593
|
+
)
|
594
|
+
tags: List[str] = Field(
|
595
|
+
default=...,
|
596
|
+
description="The flow run tags that trigger notifications (set [] to disable)",
|
597
|
+
)
|
598
|
+
block_document_id: UUID = Field(
|
599
|
+
default=..., description="The block document ID used for sending notifications"
|
600
|
+
)
|
601
|
+
message_template: Optional[str] = Field(
|
602
|
+
default=None,
|
603
|
+
description=(
|
604
|
+
"A templatable notification message. Use {braces} to add variables."
|
605
|
+
" Valid variables include:"
|
606
|
+
f" {listrepr(sorted(objects.FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS), sep=', ')}"
|
607
|
+
),
|
608
|
+
example=(
|
609
|
+
"Flow run {flow_run_name} with id {flow_run_id} entered state"
|
610
|
+
" {flow_run_state_name}."
|
611
|
+
),
|
612
|
+
)
|
613
|
+
|
614
|
+
@validator("message_template")
|
615
|
+
def validate_message_template_variables(cls, v):
|
616
|
+
return validate_message_template_variables(v)
|
574
617
|
|
575
618
|
|
576
|
-
@copy_model_fields
|
577
619
|
class FlowRunNotificationPolicyUpdate(ActionBaseModel):
|
578
620
|
"""Data used by the Prefect REST API to update a flow run notification policy."""
|
579
621
|
|
580
|
-
is_active: Optional[bool] =
|
581
|
-
state_names: Optional[List[str]] =
|
582
|
-
tags: Optional[List[str]] =
|
583
|
-
block_document_id: Optional[UUID] =
|
584
|
-
message_template: Optional[str] =
|
622
|
+
is_active: Optional[bool] = Field(None)
|
623
|
+
state_names: Optional[List[str]] = Field(None)
|
624
|
+
tags: Optional[List[str]] = Field(None)
|
625
|
+
block_document_id: Optional[UUID] = Field(None)
|
626
|
+
message_template: Optional[str] = Field(None)
|
585
627
|
|
586
628
|
|
587
|
-
@copy_model_fields
|
588
629
|
class ArtifactCreate(ActionBaseModel):
|
589
630
|
"""Data used by the Prefect REST API to create an artifact."""
|
590
631
|
|
591
|
-
key: Optional[str] =
|
592
|
-
type: Optional[str] =
|
593
|
-
description: Optional[str] =
|
594
|
-
data: Optional[Union[Dict[str, Any], Any]] =
|
595
|
-
metadata_: Optional[Dict[str, str]] =
|
596
|
-
flow_run_id: Optional[UUID] =
|
597
|
-
task_run_id: Optional[UUID] =
|
632
|
+
key: Optional[str] = Field(None)
|
633
|
+
type: Optional[str] = Field(None)
|
634
|
+
description: Optional[str] = Field(None)
|
635
|
+
data: Optional[Union[Dict[str, Any], Any]] = Field(None)
|
636
|
+
metadata_: Optional[Dict[str, str]] = Field(None)
|
637
|
+
flow_run_id: Optional[UUID] = Field(None)
|
638
|
+
task_run_id: Optional[UUID] = Field(None)
|
598
639
|
|
599
640
|
_validate_artifact_format = validator("key", allow_reuse=True)(
|
600
641
|
validate_artifact_key
|
601
642
|
)
|
602
643
|
|
603
644
|
|
604
|
-
@copy_model_fields
|
605
645
|
class ArtifactUpdate(ActionBaseModel):
|
606
646
|
"""Data used by the Prefect REST API to update an artifact."""
|
607
647
|
|
608
|
-
data: Optional[Union[Dict[str, Any], Any]] =
|
609
|
-
description: Optional[str] =
|
610
|
-
metadata_: Optional[Dict[str, str]] =
|
648
|
+
data: Optional[Union[Dict[str, Any], Any]] = Field(None)
|
649
|
+
description: Optional[str] = Field(None)
|
650
|
+
metadata_: Optional[Dict[str, str]] = Field(None)
|
611
651
|
|
612
652
|
|
613
|
-
@copy_model_fields
|
614
653
|
class VariableCreate(ActionBaseModel):
|
615
654
|
"""Data used by the Prefect REST API to create a Variable."""
|
616
655
|
|
617
|
-
name: str =
|
618
|
-
|
619
|
-
|
656
|
+
name: str = Field(
|
657
|
+
default=...,
|
658
|
+
description="The name of the variable",
|
659
|
+
example="my_variable",
|
660
|
+
max_length=objects.MAX_VARIABLE_NAME_LENGTH,
|
661
|
+
)
|
662
|
+
value: str = Field(
|
663
|
+
default=...,
|
664
|
+
description="The value of the variable",
|
665
|
+
example="my-value",
|
666
|
+
max_length=objects.MAX_VARIABLE_VALUE_LENGTH,
|
667
|
+
)
|
668
|
+
tags: Optional[List[str]] = Field(default=None)
|
620
669
|
|
621
670
|
# validators
|
622
671
|
_validate_name_format = validator("name", allow_reuse=True)(validate_variable_name)
|
623
672
|
|
624
673
|
|
625
|
-
@copy_model_fields
|
626
674
|
class VariableUpdate(ActionBaseModel):
|
627
675
|
"""Data used by the Prefect REST API to update a Variable."""
|
628
676
|
|
@@ -638,29 +686,44 @@ class VariableUpdate(ActionBaseModel):
|
|
638
686
|
example="my-value",
|
639
687
|
max_length=objects.MAX_VARIABLE_NAME_LENGTH,
|
640
688
|
)
|
641
|
-
tags: Optional[List[str]] =
|
689
|
+
tags: Optional[List[str]] = Field(default=None)
|
642
690
|
|
643
691
|
# validators
|
644
692
|
_validate_name_format = validator("name", allow_reuse=True)(validate_variable_name)
|
645
693
|
|
646
694
|
|
647
|
-
@copy_model_fields
|
648
695
|
class GlobalConcurrencyLimitCreate(ActionBaseModel):
|
649
696
|
"""Data used by the Prefect REST API to create a global concurrency limit."""
|
650
697
|
|
651
|
-
name: str =
|
652
|
-
limit: int =
|
653
|
-
|
654
|
-
|
655
|
-
|
698
|
+
name: str = Field(description="The name of the global concurrency limit.")
|
699
|
+
limit: int = Field(
|
700
|
+
description=(
|
701
|
+
"The maximum number of slots that can be occupied on this concurrency"
|
702
|
+
" limit."
|
703
|
+
)
|
704
|
+
)
|
705
|
+
active: Optional[bool] = Field(
|
706
|
+
default=True,
|
707
|
+
description="Whether or not the concurrency limit is in an active state.",
|
708
|
+
)
|
709
|
+
active_slots: Optional[int] = Field(
|
710
|
+
default=0,
|
711
|
+
description="Number of tasks currently using a concurrency slot.",
|
712
|
+
)
|
713
|
+
slot_decay_per_second: Optional[float] = Field(
|
714
|
+
default=0.0,
|
715
|
+
description=(
|
716
|
+
"Controls the rate at which slots are released when the concurrency limit"
|
717
|
+
" is used as a rate limit."
|
718
|
+
),
|
719
|
+
)
|
656
720
|
|
657
721
|
|
658
|
-
@copy_model_fields
|
659
722
|
class GlobalConcurrencyLimitUpdate(ActionBaseModel):
|
660
723
|
"""Data used by the Prefect REST API to update a global concurrency limit."""
|
661
724
|
|
662
|
-
name: Optional[str] =
|
663
|
-
limit: Optional[int] =
|
664
|
-
active: Optional[bool] =
|
665
|
-
active_slots: Optional[int] =
|
666
|
-
slot_decay_per_second: Optional[float] =
|
725
|
+
name: Optional[str] = Field(None)
|
726
|
+
limit: Optional[int] = Field(None)
|
727
|
+
active: Optional[bool] = Field(None)
|
728
|
+
active_slots: Optional[int] = Field(None)
|
729
|
+
slot_decay_per_second: Optional[float] = Field(None)
|