prefect-client 3.1.5__py3-none-any.whl → 3.1.7__py3-none-any.whl

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