prefect-client 3.1.4__py3-none-any.whl → 3.1.6__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 +3 -0
- prefect/_internal/compatibility/migration.py +1 -1
- prefect/_internal/concurrency/api.py +52 -52
- prefect/_internal/concurrency/calls.py +59 -35
- prefect/_internal/concurrency/cancellation.py +34 -18
- prefect/_internal/concurrency/event_loop.py +7 -6
- prefect/_internal/concurrency/threads.py +41 -33
- prefect/_internal/concurrency/waiters.py +28 -21
- prefect/_internal/pydantic/v1_schema.py +2 -2
- prefect/_internal/pydantic/v2_schema.py +10 -9
- prefect/_internal/schemas/bases.py +10 -11
- prefect/_internal/schemas/validators.py +2 -1
- prefect/_version.py +3 -3
- prefect/automations.py +53 -47
- prefect/blocks/abstract.py +12 -10
- prefect/blocks/core.py +4 -2
- prefect/cache_policies.py +11 -11
- prefect/client/__init__.py +3 -1
- prefect/client/base.py +36 -37
- prefect/client/cloud.py +26 -19
- prefect/client/collections.py +2 -2
- prefect/client/orchestration.py +366 -277
- prefect/client/schemas/__init__.py +24 -0
- prefect/client/schemas/actions.py +132 -120
- prefect/client/schemas/filters.py +5 -0
- prefect/client/schemas/objects.py +113 -85
- prefect/client/schemas/responses.py +21 -18
- prefect/client/schemas/schedules.py +136 -93
- prefect/client/subscriptions.py +28 -14
- prefect/client/utilities.py +32 -36
- prefect/concurrency/asyncio.py +6 -9
- prefect/concurrency/services.py +3 -0
- prefect/concurrency/sync.py +35 -5
- prefect/context.py +39 -31
- prefect/deployments/flow_runs.py +3 -5
- prefect/docker/__init__.py +1 -1
- prefect/events/schemas/events.py +25 -20
- prefect/events/utilities.py +1 -2
- prefect/filesystems.py +3 -3
- prefect/flow_engine.py +755 -138
- prefect/flow_runs.py +3 -3
- prefect/flows.py +214 -170
- prefect/logging/configuration.py +1 -1
- prefect/logging/highlighters.py +1 -2
- prefect/logging/loggers.py +30 -20
- prefect/main.py +17 -24
- prefect/runner/runner.py +43 -21
- prefect/runner/server.py +30 -32
- prefect/runner/submit.py +3 -6
- prefect/runner/utils.py +6 -6
- prefect/runtime/flow_run.py +7 -0
- prefect/settings/constants.py +2 -2
- prefect/settings/legacy.py +1 -1
- prefect/settings/models/server/events.py +10 -0
- prefect/settings/sources.py +9 -2
- prefect/task_engine.py +72 -19
- prefect/task_runners.py +2 -2
- prefect/tasks.py +46 -33
- prefect/telemetry/bootstrap.py +15 -2
- prefect/telemetry/run_telemetry.py +107 -0
- prefect/transactions.py +14 -14
- prefect/types/__init__.py +20 -3
- prefect/utilities/_engine.py +96 -0
- prefect/utilities/annotations.py +25 -18
- prefect/utilities/asyncutils.py +126 -140
- prefect/utilities/callables.py +87 -78
- prefect/utilities/collections.py +278 -117
- prefect/utilities/compat.py +13 -21
- prefect/utilities/context.py +6 -5
- prefect/utilities/dispatch.py +23 -12
- prefect/utilities/dockerutils.py +33 -32
- prefect/utilities/engine.py +126 -239
- prefect/utilities/filesystem.py +18 -15
- prefect/utilities/hashing.py +10 -11
- prefect/utilities/importtools.py +40 -27
- prefect/utilities/math.py +9 -5
- prefect/utilities/names.py +3 -3
- prefect/utilities/processutils.py +121 -57
- prefect/utilities/pydantic.py +41 -36
- prefect/utilities/render_swagger.py +22 -12
- prefect/utilities/schema_tools/__init__.py +2 -1
- prefect/utilities/schema_tools/hydration.py +50 -43
- prefect/utilities/schema_tools/validation.py +52 -42
- prefect/utilities/services.py +13 -12
- prefect/utilities/templating.py +45 -45
- prefect/utilities/text.py +2 -1
- prefect/utilities/timeout.py +4 -4
- prefect/utilities/urls.py +9 -4
- prefect/utilities/visualization.py +46 -24
- prefect/variables.py +9 -8
- prefect/workers/base.py +18 -10
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.6.dist-info}/METADATA +5 -5
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.6.dist-info}/RECORD +96 -94
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.6.dist-info}/WHEEL +1 -1
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.6.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.6.dist-info}/top_level.txt +0 -0
@@ -25,3 +25,27 @@ from .responses import (
|
|
25
25
|
StateAcceptDetails,
|
26
26
|
StateRejectDetails,
|
27
27
|
)
|
28
|
+
|
29
|
+
__all__ = (
|
30
|
+
"BlockDocument",
|
31
|
+
"BlockSchema",
|
32
|
+
"BlockType",
|
33
|
+
"BlockTypeUpdate",
|
34
|
+
"DEFAULT_BLOCK_SCHEMA_VERSION",
|
35
|
+
"FlowRun",
|
36
|
+
"FlowRunPolicy",
|
37
|
+
"OrchestrationResult",
|
38
|
+
"SetStateStatus",
|
39
|
+
"State",
|
40
|
+
"StateAbortDetails",
|
41
|
+
"StateAcceptDetails",
|
42
|
+
"StateCreate",
|
43
|
+
"StateDetails",
|
44
|
+
"StateRejectDetails",
|
45
|
+
"StateType",
|
46
|
+
"TaskRun",
|
47
|
+
"TaskRunInput",
|
48
|
+
"TaskRunPolicy",
|
49
|
+
"TaskRunResult",
|
50
|
+
"Workspace",
|
51
|
+
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from copy import deepcopy
|
2
|
-
from typing import TYPE_CHECKING, Any,
|
2
|
+
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union
|
3
3
|
from uuid import UUID, uuid4
|
4
4
|
|
5
5
|
import jsonschema
|
@@ -27,6 +27,7 @@ from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
|
27
27
|
from prefect.settings import PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS
|
28
28
|
from prefect.types import (
|
29
29
|
MAX_VARIABLE_NAME_LENGTH,
|
30
|
+
KeyValueLabelsField,
|
30
31
|
Name,
|
31
32
|
NonEmptyishName,
|
32
33
|
NonNegativeFloat,
|
@@ -50,7 +51,7 @@ class StateCreate(ActionBaseModel):
|
|
50
51
|
name: Optional[str] = Field(default=None)
|
51
52
|
message: Optional[str] = Field(default=None, examples=["Run started"])
|
52
53
|
state_details: StateDetails = Field(default_factory=StateDetails)
|
53
|
-
data: Union["BaseResult[
|
54
|
+
data: Union["BaseResult[Any]", "ResultRecordMetadata", Any] = Field(
|
54
55
|
default=None,
|
55
56
|
)
|
56
57
|
|
@@ -61,17 +62,19 @@ class FlowCreate(ActionBaseModel):
|
|
61
62
|
name: str = Field(
|
62
63
|
default=..., description="The name of the flow", examples=["my-flow"]
|
63
64
|
)
|
64
|
-
tags:
|
65
|
+
tags: list[str] = Field(
|
65
66
|
default_factory=list,
|
66
67
|
description="A list of flow tags",
|
67
68
|
examples=[["tag-1", "tag-2"]],
|
68
69
|
)
|
69
70
|
|
71
|
+
labels: KeyValueLabelsField = Field(default_factory=dict)
|
72
|
+
|
70
73
|
|
71
74
|
class FlowUpdate(ActionBaseModel):
|
72
75
|
"""Data used by the Prefect REST API to update a flow."""
|
73
76
|
|
74
|
-
tags:
|
77
|
+
tags: list[str] = Field(
|
75
78
|
default_factory=list,
|
76
79
|
description="A list of flow tags",
|
77
80
|
examples=[["tag-1", "tag-2"]],
|
@@ -92,7 +95,7 @@ class DeploymentScheduleCreate(ActionBaseModel):
|
|
92
95
|
|
93
96
|
@field_validator("max_scheduled_runs")
|
94
97
|
@classmethod
|
95
|
-
def validate_max_scheduled_runs(cls, v):
|
98
|
+
def validate_max_scheduled_runs(cls, v: Optional[int]) -> Optional[int]:
|
96
99
|
return validate_schedule_max_scheduled_runs(
|
97
100
|
v, PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS.value()
|
98
101
|
)
|
@@ -113,7 +116,7 @@ class DeploymentScheduleUpdate(ActionBaseModel):
|
|
113
116
|
|
114
117
|
@field_validator("max_scheduled_runs")
|
115
118
|
@classmethod
|
116
|
-
def validate_max_scheduled_runs(cls, v):
|
119
|
+
def validate_max_scheduled_runs(cls, v: Optional[int]) -> Optional[int]:
|
117
120
|
return validate_schedule_max_scheduled_runs(
|
118
121
|
v, PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS.value()
|
119
122
|
)
|
@@ -124,18 +127,20 @@ class DeploymentCreate(ActionBaseModel):
|
|
124
127
|
|
125
128
|
@model_validator(mode="before")
|
126
129
|
@classmethod
|
127
|
-
def remove_old_fields(cls, values):
|
130
|
+
def remove_old_fields(cls, values: dict[str, Any]) -> dict[str, Any]:
|
128
131
|
return remove_old_deployment_fields(values)
|
129
132
|
|
130
133
|
@field_validator("description", "tags", mode="before")
|
131
134
|
@classmethod
|
132
|
-
def convert_to_strings(
|
135
|
+
def convert_to_strings(
|
136
|
+
cls, values: Optional[Union[str, list[str]]]
|
137
|
+
) -> Union[str, list[str]]:
|
133
138
|
return convert_to_strings(values)
|
134
139
|
|
135
140
|
name: str = Field(..., description="The name of the deployment.")
|
136
141
|
flow_id: UUID = Field(..., description="The ID of the flow to deploy.")
|
137
|
-
paused: Optional[bool] = Field(None)
|
138
|
-
schedules:
|
142
|
+
paused: Optional[bool] = Field(default=None)
|
143
|
+
schedules: list[DeploymentScheduleCreate] = Field(
|
139
144
|
default_factory=list,
|
140
145
|
description="A list of schedules for the deployment.",
|
141
146
|
)
|
@@ -153,32 +158,33 @@ class DeploymentCreate(ActionBaseModel):
|
|
153
158
|
"Whether or not the deployment should enforce the parameter schema."
|
154
159
|
),
|
155
160
|
)
|
156
|
-
parameter_openapi_schema: Optional[
|
157
|
-
parameters:
|
161
|
+
parameter_openapi_schema: Optional[dict[str, Any]] = Field(default_factory=dict)
|
162
|
+
parameters: dict[str, Any] = Field(
|
158
163
|
default_factory=dict,
|
159
164
|
description="Parameters for flow runs scheduled by the deployment.",
|
160
165
|
)
|
161
|
-
tags:
|
162
|
-
|
166
|
+
tags: list[str] = Field(default_factory=list)
|
167
|
+
labels: KeyValueLabelsField = Field(default_factory=dict)
|
168
|
+
pull_steps: Optional[list[dict[str, Any]]] = Field(default=None)
|
163
169
|
|
164
|
-
work_queue_name: Optional[str] = Field(None)
|
170
|
+
work_queue_name: Optional[str] = Field(default=None)
|
165
171
|
work_pool_name: Optional[str] = Field(
|
166
172
|
default=None,
|
167
173
|
description="The name of the deployment's work pool.",
|
168
174
|
examples=["my-work-pool"],
|
169
175
|
)
|
170
|
-
storage_document_id: Optional[UUID] = Field(None)
|
171
|
-
infrastructure_document_id: Optional[UUID] = Field(None)
|
172
|
-
description: Optional[str] = Field(None)
|
173
|
-
path: Optional[str] = Field(None)
|
174
|
-
version: Optional[str] = Field(None)
|
175
|
-
entrypoint: Optional[str] = Field(None)
|
176
|
-
job_variables:
|
176
|
+
storage_document_id: Optional[UUID] = Field(default=None)
|
177
|
+
infrastructure_document_id: Optional[UUID] = Field(default=None)
|
178
|
+
description: Optional[str] = Field(default=None)
|
179
|
+
path: Optional[str] = Field(default=None)
|
180
|
+
version: Optional[str] = Field(default=None)
|
181
|
+
entrypoint: Optional[str] = Field(default=None)
|
182
|
+
job_variables: dict[str, Any] = Field(
|
177
183
|
default_factory=dict,
|
178
184
|
description="Overrides to apply to flow run infrastructure at runtime.",
|
179
185
|
)
|
180
186
|
|
181
|
-
def check_valid_configuration(self, base_job_template: dict):
|
187
|
+
def check_valid_configuration(self, base_job_template: dict[str, Any]) -> None:
|
182
188
|
"""Check that the combination of base_job_template defaults
|
183
189
|
and job_variables conforms to the specified schema.
|
184
190
|
"""
|
@@ -203,19 +209,19 @@ class DeploymentUpdate(ActionBaseModel):
|
|
203
209
|
|
204
210
|
@model_validator(mode="before")
|
205
211
|
@classmethod
|
206
|
-
def remove_old_fields(cls, values):
|
212
|
+
def remove_old_fields(cls, values: dict[str, Any]) -> dict[str, Any]:
|
207
213
|
return remove_old_deployment_fields(values)
|
208
214
|
|
209
|
-
version: Optional[str] = Field(None)
|
210
|
-
description: Optional[str] = Field(None)
|
211
|
-
parameters: Optional[
|
215
|
+
version: Optional[str] = Field(default=None)
|
216
|
+
description: Optional[str] = Field(default=None)
|
217
|
+
parameters: Optional[dict[str, Any]] = Field(
|
212
218
|
default=None,
|
213
219
|
description="Parameters for flow runs scheduled by the deployment.",
|
214
220
|
)
|
215
221
|
paused: Optional[bool] = Field(
|
216
222
|
default=None, description="Whether or not the deployment is paused."
|
217
223
|
)
|
218
|
-
schedules: Optional[
|
224
|
+
schedules: Optional[list[DeploymentScheduleCreate]] = Field(
|
219
225
|
default=None,
|
220
226
|
description="A list of schedules for the deployment.",
|
221
227
|
)
|
@@ -227,21 +233,21 @@ class DeploymentUpdate(ActionBaseModel):
|
|
227
233
|
default=None,
|
228
234
|
description="The concurrency options for the deployment.",
|
229
235
|
)
|
230
|
-
tags:
|
231
|
-
work_queue_name: Optional[str] = Field(None)
|
236
|
+
tags: list[str] = Field(default_factory=list)
|
237
|
+
work_queue_name: Optional[str] = Field(default=None)
|
232
238
|
work_pool_name: Optional[str] = Field(
|
233
239
|
default=None,
|
234
240
|
description="The name of the deployment's work pool.",
|
235
241
|
examples=["my-work-pool"],
|
236
242
|
)
|
237
|
-
path: Optional[str] = Field(None)
|
238
|
-
job_variables: Optional[
|
243
|
+
path: Optional[str] = Field(default=None)
|
244
|
+
job_variables: Optional[dict[str, Any]] = Field(
|
239
245
|
default_factory=dict,
|
240
246
|
description="Overrides to apply to flow run infrastructure at runtime.",
|
241
247
|
)
|
242
|
-
entrypoint: Optional[str] = Field(None)
|
243
|
-
storage_document_id: Optional[UUID] = Field(None)
|
244
|
-
infrastructure_document_id: Optional[UUID] = Field(None)
|
248
|
+
entrypoint: Optional[str] = Field(default=None)
|
249
|
+
storage_document_id: Optional[UUID] = Field(default=None)
|
250
|
+
infrastructure_document_id: Optional[UUID] = Field(default=None)
|
245
251
|
enforce_parameter_schema: Optional[bool] = Field(
|
246
252
|
default=None,
|
247
253
|
description=(
|
@@ -249,7 +255,7 @@ class DeploymentUpdate(ActionBaseModel):
|
|
249
255
|
),
|
250
256
|
)
|
251
257
|
|
252
|
-
def check_valid_configuration(self, base_job_template: dict):
|
258
|
+
def check_valid_configuration(self, base_job_template: dict[str, Any]) -> None:
|
253
259
|
"""Check that the combination of base_job_template defaults
|
254
260
|
and job_variables conforms to the specified schema.
|
255
261
|
"""
|
@@ -273,15 +279,15 @@ class DeploymentUpdate(ActionBaseModel):
|
|
273
279
|
class FlowRunUpdate(ActionBaseModel):
|
274
280
|
"""Data used by the Prefect REST API to update a flow run."""
|
275
281
|
|
276
|
-
name: Optional[str] = Field(None)
|
277
|
-
flow_version: Optional[str] = Field(None)
|
278
|
-
parameters: Optional[
|
282
|
+
name: Optional[str] = Field(default=None)
|
283
|
+
flow_version: Optional[str] = Field(default=None)
|
284
|
+
parameters: Optional[dict[str, Any]] = Field(default_factory=dict)
|
279
285
|
empirical_policy: objects.FlowRunPolicy = Field(
|
280
286
|
default_factory=objects.FlowRunPolicy
|
281
287
|
)
|
282
|
-
tags:
|
283
|
-
infrastructure_pid: Optional[str] = Field(None)
|
284
|
-
job_variables: Optional[
|
288
|
+
tags: list[str] = Field(default_factory=list)
|
289
|
+
infrastructure_pid: Optional[str] = Field(default=None)
|
290
|
+
job_variables: Optional[dict[str, Any]] = Field(default=None)
|
285
291
|
|
286
292
|
|
287
293
|
class TaskRunCreate(ActionBaseModel):
|
@@ -297,7 +303,7 @@ class TaskRunCreate(ActionBaseModel):
|
|
297
303
|
default=None,
|
298
304
|
description="The name of the task run",
|
299
305
|
)
|
300
|
-
flow_run_id: Optional[UUID] = Field(None)
|
306
|
+
flow_run_id: Optional[UUID] = Field(default=None)
|
301
307
|
task_key: str = Field(
|
302
308
|
default=..., description="A unique identifier for the task being run."
|
303
309
|
)
|
@@ -308,16 +314,17 @@ class TaskRunCreate(ActionBaseModel):
|
|
308
314
|
" within the same flow run."
|
309
315
|
),
|
310
316
|
)
|
311
|
-
cache_key: Optional[str] = Field(None)
|
312
|
-
cache_expiration: Optional[objects.DateTime] = Field(None)
|
313
|
-
task_version: Optional[str] = Field(None)
|
317
|
+
cache_key: Optional[str] = Field(default=None)
|
318
|
+
cache_expiration: Optional[objects.DateTime] = Field(default=None)
|
319
|
+
task_version: Optional[str] = Field(default=None)
|
314
320
|
empirical_policy: objects.TaskRunPolicy = Field(
|
315
321
|
default_factory=objects.TaskRunPolicy,
|
316
322
|
)
|
317
|
-
tags:
|
318
|
-
|
323
|
+
tags: list[str] = Field(default_factory=list)
|
324
|
+
labels: KeyValueLabelsField = Field(default_factory=dict)
|
325
|
+
task_inputs: dict[
|
319
326
|
str,
|
320
|
-
|
327
|
+
list[
|
321
328
|
Union[
|
322
329
|
objects.TaskRunResult,
|
323
330
|
objects.Parameter,
|
@@ -330,7 +337,7 @@ class TaskRunCreate(ActionBaseModel):
|
|
330
337
|
class TaskRunUpdate(ActionBaseModel):
|
331
338
|
"""Data used by the Prefect REST API to update a task run"""
|
332
339
|
|
333
|
-
name: Optional[str] = Field(None)
|
340
|
+
name: Optional[str] = Field(default=None)
|
334
341
|
|
335
342
|
|
336
343
|
class FlowRunCreate(ActionBaseModel):
|
@@ -343,21 +350,23 @@ class FlowRunCreate(ActionBaseModel):
|
|
343
350
|
|
344
351
|
name: Optional[str] = Field(default=None, description="The name of the flow run.")
|
345
352
|
flow_id: UUID = Field(default=..., description="The id of the flow being run.")
|
346
|
-
deployment_id: Optional[UUID] = Field(None)
|
347
|
-
flow_version: Optional[str] = Field(None)
|
348
|
-
parameters:
|
353
|
+
deployment_id: Optional[UUID] = Field(default=None)
|
354
|
+
flow_version: Optional[str] = Field(default=None)
|
355
|
+
parameters: dict[str, Any] = Field(
|
349
356
|
default_factory=dict, description="The parameters for the flow run."
|
350
357
|
)
|
351
|
-
context:
|
358
|
+
context: dict[str, Any] = Field(
|
352
359
|
default_factory=dict, description="The context for the flow run."
|
353
360
|
)
|
354
|
-
parent_task_run_id: Optional[UUID] = Field(None)
|
355
|
-
infrastructure_document_id: Optional[UUID] = Field(None)
|
361
|
+
parent_task_run_id: Optional[UUID] = Field(default=None)
|
362
|
+
infrastructure_document_id: Optional[UUID] = Field(default=None)
|
356
363
|
empirical_policy: objects.FlowRunPolicy = Field(
|
357
364
|
default_factory=objects.FlowRunPolicy
|
358
365
|
)
|
359
|
-
tags:
|
360
|
-
idempotency_key: Optional[str] = Field(None)
|
366
|
+
tags: list[str] = Field(default_factory=list)
|
367
|
+
idempotency_key: Optional[str] = Field(default=None)
|
368
|
+
|
369
|
+
labels: KeyValueLabelsField = Field(default_factory=dict)
|
361
370
|
|
362
371
|
|
363
372
|
class DeploymentFlowRunCreate(ActionBaseModel):
|
@@ -369,32 +378,33 @@ class DeploymentFlowRunCreate(ActionBaseModel):
|
|
369
378
|
)
|
370
379
|
|
371
380
|
name: Optional[str] = Field(default=None, description="The name of the flow run.")
|
372
|
-
parameters:
|
381
|
+
parameters: dict[str, Any] = Field(
|
373
382
|
default_factory=dict, description="The parameters for the flow run."
|
374
383
|
)
|
375
384
|
enforce_parameter_schema: Optional[bool] = Field(
|
376
385
|
default=None,
|
377
386
|
description="Whether or not to enforce the parameter schema on this run.",
|
378
387
|
)
|
379
|
-
context:
|
388
|
+
context: dict[str, Any] = Field(
|
380
389
|
default_factory=dict, description="The context for the flow run."
|
381
390
|
)
|
382
|
-
infrastructure_document_id: Optional[UUID] = Field(None)
|
391
|
+
infrastructure_document_id: Optional[UUID] = Field(default=None)
|
383
392
|
empirical_policy: objects.FlowRunPolicy = Field(
|
384
393
|
default_factory=objects.FlowRunPolicy
|
385
394
|
)
|
386
|
-
tags:
|
395
|
+
tags: list[str] = Field(default_factory=list)
|
387
396
|
idempotency_key: Optional[str] = Field(None)
|
388
397
|
parent_task_run_id: Optional[UUID] = Field(None)
|
389
398
|
work_queue_name: Optional[str] = Field(None)
|
390
399
|
job_variables: Optional[dict] = Field(None)
|
400
|
+
labels: KeyValueLabelsField = Field(default_factory=dict)
|
391
401
|
|
392
402
|
|
393
403
|
class SavedSearchCreate(ActionBaseModel):
|
394
404
|
"""Data used by the Prefect REST API to create a saved search."""
|
395
405
|
|
396
406
|
name: str = Field(default=..., description="The name of the saved search.")
|
397
|
-
filters:
|
407
|
+
filters: list[objects.SavedSearchFilter] = Field(
|
398
408
|
default_factory=list, description="The filter set for the saved search."
|
399
409
|
)
|
400
410
|
|
@@ -431,12 +441,12 @@ class ConcurrencyLimitV2Create(ActionBaseModel):
|
|
431
441
|
class ConcurrencyLimitV2Update(ActionBaseModel):
|
432
442
|
"""Data used by the Prefect REST API to update a v2 concurrency limit."""
|
433
443
|
|
434
|
-
active: Optional[bool] = Field(None)
|
435
|
-
name: Optional[Name] = Field(None)
|
436
|
-
limit: Optional[NonNegativeInteger] = Field(None)
|
437
|
-
active_slots: Optional[NonNegativeInteger] = Field(None)
|
438
|
-
denied_slots: Optional[NonNegativeInteger] = Field(None)
|
439
|
-
slot_decay_per_second: Optional[NonNegativeFloat] = Field(None)
|
444
|
+
active: Optional[bool] = Field(default=None)
|
445
|
+
name: Optional[Name] = Field(default=None)
|
446
|
+
limit: Optional[NonNegativeInteger] = Field(default=None)
|
447
|
+
active_slots: Optional[NonNegativeInteger] = Field(default=None)
|
448
|
+
denied_slots: Optional[NonNegativeInteger] = Field(default=None)
|
449
|
+
slot_decay_per_second: Optional[NonNegativeFloat] = Field(default=None)
|
440
450
|
|
441
451
|
|
442
452
|
class BlockTypeCreate(ActionBaseModel):
|
@@ -466,24 +476,24 @@ class BlockTypeCreate(ActionBaseModel):
|
|
466
476
|
class BlockTypeUpdate(ActionBaseModel):
|
467
477
|
"""Data used by the Prefect REST API to update a block type."""
|
468
478
|
|
469
|
-
logo_url: Optional[objects.HttpUrl] = Field(None)
|
470
|
-
documentation_url: Optional[objects.HttpUrl] = Field(None)
|
471
|
-
description: Optional[str] = Field(None)
|
472
|
-
code_example: Optional[str] = Field(None)
|
479
|
+
logo_url: Optional[objects.HttpUrl] = Field(default=None)
|
480
|
+
documentation_url: Optional[objects.HttpUrl] = Field(default=None)
|
481
|
+
description: Optional[str] = Field(default=None)
|
482
|
+
code_example: Optional[str] = Field(default=None)
|
473
483
|
|
474
484
|
@classmethod
|
475
|
-
def updatable_fields(cls) -> set:
|
485
|
+
def updatable_fields(cls) -> set[str]:
|
476
486
|
return get_class_fields_only(cls)
|
477
487
|
|
478
488
|
|
479
489
|
class BlockSchemaCreate(ActionBaseModel):
|
480
490
|
"""Data used by the Prefect REST API to create a block schema."""
|
481
491
|
|
482
|
-
fields:
|
492
|
+
fields: dict[str, Any] = Field(
|
483
493
|
default_factory=dict, description="The block schema's field schema"
|
484
494
|
)
|
485
|
-
block_type_id: Optional[UUID] = Field(None)
|
486
|
-
capabilities:
|
495
|
+
block_type_id: Optional[UUID] = Field(default=None)
|
496
|
+
capabilities: list[str] = Field(
|
487
497
|
default_factory=list,
|
488
498
|
description="A list of Block capabilities",
|
489
499
|
)
|
@@ -499,7 +509,7 @@ class BlockDocumentCreate(ActionBaseModel):
|
|
499
509
|
name: Optional[Name] = Field(
|
500
510
|
default=None, description="The name of the block document"
|
501
511
|
)
|
502
|
-
data:
|
512
|
+
data: dict[str, Any] = Field(
|
503
513
|
default_factory=dict, description="The block document's data"
|
504
514
|
)
|
505
515
|
block_schema_id: UUID = Field(
|
@@ -519,7 +529,9 @@ class BlockDocumentCreate(ActionBaseModel):
|
|
519
529
|
_validate_name_format = field_validator("name")(validate_block_document_name)
|
520
530
|
|
521
531
|
@model_validator(mode="before")
|
522
|
-
def validate_name_is_present_if_not_anonymous(
|
532
|
+
def validate_name_is_present_if_not_anonymous(
|
533
|
+
cls, values: dict[str, Any]
|
534
|
+
) -> dict[str, Any]:
|
523
535
|
return validate_name_present_on_nonanonymous_blocks(values)
|
524
536
|
|
525
537
|
|
@@ -529,7 +541,7 @@ class BlockDocumentUpdate(ActionBaseModel):
|
|
529
541
|
block_schema_id: Optional[UUID] = Field(
|
530
542
|
default=None, description="A block schema ID"
|
531
543
|
)
|
532
|
-
data:
|
544
|
+
data: dict[str, Any] = Field(
|
533
545
|
default_factory=dict, description="The block document's data"
|
534
546
|
)
|
535
547
|
merge_existing_data: bool = Field(
|
@@ -560,11 +572,11 @@ class LogCreate(ActionBaseModel):
|
|
560
572
|
level: int = Field(default=..., description="The log level.")
|
561
573
|
message: str = Field(default=..., description="The log message.")
|
562
574
|
timestamp: DateTime = Field(default=..., description="The log timestamp.")
|
563
|
-
flow_run_id: Optional[UUID] = Field(None)
|
564
|
-
task_run_id: Optional[UUID] = Field(None)
|
565
|
-
worker_id: Optional[UUID] = Field(None)
|
575
|
+
flow_run_id: Optional[UUID] = Field(default=None)
|
576
|
+
task_run_id: Optional[UUID] = Field(default=None)
|
577
|
+
worker_id: Optional[UUID] = Field(default=None)
|
566
578
|
|
567
|
-
def model_dump(self, *args, **kwargs):
|
579
|
+
def model_dump(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
|
568
580
|
"""
|
569
581
|
The worker_id field is only included in logs sent to Prefect Cloud.
|
570
582
|
If it's unset, we should not include it in the log payload.
|
@@ -581,11 +593,11 @@ class WorkPoolCreate(ActionBaseModel):
|
|
581
593
|
name: NonEmptyishName = Field(
|
582
594
|
description="The name of the work pool.",
|
583
595
|
)
|
584
|
-
description: Optional[str] = Field(None)
|
596
|
+
description: Optional[str] = Field(default=None)
|
585
597
|
type: str = Field(
|
586
598
|
description="The work pool type.", default="prefect-agent"
|
587
599
|
) # TODO: change default
|
588
|
-
base_job_template:
|
600
|
+
base_job_template: dict[str, Any] = Field(
|
589
601
|
default_factory=dict,
|
590
602
|
description="The base job template for the work pool.",
|
591
603
|
)
|
@@ -601,17 +613,17 @@ class WorkPoolCreate(ActionBaseModel):
|
|
601
613
|
class WorkPoolUpdate(ActionBaseModel):
|
602
614
|
"""Data used by the Prefect REST API to update a work pool."""
|
603
615
|
|
604
|
-
description: Optional[str] = Field(None)
|
605
|
-
is_paused: Optional[bool] = Field(None)
|
606
|
-
base_job_template: Optional[
|
607
|
-
concurrency_limit: Optional[int] = Field(None)
|
616
|
+
description: Optional[str] = Field(default=None)
|
617
|
+
is_paused: Optional[bool] = Field(default=None)
|
618
|
+
base_job_template: Optional[dict[str, Any]] = Field(default=None)
|
619
|
+
concurrency_limit: Optional[int] = Field(default=None)
|
608
620
|
|
609
621
|
|
610
622
|
class WorkQueueCreate(ActionBaseModel):
|
611
623
|
"""Data used by the Prefect REST API to create a work queue."""
|
612
624
|
|
613
625
|
name: str = Field(default=..., description="The name of the work queue.")
|
614
|
-
description: Optional[str] = Field(None)
|
626
|
+
description: Optional[str] = Field(default=None)
|
615
627
|
is_paused: bool = Field(
|
616
628
|
default=False,
|
617
629
|
description="Whether the work queue is paused.",
|
@@ -639,16 +651,16 @@ class WorkQueueCreate(ActionBaseModel):
|
|
639
651
|
class WorkQueueUpdate(ActionBaseModel):
|
640
652
|
"""Data used by the Prefect REST API to update a work queue."""
|
641
653
|
|
642
|
-
name: Optional[str] = Field(None)
|
643
|
-
description: Optional[str] = Field(None)
|
654
|
+
name: Optional[str] = Field(default=None)
|
655
|
+
description: Optional[str] = Field(default=None)
|
644
656
|
is_paused: bool = Field(
|
645
657
|
default=False, description="Whether or not the work queue is paused."
|
646
658
|
)
|
647
|
-
concurrency_limit: Optional[NonNegativeInteger] = Field(None)
|
659
|
+
concurrency_limit: Optional[NonNegativeInteger] = Field(default=None)
|
648
660
|
priority: Optional[PositiveInteger] = Field(
|
649
661
|
None, description="The queue's priority."
|
650
662
|
)
|
651
|
-
last_polled: Optional[DateTime] = Field(None)
|
663
|
+
last_polled: Optional[DateTime] = Field(default=None)
|
652
664
|
|
653
665
|
# DEPRECATED
|
654
666
|
|
@@ -665,10 +677,10 @@ class FlowRunNotificationPolicyCreate(ActionBaseModel):
|
|
665
677
|
is_active: bool = Field(
|
666
678
|
default=True, description="Whether the policy is currently active"
|
667
679
|
)
|
668
|
-
state_names:
|
680
|
+
state_names: list[str] = Field(
|
669
681
|
default=..., description="The flow run states that trigger notifications"
|
670
682
|
)
|
671
|
-
tags:
|
683
|
+
tags: list[str] = Field(
|
672
684
|
default=...,
|
673
685
|
description="The flow run tags that trigger notifications (set [] to disable)",
|
674
686
|
)
|
@@ -690,30 +702,30 @@ class FlowRunNotificationPolicyCreate(ActionBaseModel):
|
|
690
702
|
|
691
703
|
@field_validator("message_template")
|
692
704
|
@classmethod
|
693
|
-
def validate_message_template_variables(cls, v):
|
705
|
+
def validate_message_template_variables(cls, v: Optional[str]) -> Optional[str]:
|
694
706
|
return validate_message_template_variables(v)
|
695
707
|
|
696
708
|
|
697
709
|
class FlowRunNotificationPolicyUpdate(ActionBaseModel):
|
698
710
|
"""Data used by the Prefect REST API to update a flow run notification policy."""
|
699
711
|
|
700
|
-
is_active: Optional[bool] = Field(None)
|
701
|
-
state_names: Optional[
|
702
|
-
tags: Optional[
|
703
|
-
block_document_id: Optional[UUID] = Field(None)
|
704
|
-
message_template: Optional[str] = Field(None)
|
712
|
+
is_active: Optional[bool] = Field(default=None)
|
713
|
+
state_names: Optional[list[str]] = Field(default=None)
|
714
|
+
tags: Optional[list[str]] = Field(default=None)
|
715
|
+
block_document_id: Optional[UUID] = Field(default=None)
|
716
|
+
message_template: Optional[str] = Field(default=None)
|
705
717
|
|
706
718
|
|
707
719
|
class ArtifactCreate(ActionBaseModel):
|
708
720
|
"""Data used by the Prefect REST API to create an artifact."""
|
709
721
|
|
710
|
-
key: Optional[str] = Field(None)
|
711
|
-
type: Optional[str] = Field(None)
|
712
|
-
description: Optional[str] = Field(None)
|
713
|
-
data: Optional[Union[
|
714
|
-
metadata_: Optional[
|
715
|
-
flow_run_id: Optional[UUID] = Field(None)
|
716
|
-
task_run_id: Optional[UUID] = Field(None)
|
722
|
+
key: Optional[str] = Field(default=None)
|
723
|
+
type: Optional[str] = Field(default=None)
|
724
|
+
description: Optional[str] = Field(default=None)
|
725
|
+
data: Optional[Union[dict[str, Any], Any]] = Field(default=None)
|
726
|
+
metadata_: Optional[dict[str, str]] = Field(default=None)
|
727
|
+
flow_run_id: Optional[UUID] = Field(default=None)
|
728
|
+
task_run_id: Optional[UUID] = Field(default=None)
|
717
729
|
|
718
730
|
_validate_artifact_format = field_validator("key")(validate_artifact_key)
|
719
731
|
|
@@ -721,9 +733,9 @@ class ArtifactCreate(ActionBaseModel):
|
|
721
733
|
class ArtifactUpdate(ActionBaseModel):
|
722
734
|
"""Data used by the Prefect REST API to update an artifact."""
|
723
735
|
|
724
|
-
data: Optional[Union[
|
725
|
-
description: Optional[str] = Field(None)
|
726
|
-
metadata_: Optional[
|
736
|
+
data: Optional[Union[dict[str, Any], Any]] = Field(default=None)
|
737
|
+
description: Optional[str] = Field(default=None)
|
738
|
+
metadata_: Optional[dict[str, str]] = Field(default=None)
|
727
739
|
|
728
740
|
|
729
741
|
class VariableCreate(ActionBaseModel):
|
@@ -740,7 +752,7 @@ class VariableCreate(ActionBaseModel):
|
|
740
752
|
description="The value of the variable",
|
741
753
|
examples=["my-value"],
|
742
754
|
)
|
743
|
-
tags: Optional[
|
755
|
+
tags: Optional[list[str]] = Field(default=None)
|
744
756
|
|
745
757
|
# validators
|
746
758
|
_validate_name_format = field_validator("name")(validate_variable_name)
|
@@ -760,7 +772,7 @@ class VariableUpdate(ActionBaseModel):
|
|
760
772
|
description="The value of the variable",
|
761
773
|
examples=["my-value"],
|
762
774
|
)
|
763
|
-
tags: Optional[
|
775
|
+
tags: Optional[list[str]] = Field(default=None)
|
764
776
|
|
765
777
|
# validators
|
766
778
|
_validate_name_format = field_validator("name")(validate_variable_name)
|
@@ -796,8 +808,8 @@ class GlobalConcurrencyLimitCreate(ActionBaseModel):
|
|
796
808
|
class GlobalConcurrencyLimitUpdate(ActionBaseModel):
|
797
809
|
"""Data used by the Prefect REST API to update a global concurrency limit."""
|
798
810
|
|
799
|
-
name: Optional[Name] = Field(None)
|
800
|
-
limit: Optional[NonNegativeInteger] = Field(None)
|
801
|
-
active: Optional[bool] = Field(None)
|
802
|
-
active_slots: Optional[NonNegativeInteger] = Field(None)
|
803
|
-
slot_decay_per_second: Optional[NonNegativeFloat] = Field(None)
|
811
|
+
name: Optional[Name] = Field(default=None)
|
812
|
+
limit: Optional[NonNegativeInteger] = Field(default=None)
|
813
|
+
active: Optional[bool] = Field(default=None)
|
814
|
+
active_slots: Optional[NonNegativeInteger] = Field(default=None)
|
815
|
+
slot_decay_per_second: Optional[NonNegativeFloat] = Field(default=None)
|
@@ -129,6 +129,11 @@ class FlowRunFilterTags(PrefectBaseModel, OperatorMixin):
|
|
129
129
|
" superset of the list"
|
130
130
|
),
|
131
131
|
)
|
132
|
+
any_: Optional[List[str]] = Field(
|
133
|
+
default=None,
|
134
|
+
examples=[["tag-1", "tag-2"]],
|
135
|
+
description="A list of tags to include",
|
136
|
+
)
|
132
137
|
is_null_: Optional[bool] = Field(
|
133
138
|
default=None, description="If true, only include flow runs without tags"
|
134
139
|
)
|