prefect-client 2.16.8__py3-none-any.whl → 2.17.0__py3-none-any.whl

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