prefect-client 2.19.2__py3-none-any.whl → 3.0.0rc1__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 +8 -56
- prefect/_internal/compatibility/deprecated.py +6 -115
- prefect/_internal/compatibility/experimental.py +4 -79
- prefect/_internal/concurrency/api.py +0 -34
- prefect/_internal/concurrency/calls.py +0 -6
- prefect/_internal/concurrency/cancellation.py +0 -3
- prefect/_internal/concurrency/event_loop.py +0 -20
- prefect/_internal/concurrency/inspection.py +3 -3
- prefect/_internal/concurrency/threads.py +35 -0
- prefect/_internal/concurrency/waiters.py +0 -28
- prefect/_internal/pydantic/__init__.py +0 -45
- prefect/_internal/pydantic/v1_schema.py +21 -22
- prefect/_internal/pydantic/v2_schema.py +0 -2
- prefect/_internal/pydantic/v2_validated_func.py +18 -23
- prefect/_internal/schemas/bases.py +44 -177
- prefect/_internal/schemas/fields.py +1 -43
- prefect/_internal/schemas/validators.py +60 -158
- prefect/artifacts.py +161 -14
- prefect/automations.py +39 -4
- prefect/blocks/abstract.py +1 -1
- prefect/blocks/core.py +268 -148
- prefect/blocks/fields.py +2 -57
- prefect/blocks/kubernetes.py +8 -12
- prefect/blocks/notifications.py +40 -20
- prefect/blocks/system.py +22 -11
- prefect/blocks/webhook.py +2 -9
- prefect/client/base.py +4 -4
- prefect/client/cloud.py +8 -13
- prefect/client/orchestration.py +347 -341
- prefect/client/schemas/actions.py +92 -86
- prefect/client/schemas/filters.py +20 -40
- prefect/client/schemas/objects.py +151 -145
- prefect/client/schemas/responses.py +16 -24
- prefect/client/schemas/schedules.py +47 -35
- prefect/client/subscriptions.py +2 -2
- prefect/client/utilities.py +5 -2
- prefect/concurrency/asyncio.py +3 -1
- prefect/concurrency/events.py +1 -1
- prefect/concurrency/services.py +6 -3
- prefect/context.py +195 -27
- prefect/deployments/__init__.py +5 -6
- prefect/deployments/base.py +7 -5
- prefect/deployments/flow_runs.py +185 -0
- prefect/deployments/runner.py +50 -45
- prefect/deployments/schedules.py +28 -23
- prefect/deployments/steps/__init__.py +0 -1
- prefect/deployments/steps/core.py +1 -0
- prefect/deployments/steps/pull.py +7 -21
- prefect/engine.py +12 -2422
- prefect/events/actions.py +17 -23
- prefect/events/cli/automations.py +19 -6
- prefect/events/clients.py +14 -37
- prefect/events/filters.py +14 -18
- prefect/events/related.py +2 -2
- prefect/events/schemas/__init__.py +0 -5
- prefect/events/schemas/automations.py +55 -46
- prefect/events/schemas/deployment_triggers.py +7 -197
- prefect/events/schemas/events.py +34 -65
- prefect/events/schemas/labelling.py +10 -14
- prefect/events/utilities.py +2 -3
- prefect/events/worker.py +2 -3
- prefect/filesystems.py +6 -517
- prefect/{new_flow_engine.py → flow_engine.py} +313 -72
- prefect/flow_runs.py +377 -5
- prefect/flows.py +307 -166
- prefect/futures.py +186 -345
- prefect/infrastructure/__init__.py +0 -27
- prefect/infrastructure/provisioners/__init__.py +5 -3
- prefect/infrastructure/provisioners/cloud_run.py +11 -6
- prefect/infrastructure/provisioners/container_instance.py +11 -7
- prefect/infrastructure/provisioners/ecs.py +6 -4
- prefect/infrastructure/provisioners/modal.py +8 -5
- prefect/input/actions.py +2 -4
- prefect/input/run_input.py +5 -7
- prefect/logging/formatters.py +0 -2
- prefect/logging/handlers.py +3 -11
- prefect/logging/loggers.py +2 -2
- prefect/manifests.py +2 -1
- prefect/records/__init__.py +1 -0
- prefect/records/result_store.py +42 -0
- prefect/records/store.py +9 -0
- prefect/results.py +43 -39
- prefect/runner/runner.py +19 -15
- prefect/runner/server.py +6 -10
- prefect/runner/storage.py +3 -8
- prefect/runner/submit.py +2 -2
- prefect/runner/utils.py +2 -2
- prefect/serializers.py +24 -35
- prefect/server/api/collections_data/views/aggregate-worker-metadata.json +5 -14
- prefect/settings.py +70 -133
- prefect/states.py +17 -47
- prefect/task_engine.py +697 -58
- prefect/task_runners.py +269 -301
- prefect/task_server.py +53 -34
- prefect/tasks.py +327 -337
- prefect/transactions.py +220 -0
- prefect/types/__init__.py +61 -82
- prefect/utilities/asyncutils.py +195 -136
- prefect/utilities/callables.py +311 -43
- prefect/utilities/collections.py +23 -38
- prefect/utilities/dispatch.py +11 -3
- prefect/utilities/dockerutils.py +4 -0
- prefect/utilities/engine.py +140 -20
- prefect/utilities/importtools.py +97 -27
- prefect/utilities/pydantic.py +128 -38
- prefect/utilities/schema_tools/hydration.py +5 -1
- prefect/utilities/templating.py +12 -2
- prefect/variables.py +78 -61
- prefect/workers/__init__.py +0 -1
- prefect/workers/base.py +15 -17
- prefect/workers/process.py +3 -8
- prefect/workers/server.py +2 -2
- {prefect_client-2.19.2.dist-info → prefect_client-3.0.0rc1.dist-info}/METADATA +22 -21
- prefect_client-3.0.0rc1.dist-info/RECORD +176 -0
- prefect/_internal/pydantic/_base_model.py +0 -51
- prefect/_internal/pydantic/_compat.py +0 -82
- prefect/_internal/pydantic/_flags.py +0 -20
- prefect/_internal/pydantic/_types.py +0 -8
- prefect/_internal/pydantic/utilities/__init__.py +0 -0
- prefect/_internal/pydantic/utilities/config_dict.py +0 -72
- prefect/_internal/pydantic/utilities/field_validator.py +0 -150
- prefect/_internal/pydantic/utilities/model_construct.py +0 -56
- prefect/_internal/pydantic/utilities/model_copy.py +0 -55
- prefect/_internal/pydantic/utilities/model_dump.py +0 -136
- prefect/_internal/pydantic/utilities/model_dump_json.py +0 -112
- prefect/_internal/pydantic/utilities/model_fields.py +0 -50
- prefect/_internal/pydantic/utilities/model_fields_set.py +0 -29
- prefect/_internal/pydantic/utilities/model_json_schema.py +0 -82
- prefect/_internal/pydantic/utilities/model_rebuild.py +0 -80
- prefect/_internal/pydantic/utilities/model_validate.py +0 -75
- prefect/_internal/pydantic/utilities/model_validate_json.py +0 -68
- prefect/_internal/pydantic/utilities/model_validator.py +0 -87
- prefect/_internal/pydantic/utilities/type_adapter.py +0 -71
- prefect/_vendor/__init__.py +0 -0
- prefect/_vendor/fastapi/__init__.py +0 -25
- prefect/_vendor/fastapi/applications.py +0 -946
- prefect/_vendor/fastapi/background.py +0 -3
- prefect/_vendor/fastapi/concurrency.py +0 -44
- prefect/_vendor/fastapi/datastructures.py +0 -58
- prefect/_vendor/fastapi/dependencies/__init__.py +0 -0
- prefect/_vendor/fastapi/dependencies/models.py +0 -64
- prefect/_vendor/fastapi/dependencies/utils.py +0 -877
- prefect/_vendor/fastapi/encoders.py +0 -177
- prefect/_vendor/fastapi/exception_handlers.py +0 -40
- prefect/_vendor/fastapi/exceptions.py +0 -46
- prefect/_vendor/fastapi/logger.py +0 -3
- prefect/_vendor/fastapi/middleware/__init__.py +0 -1
- prefect/_vendor/fastapi/middleware/asyncexitstack.py +0 -25
- prefect/_vendor/fastapi/middleware/cors.py +0 -3
- prefect/_vendor/fastapi/middleware/gzip.py +0 -3
- prefect/_vendor/fastapi/middleware/httpsredirect.py +0 -3
- prefect/_vendor/fastapi/middleware/trustedhost.py +0 -3
- prefect/_vendor/fastapi/middleware/wsgi.py +0 -3
- prefect/_vendor/fastapi/openapi/__init__.py +0 -0
- prefect/_vendor/fastapi/openapi/constants.py +0 -2
- prefect/_vendor/fastapi/openapi/docs.py +0 -203
- prefect/_vendor/fastapi/openapi/models.py +0 -480
- prefect/_vendor/fastapi/openapi/utils.py +0 -485
- prefect/_vendor/fastapi/param_functions.py +0 -340
- prefect/_vendor/fastapi/params.py +0 -453
- prefect/_vendor/fastapi/requests.py +0 -4
- prefect/_vendor/fastapi/responses.py +0 -40
- prefect/_vendor/fastapi/routing.py +0 -1331
- prefect/_vendor/fastapi/security/__init__.py +0 -15
- prefect/_vendor/fastapi/security/api_key.py +0 -98
- prefect/_vendor/fastapi/security/base.py +0 -6
- prefect/_vendor/fastapi/security/http.py +0 -172
- prefect/_vendor/fastapi/security/oauth2.py +0 -227
- prefect/_vendor/fastapi/security/open_id_connect_url.py +0 -34
- prefect/_vendor/fastapi/security/utils.py +0 -10
- prefect/_vendor/fastapi/staticfiles.py +0 -1
- prefect/_vendor/fastapi/templating.py +0 -3
- prefect/_vendor/fastapi/testclient.py +0 -1
- prefect/_vendor/fastapi/types.py +0 -3
- prefect/_vendor/fastapi/utils.py +0 -235
- prefect/_vendor/fastapi/websockets.py +0 -7
- prefect/_vendor/starlette/__init__.py +0 -1
- prefect/_vendor/starlette/_compat.py +0 -28
- prefect/_vendor/starlette/_exception_handler.py +0 -80
- prefect/_vendor/starlette/_utils.py +0 -88
- prefect/_vendor/starlette/applications.py +0 -261
- prefect/_vendor/starlette/authentication.py +0 -159
- prefect/_vendor/starlette/background.py +0 -43
- prefect/_vendor/starlette/concurrency.py +0 -59
- prefect/_vendor/starlette/config.py +0 -151
- prefect/_vendor/starlette/convertors.py +0 -87
- prefect/_vendor/starlette/datastructures.py +0 -707
- prefect/_vendor/starlette/endpoints.py +0 -130
- prefect/_vendor/starlette/exceptions.py +0 -60
- prefect/_vendor/starlette/formparsers.py +0 -276
- prefect/_vendor/starlette/middleware/__init__.py +0 -17
- prefect/_vendor/starlette/middleware/authentication.py +0 -52
- prefect/_vendor/starlette/middleware/base.py +0 -220
- prefect/_vendor/starlette/middleware/cors.py +0 -176
- prefect/_vendor/starlette/middleware/errors.py +0 -265
- prefect/_vendor/starlette/middleware/exceptions.py +0 -74
- prefect/_vendor/starlette/middleware/gzip.py +0 -113
- prefect/_vendor/starlette/middleware/httpsredirect.py +0 -19
- prefect/_vendor/starlette/middleware/sessions.py +0 -82
- prefect/_vendor/starlette/middleware/trustedhost.py +0 -64
- prefect/_vendor/starlette/middleware/wsgi.py +0 -147
- prefect/_vendor/starlette/requests.py +0 -328
- prefect/_vendor/starlette/responses.py +0 -347
- prefect/_vendor/starlette/routing.py +0 -933
- prefect/_vendor/starlette/schemas.py +0 -154
- prefect/_vendor/starlette/staticfiles.py +0 -248
- prefect/_vendor/starlette/status.py +0 -199
- prefect/_vendor/starlette/templating.py +0 -231
- prefect/_vendor/starlette/testclient.py +0 -804
- prefect/_vendor/starlette/types.py +0 -30
- prefect/_vendor/starlette/websockets.py +0 -193
- prefect/agent.py +0 -698
- prefect/deployments/deployments.py +0 -1042
- prefect/deprecated/__init__.py +0 -0
- prefect/deprecated/data_documents.py +0 -350
- prefect/deprecated/packaging/__init__.py +0 -12
- prefect/deprecated/packaging/base.py +0 -96
- prefect/deprecated/packaging/docker.py +0 -146
- prefect/deprecated/packaging/file.py +0 -92
- prefect/deprecated/packaging/orion.py +0 -80
- prefect/deprecated/packaging/serializers.py +0 -171
- prefect/events/instrument.py +0 -135
- prefect/infrastructure/base.py +0 -323
- prefect/infrastructure/container.py +0 -818
- prefect/infrastructure/kubernetes.py +0 -920
- prefect/infrastructure/process.py +0 -289
- prefect/new_task_engine.py +0 -423
- prefect/pydantic/__init__.py +0 -76
- prefect/pydantic/main.py +0 -39
- prefect/software/__init__.py +0 -2
- prefect/software/base.py +0 -50
- prefect/software/conda.py +0 -199
- prefect/software/pip.py +0 -122
- prefect/software/python.py +0 -52
- prefect/workers/block.py +0 -218
- prefect_client-2.19.2.dist-info/RECORD +0 -292
- {prefect_client-2.19.2.dist-info → prefect_client-3.0.0rc1.dist-info}/LICENSE +0 -0
- {prefect_client-2.19.2.dist-info → prefect_client-3.0.0rc1.dist-info}/WHEEL +0 -0
- {prefect_client-2.19.2.dist-info → prefect_client-3.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -3,65 +3,47 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeVar, Union
|
|
3
3
|
from uuid import UUID, uuid4
|
4
4
|
|
5
5
|
import jsonschema
|
6
|
-
|
7
|
-
from
|
8
|
-
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
9
|
-
|
10
|
-
if HAS_PYDANTIC_V2:
|
11
|
-
from pydantic.v1 import Field, root_validator, validator
|
12
|
-
else:
|
13
|
-
from pydantic import Field, root_validator, validator
|
6
|
+
from pydantic import Field, field_validator, model_validator
|
7
|
+
from pydantic_extra_types.pendulum_dt import DateTime
|
14
8
|
|
15
9
|
import prefect.client.schemas.objects as objects
|
16
10
|
from prefect._internal.schemas.bases import ActionBaseModel
|
17
|
-
from prefect._internal.schemas.fields import DateTimeTZ
|
18
|
-
from prefect._internal.schemas.serializers import orjson_dumps_extra_compatible
|
19
11
|
from prefect._internal.schemas.validators import (
|
20
|
-
|
21
|
-
raise_on_name_alphanumeric_underscores_only,
|
22
|
-
raise_on_name_with_banned_characters,
|
12
|
+
convert_to_strings,
|
23
13
|
remove_old_deployment_fields,
|
24
14
|
return_none_schedule,
|
15
|
+
validate_artifact_key,
|
16
|
+
validate_block_document_name,
|
17
|
+
validate_block_type_slug,
|
25
18
|
validate_message_template_variables,
|
26
19
|
validate_name_present_on_nonanonymous_blocks,
|
27
20
|
validate_schedule_max_scheduled_runs,
|
21
|
+
validate_variable_name,
|
22
|
+
)
|
23
|
+
from prefect.client.schemas.objects import (
|
24
|
+
StateDetails,
|
25
|
+
StateType,
|
28
26
|
)
|
29
|
-
from prefect.client.schemas.objects import StateDetails, StateType
|
30
27
|
from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
31
28
|
from prefect.settings import PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS
|
32
|
-
from prefect.types import
|
29
|
+
from prefect.types import (
|
30
|
+
MAX_VARIABLE_NAME_LENGTH,
|
31
|
+
Name,
|
32
|
+
NonEmptyishName,
|
33
|
+
NonNegativeFloat,
|
34
|
+
NonNegativeInteger,
|
35
|
+
PositiveInteger,
|
36
|
+
StrictVariableValue,
|
37
|
+
)
|
33
38
|
from prefect.utilities.collections import listrepr
|
34
39
|
from prefect.utilities.pydantic import get_class_fields_only
|
35
40
|
|
36
41
|
if TYPE_CHECKING:
|
37
|
-
from prefect.deprecated.data_documents import DataDocument
|
38
42
|
from prefect.results import BaseResult
|
39
43
|
|
40
44
|
R = TypeVar("R")
|
41
45
|
|
42
46
|
|
43
|
-
def validate_block_type_slug(value):
|
44
|
-
raise_on_name_alphanumeric_dashes_only(value, field_name="Block type slug")
|
45
|
-
return value
|
46
|
-
|
47
|
-
|
48
|
-
def validate_block_document_name(value):
|
49
|
-
if value is not None:
|
50
|
-
raise_on_name_alphanumeric_dashes_only(value, field_name="Block document name")
|
51
|
-
return value
|
52
|
-
|
53
|
-
|
54
|
-
def validate_artifact_key(value):
|
55
|
-
raise_on_name_alphanumeric_dashes_only(value, field_name="Artifact key")
|
56
|
-
return value
|
57
|
-
|
58
|
-
|
59
|
-
def validate_variable_name(value):
|
60
|
-
if value is not None:
|
61
|
-
raise_on_name_alphanumeric_underscores_only(value, field_name="Variable name")
|
62
|
-
return value
|
63
|
-
|
64
|
-
|
65
47
|
class StateCreate(ActionBaseModel):
|
66
48
|
"""Data used by the Prefect REST API to create a new state."""
|
67
49
|
|
@@ -69,7 +51,7 @@ class StateCreate(ActionBaseModel):
|
|
69
51
|
name: Optional[str] = Field(default=None)
|
70
52
|
message: Optional[str] = Field(default=None, examples=["Run started"])
|
71
53
|
state_details: StateDetails = Field(default_factory=StateDetails)
|
72
|
-
data: Union["BaseResult[R]",
|
54
|
+
data: Union["BaseResult[R]", Any] = Field(
|
73
55
|
default=None,
|
74
56
|
)
|
75
57
|
|
@@ -117,7 +99,8 @@ class DeploymentScheduleCreate(ActionBaseModel):
|
|
117
99
|
description="Whether or not a worker should catch up on Late runs for the schedule.",
|
118
100
|
)
|
119
101
|
|
120
|
-
@
|
102
|
+
@field_validator("max_scheduled_runs")
|
103
|
+
@classmethod
|
121
104
|
def validate_max_scheduled_runs(cls, v):
|
122
105
|
return validate_schedule_max_scheduled_runs(
|
123
106
|
v, PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS.value()
|
@@ -147,20 +130,27 @@ class DeploymentScheduleUpdate(ActionBaseModel):
|
|
147
130
|
description="Whether or not a worker should catch up on Late runs for the schedule.",
|
148
131
|
)
|
149
132
|
|
150
|
-
@
|
133
|
+
@field_validator("max_scheduled_runs")
|
134
|
+
@classmethod
|
151
135
|
def validate_max_scheduled_runs(cls, v):
|
152
136
|
return validate_schedule_max_scheduled_runs(
|
153
137
|
v, PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS.value()
|
154
138
|
)
|
155
139
|
|
156
140
|
|
157
|
-
class DeploymentCreate(
|
141
|
+
class DeploymentCreate(ActionBaseModel):
|
158
142
|
"""Data used by the Prefect REST API to create a deployment."""
|
159
143
|
|
160
|
-
@
|
144
|
+
@model_validator(mode="before")
|
145
|
+
@classmethod
|
161
146
|
def remove_old_fields(cls, values):
|
162
147
|
return remove_old_deployment_fields(values)
|
163
148
|
|
149
|
+
@field_validator("description", "tags", mode="before")
|
150
|
+
@classmethod
|
151
|
+
def convert_to_strings(cls, values):
|
152
|
+
return convert_to_strings(values)
|
153
|
+
|
164
154
|
name: str = Field(..., description="The name of the deployment.")
|
165
155
|
flow_id: UUID = Field(..., description="The ID of the flow to deploy.")
|
166
156
|
is_schedule_active: Optional[bool] = Field(None)
|
@@ -175,7 +165,7 @@ class DeploymentCreate(DeprecatedInfraOverridesField, ActionBaseModel):
|
|
175
165
|
"Whether or not the deployment should enforce the parameter schema."
|
176
166
|
),
|
177
167
|
)
|
178
|
-
parameter_openapi_schema: Optional[Dict[str, Any]] = Field(
|
168
|
+
parameter_openapi_schema: Optional[Dict[str, Any]] = Field(default_factory=dict)
|
179
169
|
parameters: Dict[str, Any] = Field(
|
180
170
|
default_factory=dict,
|
181
171
|
description="Parameters for flow runs scheduled by the deployment.",
|
@@ -197,7 +187,7 @@ class DeploymentCreate(DeprecatedInfraOverridesField, ActionBaseModel):
|
|
197
187
|
path: Optional[str] = Field(None)
|
198
188
|
version: Optional[str] = Field(None)
|
199
189
|
entrypoint: Optional[str] = Field(None)
|
200
|
-
job_variables:
|
190
|
+
job_variables: Dict[str, Any] = Field(
|
201
191
|
default_factory=dict,
|
202
192
|
description="Overrides to apply to flow run infrastructure at runtime.",
|
203
193
|
)
|
@@ -222,14 +212,16 @@ class DeploymentCreate(DeprecatedInfraOverridesField, ActionBaseModel):
|
|
222
212
|
jsonschema.validate(self.job_variables, variables_schema)
|
223
213
|
|
224
214
|
|
225
|
-
class DeploymentUpdate(
|
215
|
+
class DeploymentUpdate(ActionBaseModel):
|
226
216
|
"""Data used by the Prefect REST API to update a deployment."""
|
227
217
|
|
228
|
-
@
|
218
|
+
@model_validator(mode="before")
|
219
|
+
@classmethod
|
229
220
|
def remove_old_fields(cls, values):
|
230
221
|
return remove_old_deployment_fields(values)
|
231
222
|
|
232
|
-
@
|
223
|
+
@field_validator("schedule")
|
224
|
+
@classmethod
|
233
225
|
def validate_none_schedule(cls, v):
|
234
226
|
return return_none_schedule(v)
|
235
227
|
|
@@ -290,7 +282,7 @@ class FlowRunUpdate(ActionBaseModel):
|
|
290
282
|
|
291
283
|
name: Optional[str] = Field(None)
|
292
284
|
flow_version: Optional[str] = Field(None)
|
293
|
-
parameters: Optional[Dict[str, Any]] = Field(
|
285
|
+
parameters: Optional[Dict[str, Any]] = Field(default_factory=dict)
|
294
286
|
empirical_policy: objects.FlowRunPolicy = Field(
|
295
287
|
default_factory=objects.FlowRunPolicy
|
296
288
|
)
|
@@ -302,6 +294,7 @@ class FlowRunUpdate(ActionBaseModel):
|
|
302
294
|
class TaskRunCreate(ActionBaseModel):
|
303
295
|
"""Data used by the Prefect REST API to create a task run"""
|
304
296
|
|
297
|
+
id: Optional[UUID] = Field(None, description="The ID to assign to the task run")
|
305
298
|
# TaskRunCreate states must be provided as StateCreate objects
|
306
299
|
state: Optional[StateCreate] = Field(
|
307
300
|
default=None, description="The state of the task run to create"
|
@@ -323,7 +316,7 @@ class TaskRunCreate(ActionBaseModel):
|
|
323
316
|
),
|
324
317
|
)
|
325
318
|
cache_key: Optional[str] = Field(None)
|
326
|
-
cache_expiration: Optional[objects.
|
319
|
+
cache_expiration: Optional[objects.DateTime] = Field(None)
|
327
320
|
task_version: Optional[str] = Field(None)
|
328
321
|
empirical_policy: objects.TaskRunPolicy = Field(
|
329
322
|
default_factory=objects.TaskRunPolicy,
|
@@ -373,9 +366,6 @@ class FlowRunCreate(ActionBaseModel):
|
|
373
366
|
tags: List[str] = Field(default_factory=list)
|
374
367
|
idempotency_key: Optional[str] = Field(None)
|
375
368
|
|
376
|
-
class Config(ActionBaseModel.Config):
|
377
|
-
json_dumps = orjson_dumps_extra_compatible
|
378
|
-
|
379
369
|
|
380
370
|
class DeploymentFlowRunCreate(ActionBaseModel):
|
381
371
|
"""Data used by the Prefect REST API to create a flow run from a deployment."""
|
@@ -421,6 +411,37 @@ class ConcurrencyLimitCreate(ActionBaseModel):
|
|
421
411
|
concurrency_limit: int = Field(default=..., description="The concurrency limit.")
|
422
412
|
|
423
413
|
|
414
|
+
class ConcurrencyLimitV2Create(ActionBaseModel):
|
415
|
+
"""Data used by the Prefect REST API to create a v2 concurrency limit."""
|
416
|
+
|
417
|
+
active: bool = Field(
|
418
|
+
default=True, description="Whether the concurrency limit is active."
|
419
|
+
)
|
420
|
+
name: Name = Field(default=..., description="The name of the concurrency limit.")
|
421
|
+
limit: NonNegativeInteger = Field(default=..., description="The concurrency limit.")
|
422
|
+
active_slots: NonNegativeInteger = Field(
|
423
|
+
default=0, description="The number of active slots."
|
424
|
+
)
|
425
|
+
denied_slots: NonNegativeInteger = Field(
|
426
|
+
default=0, description="The number of denied slots."
|
427
|
+
)
|
428
|
+
slot_decay_per_second: NonNegativeFloat = Field(
|
429
|
+
default=0,
|
430
|
+
description="The decay rate for active slots when used as a rate limit.",
|
431
|
+
)
|
432
|
+
|
433
|
+
|
434
|
+
class ConcurrencyLimitV2Update(ActionBaseModel):
|
435
|
+
"""Data used by the Prefect REST API to update a v2 concurrency limit."""
|
436
|
+
|
437
|
+
active: Optional[bool] = Field(None)
|
438
|
+
name: Optional[Name] = Field(None)
|
439
|
+
limit: Optional[NonNegativeInteger] = Field(None)
|
440
|
+
active_slots: Optional[NonNegativeInteger] = Field(None)
|
441
|
+
denied_slots: Optional[NonNegativeInteger] = Field(None)
|
442
|
+
slot_decay_per_second: Optional[NonNegativeFloat] = Field(None)
|
443
|
+
|
444
|
+
|
424
445
|
class BlockTypeCreate(ActionBaseModel):
|
425
446
|
"""Data used by the Prefect REST API to create a block type."""
|
426
447
|
|
@@ -442,9 +463,7 @@ class BlockTypeCreate(ActionBaseModel):
|
|
442
463
|
)
|
443
464
|
|
444
465
|
# validators
|
445
|
-
_validate_slug_format =
|
446
|
-
validate_block_type_slug
|
447
|
-
)
|
466
|
+
_validate_slug_format = field_validator("slug")(validate_block_type_slug)
|
448
467
|
|
449
468
|
|
450
469
|
class BlockTypeUpdate(ActionBaseModel):
|
@@ -480,7 +499,7 @@ class BlockSchemaCreate(ActionBaseModel):
|
|
480
499
|
class BlockDocumentCreate(ActionBaseModel):
|
481
500
|
"""Data used by the Prefect REST API to create a block document."""
|
482
501
|
|
483
|
-
name: Optional[
|
502
|
+
name: Optional[Name] = Field(
|
484
503
|
default=None, description="The name of the block document"
|
485
504
|
)
|
486
505
|
data: Dict[str, Any] = Field(
|
@@ -500,11 +519,9 @@ class BlockDocumentCreate(ActionBaseModel):
|
|
500
519
|
),
|
501
520
|
)
|
502
521
|
|
503
|
-
_validate_name_format =
|
504
|
-
validate_block_document_name
|
505
|
-
)
|
522
|
+
_validate_name_format = field_validator("name")(validate_block_document_name)
|
506
523
|
|
507
|
-
@
|
524
|
+
@model_validator(mode="before")
|
508
525
|
def validate_name_is_present_if_not_anonymous(cls, values):
|
509
526
|
return validate_name_present_on_nonanonymous_blocks(values)
|
510
527
|
|
@@ -545,7 +562,7 @@ class LogCreate(ActionBaseModel):
|
|
545
562
|
name: str = Field(default=..., description="The logger name.")
|
546
563
|
level: int = Field(default=..., description="The log level.")
|
547
564
|
message: str = Field(default=..., description="The log message.")
|
548
|
-
timestamp:
|
565
|
+
timestamp: DateTime = Field(default=..., description="The log timestamp.")
|
549
566
|
flow_run_id: Optional[UUID] = Field(None)
|
550
567
|
task_run_id: Optional[UUID] = Field(None)
|
551
568
|
|
@@ -553,7 +570,7 @@ class LogCreate(ActionBaseModel):
|
|
553
570
|
class WorkPoolCreate(ActionBaseModel):
|
554
571
|
"""Data used by the Prefect REST API to create a work pool."""
|
555
572
|
|
556
|
-
name:
|
573
|
+
name: NonEmptyishName = Field(
|
557
574
|
description="The name of the work pool.",
|
558
575
|
)
|
559
576
|
description: Optional[str] = Field(None)
|
@@ -621,7 +638,7 @@ class WorkQueueUpdate(ActionBaseModel):
|
|
621
638
|
)
|
622
639
|
concurrency_limit: Optional[int] = Field(None)
|
623
640
|
priority: Optional[int] = Field(None)
|
624
|
-
last_polled: Optional[
|
641
|
+
last_polled: Optional[DateTime] = Field(None)
|
625
642
|
|
626
643
|
# DEPRECATED
|
627
644
|
|
@@ -661,7 +678,8 @@ class FlowRunNotificationPolicyCreate(ActionBaseModel):
|
|
661
678
|
],
|
662
679
|
)
|
663
680
|
|
664
|
-
@
|
681
|
+
@field_validator("message_template")
|
682
|
+
@classmethod
|
665
683
|
def validate_message_template_variables(cls, v):
|
666
684
|
return validate_message_template_variables(v)
|
667
685
|
|
@@ -687,9 +705,7 @@ class ArtifactCreate(ActionBaseModel):
|
|
687
705
|
flow_run_id: Optional[UUID] = Field(None)
|
688
706
|
task_run_id: Optional[UUID] = Field(None)
|
689
707
|
|
690
|
-
_validate_artifact_format =
|
691
|
-
validate_artifact_key
|
692
|
-
)
|
708
|
+
_validate_artifact_format = field_validator("key")(validate_artifact_key)
|
693
709
|
|
694
710
|
|
695
711
|
class ArtifactUpdate(ActionBaseModel):
|
@@ -707,18 +723,17 @@ class VariableCreate(ActionBaseModel):
|
|
707
723
|
default=...,
|
708
724
|
description="The name of the variable",
|
709
725
|
examples=["my_variable"],
|
710
|
-
max_length=
|
726
|
+
max_length=MAX_VARIABLE_NAME_LENGTH,
|
711
727
|
)
|
712
|
-
value:
|
728
|
+
value: StrictVariableValue = Field(
|
713
729
|
default=...,
|
714
730
|
description="The value of the variable",
|
715
731
|
examples=["my-value"],
|
716
|
-
max_length=objects.MAX_VARIABLE_VALUE_LENGTH,
|
717
732
|
)
|
718
733
|
tags: Optional[List[str]] = Field(default=None)
|
719
734
|
|
720
735
|
# validators
|
721
|
-
_validate_name_format =
|
736
|
+
_validate_name_format = field_validator("name")(validate_variable_name)
|
722
737
|
|
723
738
|
|
724
739
|
class VariableUpdate(ActionBaseModel):
|
@@ -728,24 +743,23 @@ class VariableUpdate(ActionBaseModel):
|
|
728
743
|
default=None,
|
729
744
|
description="The name of the variable",
|
730
745
|
examples=["my_variable"],
|
731
|
-
max_length=
|
746
|
+
max_length=MAX_VARIABLE_NAME_LENGTH,
|
732
747
|
)
|
733
|
-
value:
|
748
|
+
value: StrictVariableValue = Field(
|
734
749
|
default=None,
|
735
750
|
description="The value of the variable",
|
736
751
|
examples=["my-value"],
|
737
|
-
max_length=objects.MAX_VARIABLE_NAME_LENGTH,
|
738
752
|
)
|
739
753
|
tags: Optional[List[str]] = Field(default=None)
|
740
754
|
|
741
755
|
# validators
|
742
|
-
_validate_name_format =
|
756
|
+
_validate_name_format = field_validator("name")(validate_variable_name)
|
743
757
|
|
744
758
|
|
745
759
|
class GlobalConcurrencyLimitCreate(ActionBaseModel):
|
746
760
|
"""Data used by the Prefect REST API to create a global concurrency limit."""
|
747
761
|
|
748
|
-
name:
|
762
|
+
name: Name = Field(description="The name of the global concurrency limit.")
|
749
763
|
limit: NonNegativeInteger = Field(
|
750
764
|
description=(
|
751
765
|
"The maximum number of slots that can be occupied on this concurrency"
|
@@ -768,20 +782,12 @@ class GlobalConcurrencyLimitCreate(ActionBaseModel):
|
|
768
782
|
),
|
769
783
|
)
|
770
784
|
|
771
|
-
@validator("name", check_fields=False)
|
772
|
-
def validate_name_characters(cls, v):
|
773
|
-
return raise_on_name_with_banned_characters(v)
|
774
|
-
|
775
785
|
|
776
786
|
class GlobalConcurrencyLimitUpdate(ActionBaseModel):
|
777
787
|
"""Data used by the Prefect REST API to update a global concurrency limit."""
|
778
788
|
|
779
|
-
name: Optional[
|
789
|
+
name: Optional[Name] = Field(None)
|
780
790
|
limit: Optional[NonNegativeInteger] = Field(None)
|
781
791
|
active: Optional[NonNegativeInteger] = Field(None)
|
782
792
|
active_slots: Optional[NonNegativeInteger] = Field(None)
|
783
793
|
slot_decay_per_second: Optional[NonNegativeFloat] = Field(None)
|
784
|
-
|
785
|
-
@validator("name", check_fields=False)
|
786
|
-
def validate_name_characters(cls, v):
|
787
|
-
return raise_on_name_with_banned_characters(v)
|
@@ -5,15 +5,10 @@ Schemas that define Prefect REST API filtering operations.
|
|
5
5
|
from typing import List, Optional
|
6
6
|
from uuid import UUID
|
7
7
|
|
8
|
-
from
|
9
|
-
|
10
|
-
if HAS_PYDANTIC_V2:
|
11
|
-
from pydantic.v1 import Field
|
12
|
-
else:
|
13
|
-
from pydantic import Field
|
8
|
+
from pydantic import Field
|
9
|
+
from pydantic_extra_types.pendulum_dt import DateTime
|
14
10
|
|
15
11
|
from prefect._internal.schemas.bases import PrefectBaseModel
|
16
|
-
from prefect._internal.schemas.fields import DateTimeTZ
|
17
12
|
from prefect.client.schemas.objects import StateType
|
18
13
|
from prefect.utilities.collections import AutoEnum
|
19
14
|
|
@@ -180,8 +175,12 @@ class FlowRunFilterStateName(PrefectBaseModel):
|
|
180
175
|
|
181
176
|
|
182
177
|
class FlowRunFilterState(PrefectBaseModel, OperatorMixin):
|
183
|
-
type: Optional[FlowRunFilterStateType]
|
184
|
-
|
178
|
+
type: Optional[FlowRunFilterStateType] = Field(
|
179
|
+
default=None, description="Filter criteria for `FlowRun` state type"
|
180
|
+
)
|
181
|
+
name: Optional[FlowRunFilterStateName] = Field(
|
182
|
+
default=None, description="Filter criteria for `FlowRun` state name"
|
183
|
+
)
|
185
184
|
|
186
185
|
|
187
186
|
class FlowRunFilterFlowVersion(PrefectBaseModel):
|
@@ -195,11 +194,11 @@ class FlowRunFilterFlowVersion(PrefectBaseModel):
|
|
195
194
|
class FlowRunFilterStartTime(PrefectBaseModel):
|
196
195
|
"""Filter by `FlowRun.start_time`."""
|
197
196
|
|
198
|
-
before_: Optional[
|
197
|
+
before_: Optional[DateTime] = Field(
|
199
198
|
default=None,
|
200
199
|
description="Only include flow runs starting at or before this time",
|
201
200
|
)
|
202
|
-
after_: Optional[
|
201
|
+
after_: Optional[DateTime] = Field(
|
203
202
|
default=None,
|
204
203
|
description="Only include flow runs starting at or after this time",
|
205
204
|
)
|
@@ -211,11 +210,11 @@ class FlowRunFilterStartTime(PrefectBaseModel):
|
|
211
210
|
class FlowRunFilterExpectedStartTime(PrefectBaseModel):
|
212
211
|
"""Filter by `FlowRun.expected_start_time`."""
|
213
212
|
|
214
|
-
before_: Optional[
|
213
|
+
before_: Optional[DateTime] = Field(
|
215
214
|
default=None,
|
216
215
|
description="Only include flow runs scheduled to start at or before this time",
|
217
216
|
)
|
218
|
-
after_: Optional[
|
217
|
+
after_: Optional[DateTime] = Field(
|
219
218
|
default=None,
|
220
219
|
description="Only include flow runs scheduled to start at or after this time",
|
221
220
|
)
|
@@ -224,14 +223,14 @@ class FlowRunFilterExpectedStartTime(PrefectBaseModel):
|
|
224
223
|
class FlowRunFilterNextScheduledStartTime(PrefectBaseModel):
|
225
224
|
"""Filter by `FlowRun.next_scheduled_start_time`."""
|
226
225
|
|
227
|
-
before_: Optional[
|
226
|
+
before_: Optional[DateTime] = Field(
|
228
227
|
default=None,
|
229
228
|
description=(
|
230
229
|
"Only include flow runs with a next_scheduled_start_time or before this"
|
231
230
|
" time"
|
232
231
|
),
|
233
232
|
)
|
234
|
-
after_: Optional[
|
233
|
+
after_: Optional[DateTime] = Field(
|
235
234
|
default=None,
|
236
235
|
description=(
|
237
236
|
"Only include flow runs with a next_scheduled_start_time at or after this"
|
@@ -407,11 +406,11 @@ class TaskRunFilterSubFlowRuns(PrefectBaseModel):
|
|
407
406
|
class TaskRunFilterStartTime(PrefectBaseModel):
|
408
407
|
"""Filter by `TaskRun.start_time`."""
|
409
408
|
|
410
|
-
before_: Optional[
|
409
|
+
before_: Optional[DateTime] = Field(
|
411
410
|
default=None,
|
412
411
|
description="Only include task runs starting at or before this time",
|
413
412
|
)
|
414
|
-
after_: Optional[
|
413
|
+
after_: Optional[DateTime] = Field(
|
415
414
|
default=None,
|
416
415
|
description="Only include task runs starting at or after this time",
|
417
416
|
)
|
@@ -558,11 +557,11 @@ class LogFilterLevel(PrefectBaseModel):
|
|
558
557
|
class LogFilterTimestamp(PrefectBaseModel):
|
559
558
|
"""Filter by `Log.timestamp`."""
|
560
559
|
|
561
|
-
before_: Optional[
|
560
|
+
before_: Optional[DateTime] = Field(
|
562
561
|
default=None,
|
563
562
|
description="Only include logs with a timestamp at or before this time",
|
564
563
|
)
|
565
|
-
after_: Optional[
|
564
|
+
after_: Optional[DateTime] = Field(
|
566
565
|
default=None,
|
567
566
|
description="Only include logs with a timestamp at or after this time",
|
568
567
|
)
|
@@ -883,13 +882,13 @@ class WorkerFilterWorkPoolId(PrefectBaseModel):
|
|
883
882
|
class WorkerFilterLastHeartbeatTime(PrefectBaseModel):
|
884
883
|
"""Filter by `Worker.last_heartbeat_time`."""
|
885
884
|
|
886
|
-
before_: Optional[
|
885
|
+
before_: Optional[DateTime] = Field(
|
887
886
|
default=None,
|
888
887
|
description=(
|
889
888
|
"Only include processes whose last heartbeat was at or before this time"
|
890
889
|
),
|
891
890
|
)
|
892
|
-
after_: Optional[
|
891
|
+
after_: Optional[DateTime] = Field(
|
893
892
|
default=None,
|
894
893
|
description=(
|
895
894
|
"Only include processes whose last heartbeat was at or after this time"
|
@@ -1093,22 +1092,6 @@ class VariableFilterName(PrefectBaseModel):
|
|
1093
1092
|
)
|
1094
1093
|
|
1095
1094
|
|
1096
|
-
class VariableFilterValue(PrefectBaseModel):
|
1097
|
-
"""Filter by `Variable.value`."""
|
1098
|
-
|
1099
|
-
any_: Optional[List[str]] = Field(
|
1100
|
-
default=None, description="A list of variables value to include"
|
1101
|
-
)
|
1102
|
-
like_: Optional[str] = Field(
|
1103
|
-
default=None,
|
1104
|
-
description=(
|
1105
|
-
"A string to match variable value against. This can include "
|
1106
|
-
"SQL wildcard characters like `%` and `_`."
|
1107
|
-
),
|
1108
|
-
examples=["my-value-%"],
|
1109
|
-
)
|
1110
|
-
|
1111
|
-
|
1112
1095
|
class VariableFilterTags(PrefectBaseModel, OperatorMixin):
|
1113
1096
|
"""Filter by `Variable.tags`."""
|
1114
1097
|
|
@@ -1134,9 +1117,6 @@ class VariableFilter(PrefectBaseModel, OperatorMixin):
|
|
1134
1117
|
name: Optional[VariableFilterName] = Field(
|
1135
1118
|
default=None, description="Filter criteria for `Variable.name`"
|
1136
1119
|
)
|
1137
|
-
value: Optional[VariableFilterValue] = Field(
|
1138
|
-
default=None, description="Filter criteria for `Variable.value`"
|
1139
|
-
)
|
1140
1120
|
tags: Optional[VariableFilterTags] = Field(
|
1141
1121
|
default=None, description="Filter criteria for `Variable.tags`"
|
1142
1122
|
)
|