prefect-client 2.20.2__py3-none-any.whl → 3.0.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.
- prefect/__init__.py +74 -110
- prefect/_internal/compatibility/deprecated.py +6 -115
- prefect/_internal/compatibility/experimental.py +4 -79
- prefect/_internal/compatibility/migration.py +166 -0
- prefect/_internal/concurrency/__init__.py +2 -2
- prefect/_internal/concurrency/api.py +1 -35
- 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/primitives.py +1 -0
- prefect/_internal/concurrency/services.py +23 -0
- prefect/_internal/concurrency/threads.py +35 -0
- prefect/_internal/concurrency/waiters.py +0 -28
- prefect/_internal/integrations.py +7 -0
- prefect/_internal/pydantic/__init__.py +0 -45
- prefect/_internal/pydantic/annotations/pendulum.py +2 -2
- 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/pytz.py +1 -1
- prefect/_internal/retries.py +61 -0
- prefect/_internal/schemas/bases.py +45 -177
- prefect/_internal/schemas/fields.py +1 -43
- prefect/_internal/schemas/validators.py +47 -233
- prefect/agent.py +3 -695
- prefect/artifacts.py +173 -14
- prefect/automations.py +39 -4
- prefect/blocks/abstract.py +1 -1
- prefect/blocks/core.py +423 -164
- prefect/blocks/fields.py +2 -57
- prefect/blocks/notifications.py +43 -28
- prefect/blocks/redis.py +168 -0
- prefect/blocks/system.py +67 -20
- prefect/blocks/webhook.py +2 -9
- prefect/cache_policies.py +239 -0
- prefect/client/__init__.py +4 -0
- prefect/client/base.py +33 -27
- prefect/client/cloud.py +65 -20
- prefect/client/collections.py +1 -1
- prefect/client/orchestration.py +667 -440
- prefect/client/schemas/actions.py +115 -100
- prefect/client/schemas/filters.py +46 -52
- prefect/client/schemas/objects.py +228 -178
- prefect/client/schemas/responses.py +18 -36
- prefect/client/schemas/schedules.py +55 -36
- prefect/client/schemas/sorting.py +2 -0
- prefect/client/subscriptions.py +8 -7
- prefect/client/types/flexible_schedule_list.py +11 -0
- prefect/client/utilities.py +9 -6
- prefect/concurrency/asyncio.py +60 -11
- prefect/concurrency/context.py +24 -0
- prefect/concurrency/events.py +2 -2
- prefect/concurrency/services.py +46 -16
- prefect/concurrency/sync.py +51 -7
- prefect/concurrency/v1/asyncio.py +143 -0
- prefect/concurrency/v1/context.py +27 -0
- prefect/concurrency/v1/events.py +61 -0
- prefect/concurrency/v1/services.py +116 -0
- prefect/concurrency/v1/sync.py +92 -0
- prefect/context.py +246 -149
- prefect/deployments/__init__.py +33 -18
- prefect/deployments/base.py +10 -15
- prefect/deployments/deployments.py +2 -1048
- prefect/deployments/flow_runs.py +178 -0
- prefect/deployments/runner.py +72 -173
- prefect/deployments/schedules.py +31 -25
- prefect/deployments/steps/__init__.py +0 -1
- prefect/deployments/steps/core.py +7 -0
- prefect/deployments/steps/pull.py +15 -21
- prefect/deployments/steps/utility.py +2 -1
- prefect/docker/__init__.py +20 -0
- prefect/docker/docker_image.py +82 -0
- prefect/engine.py +15 -2466
- prefect/events/actions.py +17 -23
- prefect/events/cli/automations.py +20 -7
- prefect/events/clients.py +142 -80
- prefect/events/filters.py +14 -18
- prefect/events/related.py +74 -75
- 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 +46 -65
- prefect/events/schemas/labelling.py +10 -14
- prefect/events/utilities.py +4 -5
- prefect/events/worker.py +23 -8
- prefect/exceptions.py +15 -0
- prefect/filesystems.py +30 -529
- prefect/flow_engine.py +827 -0
- prefect/flow_runs.py +379 -7
- prefect/flows.py +470 -360
- prefect/futures.py +382 -331
- prefect/infrastructure/__init__.py +5 -26
- prefect/infrastructure/base.py +3 -320
- prefect/infrastructure/provisioners/__init__.py +5 -3
- prefect/infrastructure/provisioners/cloud_run.py +13 -8
- prefect/infrastructure/provisioners/container_instance.py +14 -9
- prefect/infrastructure/provisioners/ecs.py +10 -8
- prefect/infrastructure/provisioners/modal.py +8 -5
- prefect/input/__init__.py +4 -0
- prefect/input/actions.py +2 -4
- prefect/input/run_input.py +9 -9
- prefect/logging/formatters.py +2 -4
- prefect/logging/handlers.py +9 -14
- prefect/logging/loggers.py +5 -5
- prefect/main.py +72 -0
- prefect/plugins.py +2 -64
- prefect/profiles.toml +16 -2
- prefect/records/__init__.py +1 -0
- prefect/records/base.py +223 -0
- prefect/records/filesystem.py +207 -0
- prefect/records/memory.py +178 -0
- prefect/records/result_store.py +64 -0
- prefect/results.py +577 -504
- prefect/runner/runner.py +124 -51
- prefect/runner/server.py +32 -34
- prefect/runner/storage.py +3 -12
- prefect/runner/submit.py +2 -10
- prefect/runner/utils.py +2 -2
- prefect/runtime/__init__.py +1 -0
- prefect/runtime/deployment.py +1 -0
- prefect/runtime/flow_run.py +40 -5
- prefect/runtime/task_run.py +1 -0
- prefect/serializers.py +28 -39
- prefect/server/api/collections_data/views/aggregate-worker-metadata.json +5 -14
- prefect/settings.py +209 -332
- prefect/states.py +160 -63
- prefect/task_engine.py +1478 -57
- prefect/task_runners.py +383 -287
- prefect/task_runs.py +240 -0
- prefect/task_worker.py +463 -0
- prefect/tasks.py +684 -374
- prefect/transactions.py +410 -0
- prefect/types/__init__.py +72 -86
- prefect/types/entrypoint.py +13 -0
- prefect/utilities/annotations.py +4 -3
- prefect/utilities/asyncutils.py +227 -148
- prefect/utilities/callables.py +138 -48
- prefect/utilities/collections.py +134 -86
- prefect/utilities/dispatch.py +27 -14
- prefect/utilities/dockerutils.py +11 -4
- prefect/utilities/engine.py +186 -32
- prefect/utilities/filesystem.py +4 -5
- prefect/utilities/importtools.py +26 -27
- prefect/utilities/pydantic.py +128 -38
- prefect/utilities/schema_tools/hydration.py +18 -1
- prefect/utilities/schema_tools/validation.py +30 -0
- prefect/utilities/services.py +35 -9
- prefect/utilities/templating.py +12 -2
- prefect/utilities/timeout.py +20 -5
- prefect/utilities/urls.py +195 -0
- prefect/utilities/visualization.py +1 -0
- prefect/variables.py +78 -59
- prefect/workers/__init__.py +0 -1
- prefect/workers/base.py +237 -244
- prefect/workers/block.py +5 -226
- prefect/workers/cloud.py +6 -0
- prefect/workers/process.py +265 -12
- prefect/workers/server.py +29 -11
- {prefect_client-2.20.2.dist-info → prefect_client-3.0.0.dist-info}/METADATA +30 -26
- prefect_client-3.0.0.dist-info/RECORD +201 -0
- {prefect_client-2.20.2.dist-info → prefect_client-3.0.0.dist-info}/WHEEL +1 -1
- 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/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/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/py.typed +0 -0
- 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/py.typed +0 -0
- 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/blocks/kubernetes.py +0 -119
- 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/container.py +0 -824
- prefect/infrastructure/kubernetes.py +0 -920
- prefect/infrastructure/process.py +0 -289
- prefect/manifests.py +0 -20
- prefect/new_flow_engine.py +0 -449
- 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/task_server.py +0 -322
- prefect_client-2.20.2.dist-info/RECORD +0 -294
- /prefect/{_internal/pydantic/utilities → client/types}/__init__.py +0 -0
- /prefect/{_vendor → concurrency/v1}/__init__.py +0 -0
- {prefect_client-2.20.2.dist-info → prefect_client-3.0.0.dist-info}/LICENSE +0 -0
- {prefect_client-2.20.2.dist-info → prefect_client-3.0.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,6 @@
|
|
1
1
|
import datetime
|
2
|
+
import warnings
|
3
|
+
from functools import partial
|
2
4
|
from typing import (
|
3
5
|
TYPE_CHECKING,
|
4
6
|
Any,
|
@@ -6,38 +8,36 @@ from typing import (
|
|
6
8
|
Generic,
|
7
9
|
List,
|
8
10
|
Optional,
|
9
|
-
TypeVar,
|
10
11
|
Union,
|
11
12
|
overload,
|
12
13
|
)
|
13
|
-
from uuid import UUID
|
14
|
+
from uuid import UUID, uuid4
|
14
15
|
|
15
16
|
import orjson
|
16
17
|
import pendulum
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
from pydantic import (
|
19
|
+
ConfigDict,
|
20
|
+
Field,
|
21
|
+
HttpUrl,
|
22
|
+
IPvAnyNetwork,
|
23
|
+
SerializationInfo,
|
24
|
+
field_validator,
|
25
|
+
model_serializer,
|
26
|
+
model_validator,
|
21
27
|
)
|
22
|
-
from
|
23
|
-
from
|
24
|
-
|
25
|
-
if HAS_PYDANTIC_V2:
|
26
|
-
from pydantic.v1 import Field, HttpUrl, root_validator, validator
|
27
|
-
else:
|
28
|
-
from pydantic import Field, HttpUrl, root_validator, validator
|
29
|
-
|
30
|
-
from typing_extensions import Literal
|
28
|
+
from pydantic.functional_validators import ModelWrapValidatorHandler
|
29
|
+
from pydantic_extra_types.pendulum_dt import DateTime
|
30
|
+
from typing_extensions import Literal, Self, TypeVar
|
31
31
|
|
32
|
+
from prefect._internal.compatibility.migration import getattr_migration
|
32
33
|
from prefect._internal.schemas.bases import ObjectBaseModel, PrefectBaseModel
|
33
|
-
from prefect._internal.schemas.fields import CreatedBy,
|
34
|
+
from prefect._internal.schemas.fields import CreatedBy, UpdatedBy
|
34
35
|
from prefect._internal.schemas.validators import (
|
35
36
|
get_or_create_run_name,
|
36
|
-
get_or_create_state_name,
|
37
37
|
list_length_50_or_less,
|
38
38
|
raise_on_name_alphanumeric_dashes_only,
|
39
|
-
raise_on_name_with_banned_characters,
|
40
39
|
set_run_policy_deprecated_fields,
|
40
|
+
validate_block_document_name,
|
41
41
|
validate_default_queue_id_not_none,
|
42
42
|
validate_max_metadata_length,
|
43
43
|
validate_message_template_variables,
|
@@ -47,15 +47,22 @@ from prefect._internal.schemas.validators import (
|
|
47
47
|
)
|
48
48
|
from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
49
49
|
from prefect.settings import PREFECT_CLOUD_API_URL, PREFECT_CLOUD_UI_URL
|
50
|
-
from prefect.
|
50
|
+
from prefect.types import (
|
51
|
+
MAX_VARIABLE_NAME_LENGTH,
|
52
|
+
Name,
|
53
|
+
NonNegativeInteger,
|
54
|
+
PositiveInteger,
|
55
|
+
StrictVariableValue,
|
56
|
+
)
|
57
|
+
from prefect.utilities.collections import AutoEnum, listrepr, visit_collection
|
51
58
|
from prefect.utilities.names import generate_slug
|
59
|
+
from prefect.utilities.pydantic import handle_secret_render
|
52
60
|
|
53
61
|
if TYPE_CHECKING:
|
54
|
-
from prefect.deprecated.data_documents import DataDocument
|
55
62
|
from prefect.results import BaseResult
|
56
63
|
|
57
64
|
|
58
|
-
R = TypeVar("R")
|
65
|
+
R = TypeVar("R", default=Any)
|
59
66
|
|
60
67
|
|
61
68
|
DEFAULT_BLOCK_SCHEMA_VERSION = "non-versioned"
|
@@ -73,8 +80,6 @@ FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS = [
|
|
73
80
|
"flow_run_state_timestamp",
|
74
81
|
"flow_run_state_message",
|
75
82
|
]
|
76
|
-
MAX_VARIABLE_NAME_LENGTH = 255
|
77
|
-
MAX_VARIABLE_VALUE_LENGTH = 5000
|
78
83
|
|
79
84
|
|
80
85
|
class StateType(AutoEnum):
|
@@ -91,6 +96,14 @@ class StateType(AutoEnum):
|
|
91
96
|
CANCELLING = AutoEnum.auto()
|
92
97
|
|
93
98
|
|
99
|
+
TERMINAL_STATES = {
|
100
|
+
StateType.COMPLETED,
|
101
|
+
StateType.CANCELLED,
|
102
|
+
StateType.FAILED,
|
103
|
+
StateType.CRASHED,
|
104
|
+
}
|
105
|
+
|
106
|
+
|
94
107
|
class WorkPoolStatus(AutoEnum):
|
95
108
|
"""Enumeration of work pool statuses."""
|
96
109
|
|
@@ -130,11 +143,12 @@ class StateDetails(PrefectBaseModel):
|
|
130
143
|
task_run_id: Optional[UUID] = None
|
131
144
|
# for task runs that represent subflows, the subflow's run ID
|
132
145
|
child_flow_run_id: Optional[UUID] = None
|
133
|
-
scheduled_time:
|
146
|
+
scheduled_time: Optional[DateTime] = None
|
134
147
|
cache_key: Optional[str] = None
|
135
|
-
cache_expiration:
|
148
|
+
cache_expiration: Optional[DateTime] = None
|
149
|
+
deferred: Optional[bool] = None
|
136
150
|
untrackable_result: bool = False
|
137
|
-
pause_timeout:
|
151
|
+
pause_timeout: Optional[DateTime] = None
|
138
152
|
pause_reschedule: bool = False
|
139
153
|
pause_key: Optional[str] = None
|
140
154
|
run_input_keyset: Optional[Dict[str, str]] = None
|
@@ -151,10 +165,10 @@ class State(ObjectBaseModel, Generic[R]):
|
|
151
165
|
|
152
166
|
type: StateType
|
153
167
|
name: Optional[str] = Field(default=None)
|
154
|
-
timestamp:
|
168
|
+
timestamp: DateTime = Field(default_factory=lambda: pendulum.now("UTC"))
|
155
169
|
message: Optional[str] = Field(default=None, examples=["Run started"])
|
156
170
|
state_details: StateDetails = Field(default_factory=StateDetails)
|
157
|
-
data: Union["BaseResult[R]",
|
171
|
+
data: Union["BaseResult[R]", Any] = Field(
|
158
172
|
default=None,
|
159
173
|
)
|
160
174
|
|
@@ -167,7 +181,10 @@ class State(ObjectBaseModel, Generic[R]):
|
|
167
181
|
...
|
168
182
|
|
169
183
|
def result(
|
170
|
-
self,
|
184
|
+
self,
|
185
|
+
raise_on_failure: bool = True,
|
186
|
+
fetch: Optional[bool] = None,
|
187
|
+
retry_result_failure: bool = True,
|
171
188
|
) -> Union[R, Exception]:
|
172
189
|
"""
|
173
190
|
Retrieve the result attached to this state.
|
@@ -179,6 +196,8 @@ class State(ObjectBaseModel, Generic[R]):
|
|
179
196
|
results into data. For synchronous users, this defaults to `True`.
|
180
197
|
For asynchronous users, this defaults to `False` for backwards
|
181
198
|
compatibility.
|
199
|
+
retry_result_failure: a boolean specifying whether to retry on failures to
|
200
|
+
load the result from result storage
|
182
201
|
|
183
202
|
Raises:
|
184
203
|
TypeError: If the state is failed but the result is not an exception.
|
@@ -241,7 +260,12 @@ class State(ObjectBaseModel, Generic[R]):
|
|
241
260
|
"""
|
242
261
|
from prefect.states import get_state_result
|
243
262
|
|
244
|
-
return get_state_result(
|
263
|
+
return get_state_result(
|
264
|
+
self,
|
265
|
+
raise_on_failure=raise_on_failure,
|
266
|
+
fetch=fetch,
|
267
|
+
retry_result_failure=retry_result_failure,
|
268
|
+
)
|
245
269
|
|
246
270
|
def to_state_create(self):
|
247
271
|
"""
|
@@ -254,32 +278,35 @@ class State(ObjectBaseModel, Generic[R]):
|
|
254
278
|
from prefect.client.schemas.actions import StateCreate
|
255
279
|
from prefect.results import BaseResult
|
256
280
|
|
281
|
+
if isinstance(self.data, BaseResult) and self.data.serialize_to_none is False:
|
282
|
+
data = self.data
|
283
|
+
else:
|
284
|
+
data = None
|
285
|
+
|
257
286
|
return StateCreate(
|
258
287
|
type=self.type,
|
259
288
|
name=self.name,
|
260
289
|
message=self.message,
|
261
|
-
data=
|
290
|
+
data=data,
|
262
291
|
state_details=self.state_details,
|
263
292
|
)
|
264
293
|
|
265
|
-
@
|
266
|
-
def default_name_from_type(
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
state_details.scheduled_time = pendulum.now("utc")
|
282
|
-
return values
|
294
|
+
@model_validator(mode="after")
|
295
|
+
def default_name_from_type(self) -> Self:
|
296
|
+
"""If a name is not provided, use the type"""
|
297
|
+
# if `type` is not in `values` it means the `type` didn't pass its own
|
298
|
+
# validation check and an error will be raised after this function is called
|
299
|
+
name = self.name
|
300
|
+
if name is None and self.type:
|
301
|
+
self.name = " ".join([v.capitalize() for v in self.type.value.split("_")])
|
302
|
+
return self
|
303
|
+
|
304
|
+
@model_validator(mode="after")
|
305
|
+
def default_scheduled_start_time(self) -> Self:
|
306
|
+
if self.type == StateType.SCHEDULED:
|
307
|
+
if not self.state_details.scheduled_time:
|
308
|
+
self.state_details.scheduled_time = DateTime.now("utc")
|
309
|
+
return self
|
283
310
|
|
284
311
|
def is_scheduled(self) -> bool:
|
285
312
|
return self.type == StateType.SCHEDULED
|
@@ -306,30 +333,35 @@ class State(ObjectBaseModel, Generic[R]):
|
|
306
333
|
return self.type == StateType.CANCELLING
|
307
334
|
|
308
335
|
def is_final(self) -> bool:
|
309
|
-
return self.type in
|
310
|
-
StateType.CANCELLED,
|
311
|
-
StateType.FAILED,
|
312
|
-
StateType.COMPLETED,
|
313
|
-
StateType.CRASHED,
|
314
|
-
}
|
336
|
+
return self.type in TERMINAL_STATES
|
315
337
|
|
316
338
|
def is_paused(self) -> bool:
|
317
339
|
return self.type == StateType.PAUSED
|
318
340
|
|
319
|
-
def
|
320
|
-
self,
|
321
|
-
*,
|
322
|
-
update: Optional[Dict[str, Any]] = None,
|
323
|
-
reset_fields: bool = False,
|
324
|
-
**kwargs,
|
341
|
+
def model_copy(
|
342
|
+
self, *, update: Optional[Dict[str, Any]] = None, deep: bool = False
|
325
343
|
):
|
326
344
|
"""
|
327
345
|
Copying API models should return an object that could be inserted into the
|
328
346
|
database again. The 'timestamp' is reset using the default factory.
|
329
347
|
"""
|
330
348
|
update = update or {}
|
331
|
-
update.setdefault("timestamp", self.
|
332
|
-
return super().
|
349
|
+
update.setdefault("timestamp", self.model_fields["timestamp"].get_default())
|
350
|
+
return super().model_copy(update=update, deep=deep)
|
351
|
+
|
352
|
+
def fresh_copy(self, **kwargs) -> Self:
|
353
|
+
"""
|
354
|
+
Return a fresh copy of the state with a new ID.
|
355
|
+
"""
|
356
|
+
return self.model_copy(
|
357
|
+
update={
|
358
|
+
"id": uuid4(),
|
359
|
+
"created": pendulum.now("utc"),
|
360
|
+
"updated": pendulum.now("utc"),
|
361
|
+
"timestamp": pendulum.now("utc"),
|
362
|
+
},
|
363
|
+
**kwargs,
|
364
|
+
)
|
333
365
|
|
334
366
|
def __repr__(self) -> str:
|
335
367
|
"""
|
@@ -338,12 +370,7 @@ class State(ObjectBaseModel, Generic[R]):
|
|
338
370
|
|
339
371
|
`MyCompletedState(message="my message", type=COMPLETED, result=...)`
|
340
372
|
"""
|
341
|
-
|
342
|
-
|
343
|
-
if isinstance(self.data, DataDocument):
|
344
|
-
result = self.data.decode()
|
345
|
-
else:
|
346
|
-
result = self.data
|
373
|
+
result = self.data
|
347
374
|
|
348
375
|
display = dict(
|
349
376
|
message=repr(self.message),
|
@@ -411,9 +438,12 @@ class FlowRunPolicy(PrefectBaseModel):
|
|
411
438
|
default=False, description="Indicates if this run is resuming from a pause."
|
412
439
|
)
|
413
440
|
|
414
|
-
@
|
415
|
-
|
416
|
-
|
441
|
+
@model_validator(mode="before")
|
442
|
+
@classmethod
|
443
|
+
def populate_deprecated_fields(cls, values: Any):
|
444
|
+
if isinstance(values, dict):
|
445
|
+
return set_run_policy_deprecated_fields(values)
|
446
|
+
return values
|
417
447
|
|
418
448
|
|
419
449
|
class FlowRun(ObjectBaseModel):
|
@@ -480,18 +510,18 @@ class FlowRun(ObjectBaseModel):
|
|
480
510
|
run_count: int = Field(
|
481
511
|
default=0, description="The number of times the flow run was executed."
|
482
512
|
)
|
483
|
-
expected_start_time: Optional[
|
513
|
+
expected_start_time: Optional[DateTime] = Field(
|
484
514
|
default=None,
|
485
515
|
description="The flow run's expected start time.",
|
486
516
|
)
|
487
|
-
next_scheduled_start_time: Optional[
|
517
|
+
next_scheduled_start_time: Optional[DateTime] = Field(
|
488
518
|
default=None,
|
489
519
|
description="The next time the flow run is scheduled to start.",
|
490
520
|
)
|
491
|
-
start_time: Optional[
|
521
|
+
start_time: Optional[DateTime] = Field(
|
492
522
|
default=None, description="The actual start time."
|
493
523
|
)
|
494
|
-
end_time: Optional[
|
524
|
+
end_time: Optional[DateTime] = Field(
|
495
525
|
default=None, description="The actual end time."
|
496
526
|
)
|
497
527
|
total_run_time: datetime.timedelta = Field(
|
@@ -530,7 +560,7 @@ class FlowRun(ObjectBaseModel):
|
|
530
560
|
)
|
531
561
|
|
532
562
|
work_pool_id: Optional[UUID] = Field(
|
533
|
-
description="The work pool with which the queue is associated."
|
563
|
+
default=None, description="The work pool with which the queue is associated."
|
534
564
|
)
|
535
565
|
work_pool_name: Optional[str] = Field(
|
536
566
|
default=None,
|
@@ -540,10 +570,11 @@ class FlowRun(ObjectBaseModel):
|
|
540
570
|
state: Optional[State] = Field(
|
541
571
|
default=None,
|
542
572
|
description="The state of the flow run.",
|
543
|
-
examples=[State(type=StateType.COMPLETED)],
|
573
|
+
examples=["State(type=StateType.COMPLETED)"],
|
544
574
|
)
|
545
575
|
job_variables: Optional[dict] = Field(
|
546
|
-
default=None,
|
576
|
+
default=None,
|
577
|
+
description="Job variables for the flow run.",
|
547
578
|
)
|
548
579
|
|
549
580
|
# These are server-side optimizations and should not be present on client models
|
@@ -565,12 +596,13 @@ class FlowRun(ObjectBaseModel):
|
|
565
596
|
"""
|
566
597
|
if isinstance(other, FlowRun):
|
567
598
|
exclude_fields = {"estimated_run_time", "estimated_start_time_delta"}
|
568
|
-
return self.
|
599
|
+
return self.model_dump(exclude=exclude_fields) == other.model_dump(
|
569
600
|
exclude=exclude_fields
|
570
601
|
)
|
571
602
|
return super().__eq__(other)
|
572
603
|
|
573
|
-
@
|
604
|
+
@field_validator("name", mode="before")
|
605
|
+
@classmethod
|
574
606
|
def set_default_name(cls, name):
|
575
607
|
return get_or_create_run_name(name)
|
576
608
|
|
@@ -603,15 +635,32 @@ class TaskRunPolicy(PrefectBaseModel):
|
|
603
635
|
default=None, description="Determines the amount a retry should jitter"
|
604
636
|
)
|
605
637
|
|
606
|
-
@
|
607
|
-
def populate_deprecated_fields(
|
608
|
-
|
638
|
+
@model_validator(mode="after")
|
639
|
+
def populate_deprecated_fields(self):
|
640
|
+
"""
|
641
|
+
If deprecated fields are provided, populate the corresponding new fields
|
642
|
+
to preserve orchestration behavior.
|
643
|
+
"""
|
644
|
+
# We have marked these fields as deprecated, so we need to filter out the
|
645
|
+
# deprecation warnings _we're_ generating here
|
646
|
+
with warnings.catch_warnings():
|
647
|
+
warnings.simplefilter("ignore", DeprecationWarning)
|
648
|
+
|
649
|
+
if not self.retries and self.max_retries != 0:
|
650
|
+
self.retries = self.max_retries
|
609
651
|
|
610
|
-
|
652
|
+
if not self.retry_delay and self.retry_delay_seconds != 0:
|
653
|
+
self.retry_delay = self.retry_delay_seconds
|
654
|
+
|
655
|
+
return self
|
656
|
+
|
657
|
+
@field_validator("retry_delay")
|
658
|
+
@classmethod
|
611
659
|
def validate_configured_retry_delays(cls, v):
|
612
660
|
return list_length_50_or_less(v)
|
613
661
|
|
614
|
-
@
|
662
|
+
@field_validator("retry_jitter_factor")
|
663
|
+
@classmethod
|
615
664
|
def validate_jitter_factor(cls, v):
|
616
665
|
return validate_not_negative(v)
|
617
666
|
|
@@ -622,9 +671,7 @@ class TaskRunInput(PrefectBaseModel):
|
|
622
671
|
could include, constants, parameters, or other task runs.
|
623
672
|
"""
|
624
673
|
|
625
|
-
|
626
|
-
class Config:
|
627
|
-
frozen = True
|
674
|
+
model_config = ConfigDict(frozen=True)
|
628
675
|
|
629
676
|
input_type: str
|
630
677
|
|
@@ -675,7 +722,7 @@ class TaskRun(ObjectBaseModel):
|
|
675
722
|
" the task run."
|
676
723
|
),
|
677
724
|
)
|
678
|
-
cache_expiration: Optional[
|
725
|
+
cache_expiration: Optional[DateTime] = Field(
|
679
726
|
default=None, description="Specifies when the cached state should expire."
|
680
727
|
)
|
681
728
|
task_version: Optional[str] = Field(
|
@@ -716,21 +763,21 @@ class TaskRun(ObjectBaseModel):
|
|
716
763
|
" associated with."
|
717
764
|
),
|
718
765
|
)
|
719
|
-
expected_start_time: Optional[
|
766
|
+
expected_start_time: Optional[DateTime] = Field(
|
720
767
|
default=None,
|
721
768
|
description="The task run's expected start time.",
|
722
769
|
)
|
723
770
|
|
724
771
|
# the next scheduled start time will be populated
|
725
772
|
# whenever the run is in a scheduled state
|
726
|
-
next_scheduled_start_time: Optional[
|
773
|
+
next_scheduled_start_time: Optional[DateTime] = Field(
|
727
774
|
default=None,
|
728
775
|
description="The next time the task run is scheduled to start.",
|
729
776
|
)
|
730
|
-
start_time: Optional[
|
777
|
+
start_time: Optional[DateTime] = Field(
|
731
778
|
default=None, description="The actual start time."
|
732
779
|
)
|
733
|
-
end_time: Optional[
|
780
|
+
end_time: Optional[DateTime] = Field(
|
734
781
|
default=None, description="The actual end time."
|
735
782
|
)
|
736
783
|
total_run_time: datetime.timedelta = Field(
|
@@ -751,11 +798,12 @@ class TaskRun(ObjectBaseModel):
|
|
751
798
|
|
752
799
|
state: Optional[State] = Field(
|
753
800
|
default=None,
|
754
|
-
description="The state of the
|
755
|
-
examples=[State(type=StateType.COMPLETED)],
|
801
|
+
description="The state of the task run.",
|
802
|
+
examples=["State(type=StateType.COMPLETED)"],
|
756
803
|
)
|
757
804
|
|
758
|
-
@
|
805
|
+
@field_validator("name", mode="before")
|
806
|
+
@classmethod
|
759
807
|
def set_default_name(cls, name):
|
760
808
|
return get_or_create_run_name(name)
|
761
809
|
|
@@ -774,9 +822,7 @@ class Workspace(PrefectBaseModel):
|
|
774
822
|
workspace_name: str = Field(..., description="The workspace name.")
|
775
823
|
workspace_description: str = Field(..., description="Description of the workspace.")
|
776
824
|
workspace_handle: str = Field(..., description="The workspace's unique handle.")
|
777
|
-
|
778
|
-
class Config:
|
779
|
-
extra = "ignore"
|
825
|
+
model_config = ConfigDict(extra="ignore")
|
780
826
|
|
781
827
|
@property
|
782
828
|
def handle(self) -> str:
|
@@ -809,10 +855,39 @@ class Workspace(PrefectBaseModel):
|
|
809
855
|
return hash(self.handle)
|
810
856
|
|
811
857
|
|
858
|
+
class IPAllowlistEntry(PrefectBaseModel):
|
859
|
+
ip_network: IPvAnyNetwork
|
860
|
+
enabled: bool
|
861
|
+
description: Optional[str] = Field(
|
862
|
+
default=None, description="A description of the IP entry."
|
863
|
+
)
|
864
|
+
last_seen: Optional[str] = Field(
|
865
|
+
default=None,
|
866
|
+
description="The last time this IP was seen accessing Prefect Cloud.",
|
867
|
+
)
|
868
|
+
|
869
|
+
|
870
|
+
class IPAllowlist(PrefectBaseModel):
|
871
|
+
"""
|
872
|
+
A Prefect Cloud IP allowlist.
|
873
|
+
|
874
|
+
Expected payload for an IP allowlist from the Prefect Cloud API.
|
875
|
+
"""
|
876
|
+
|
877
|
+
entries: List[IPAllowlistEntry]
|
878
|
+
|
879
|
+
|
880
|
+
class IPAllowlistMyAccessResponse(PrefectBaseModel):
|
881
|
+
"""Expected payload for an IP allowlist access response from the Prefect Cloud API."""
|
882
|
+
|
883
|
+
allowed: bool
|
884
|
+
detail: str
|
885
|
+
|
886
|
+
|
812
887
|
class BlockType(ObjectBaseModel):
|
813
888
|
"""An ORM representation of a block type"""
|
814
889
|
|
815
|
-
name:
|
890
|
+
name: Name = Field(default=..., description="A block type's name")
|
816
891
|
slug: str = Field(default=..., description="A block type's slug")
|
817
892
|
logo_url: Optional[HttpUrl] = Field(
|
818
893
|
default=None, description="Web URL for the block type's logo"
|
@@ -832,10 +907,6 @@ class BlockType(ObjectBaseModel):
|
|
832
907
|
default=False, description="Protected block types cannot be modified via API."
|
833
908
|
)
|
834
909
|
|
835
|
-
@validator("name", check_fields=False)
|
836
|
-
def validate_name_characters(cls, v):
|
837
|
-
return raise_on_name_with_banned_characters(v)
|
838
|
-
|
839
910
|
|
840
911
|
class BlockSchema(ObjectBaseModel):
|
841
912
|
"""A representation of a block schema."""
|
@@ -861,7 +932,7 @@ class BlockSchema(ObjectBaseModel):
|
|
861
932
|
class BlockDocument(ObjectBaseModel):
|
862
933
|
"""An ORM representation of a block document."""
|
863
934
|
|
864
|
-
name: Optional[
|
935
|
+
name: Optional[Name] = Field(
|
865
936
|
default=None,
|
866
937
|
description=(
|
867
938
|
"The block document's name. Not required for anonymous block documents."
|
@@ -890,21 +961,29 @@ class BlockDocument(ObjectBaseModel):
|
|
890
961
|
),
|
891
962
|
)
|
892
963
|
|
893
|
-
|
894
|
-
def validate_name_characters(cls, v):
|
895
|
-
# the BlockDocumentCreate subclass allows name=None
|
896
|
-
# and will inherit this validator
|
897
|
-
return raise_on_name_with_banned_characters(v)
|
964
|
+
_validate_name_format = field_validator("name")(validate_block_document_name)
|
898
965
|
|
899
|
-
@
|
966
|
+
@model_validator(mode="before")
|
967
|
+
@classmethod
|
900
968
|
def validate_name_is_present_if_not_anonymous(cls, values):
|
901
969
|
return validate_name_present_on_nonanonymous_blocks(values)
|
902
970
|
|
971
|
+
@model_serializer(mode="wrap")
|
972
|
+
def serialize_data(
|
973
|
+
self, handler: ModelWrapValidatorHandler, info: SerializationInfo
|
974
|
+
):
|
975
|
+
self.data = visit_collection(
|
976
|
+
self.data,
|
977
|
+
visit_fn=partial(handle_secret_render, context=info.context or {}),
|
978
|
+
return_data=True,
|
979
|
+
)
|
980
|
+
return handler(self)
|
981
|
+
|
903
982
|
|
904
983
|
class Flow(ObjectBaseModel):
|
905
984
|
"""An ORM representation of flow data."""
|
906
985
|
|
907
|
-
name:
|
986
|
+
name: Name = Field(
|
908
987
|
default=..., description="The name of the flow", examples=["my-flow"]
|
909
988
|
)
|
910
989
|
tags: List[str] = Field(
|
@@ -913,23 +992,6 @@ class Flow(ObjectBaseModel):
|
|
913
992
|
examples=[["tag-1", "tag-2"]],
|
914
993
|
)
|
915
994
|
|
916
|
-
@validator("name", check_fields=False)
|
917
|
-
def validate_name_characters(cls, v):
|
918
|
-
return raise_on_name_with_banned_characters(v)
|
919
|
-
|
920
|
-
|
921
|
-
@deprecated_class(
|
922
|
-
start_date="Jun 2024",
|
923
|
-
help="Will be removed in Prefect 3 in favor of prefect.client.schemas.actions.DeploymentScheduleCreate",
|
924
|
-
)
|
925
|
-
class MinimalDeploymentSchedule(PrefectBaseModel):
|
926
|
-
schedule: SCHEDULE_TYPES = Field(
|
927
|
-
default=..., description="The schedule for the deployment."
|
928
|
-
)
|
929
|
-
active: bool = Field(
|
930
|
-
default=True, description="Whether or not the schedule is active."
|
931
|
-
)
|
932
|
-
|
933
995
|
|
934
996
|
class DeploymentSchedule(ObjectBaseModel):
|
935
997
|
deployment_id: Optional[UUID] = Field(
|
@@ -956,10 +1018,10 @@ class DeploymentSchedule(ObjectBaseModel):
|
|
956
1018
|
)
|
957
1019
|
|
958
1020
|
|
959
|
-
class Deployment(
|
1021
|
+
class Deployment(ObjectBaseModel):
|
960
1022
|
"""An ORM representation of deployment data."""
|
961
1023
|
|
962
|
-
name:
|
1024
|
+
name: Name = Field(default=..., description="The name of the deployment.")
|
963
1025
|
version: Optional[str] = Field(
|
964
1026
|
default=None, description="An optional version for the deployment."
|
965
1027
|
)
|
@@ -969,15 +1031,12 @@ class Deployment(DeprecatedInfraOverridesField, ObjectBaseModel):
|
|
969
1031
|
flow_id: UUID = Field(
|
970
1032
|
default=..., description="The flow id associated with the deployment."
|
971
1033
|
)
|
972
|
-
schedule: Optional[SCHEDULE_TYPES] = Field(
|
973
|
-
default=None, description="A schedule for the deployment."
|
974
|
-
)
|
975
|
-
is_schedule_active: bool = Field(
|
976
|
-
default=True, description="Whether or not the deployment schedule is active."
|
977
|
-
)
|
978
1034
|
paused: bool = Field(
|
979
1035
|
default=False, description="Whether or not the deployment is paused."
|
980
1036
|
)
|
1037
|
+
concurrency_limit: Optional[int] = Field(
|
1038
|
+
default=None, description="The concurrency limit for the deployment."
|
1039
|
+
)
|
981
1040
|
schedules: List[DeploymentSchedule] = Field(
|
982
1041
|
default_factory=list, description="A list of schedules for the deployment."
|
983
1042
|
)
|
@@ -1005,7 +1064,7 @@ class Deployment(DeprecatedInfraOverridesField, ObjectBaseModel):
|
|
1005
1064
|
" be scheduled."
|
1006
1065
|
),
|
1007
1066
|
)
|
1008
|
-
last_polled: Optional[
|
1067
|
+
last_polled: Optional[DateTime] = Field(
|
1009
1068
|
default=None,
|
1010
1069
|
description="The last time the deployment was polled for status updates.",
|
1011
1070
|
)
|
@@ -1026,12 +1085,6 @@ class Deployment(DeprecatedInfraOverridesField, ObjectBaseModel):
|
|
1026
1085
|
"The path to the entrypoint for the workflow, relative to the `path`."
|
1027
1086
|
),
|
1028
1087
|
)
|
1029
|
-
manifest_path: Optional[str] = Field(
|
1030
|
-
default=None,
|
1031
|
-
description=(
|
1032
|
-
"The path to the flow's manifest file, relative to the chosen storage."
|
1033
|
-
),
|
1034
|
-
)
|
1035
1088
|
storage_document_id: Optional[UUID] = Field(
|
1036
1089
|
default=None,
|
1037
1090
|
description="The block document defining storage used for this flow.",
|
@@ -1048,23 +1101,19 @@ class Deployment(DeprecatedInfraOverridesField, ObjectBaseModel):
|
|
1048
1101
|
default=None,
|
1049
1102
|
description="Optional information about the updater of this deployment.",
|
1050
1103
|
)
|
1051
|
-
work_queue_id: UUID = Field(
|
1104
|
+
work_queue_id: Optional[UUID] = Field(
|
1052
1105
|
default=None,
|
1053
1106
|
description=(
|
1054
1107
|
"The id of the work pool queue to which this deployment is assigned."
|
1055
1108
|
),
|
1056
1109
|
)
|
1057
1110
|
enforce_parameter_schema: bool = Field(
|
1058
|
-
default=
|
1111
|
+
default=True,
|
1059
1112
|
description=(
|
1060
1113
|
"Whether or not the deployment should enforce the parameter schema."
|
1061
1114
|
),
|
1062
1115
|
)
|
1063
1116
|
|
1064
|
-
@validator("name", check_fields=False)
|
1065
|
-
def validate_name_characters(cls, v):
|
1066
|
-
return raise_on_name_with_banned_characters(v)
|
1067
|
-
|
1068
1117
|
|
1069
1118
|
class ConcurrencyLimit(ObjectBaseModel):
|
1070
1119
|
"""An ORM representation of a concurrency limit."""
|
@@ -1139,9 +1188,12 @@ class BlockDocumentReference(ObjectBaseModel):
|
|
1139
1188
|
default=..., description="The name that the reference is nested under"
|
1140
1189
|
)
|
1141
1190
|
|
1142
|
-
@
|
1191
|
+
@model_validator(mode="before")
|
1192
|
+
@classmethod
|
1143
1193
|
def validate_parent_and_ref_are_different(cls, values):
|
1144
|
-
|
1194
|
+
if isinstance(values, dict):
|
1195
|
+
return validate_parent_and_ref_diff(values)
|
1196
|
+
return values
|
1145
1197
|
|
1146
1198
|
|
1147
1199
|
class Configuration(ObjectBaseModel):
|
@@ -1183,7 +1235,7 @@ class Log(ObjectBaseModel):
|
|
1183
1235
|
name: str = Field(default=..., description="The logger name.")
|
1184
1236
|
level: int = Field(default=..., description="The log level.")
|
1185
1237
|
message: str = Field(default=..., description="The log message.")
|
1186
|
-
timestamp:
|
1238
|
+
timestamp: DateTime = Field(default=..., description="The log timestamp.")
|
1187
1239
|
flow_run_id: Optional[UUID] = Field(
|
1188
1240
|
default=None, description="The flow run ID associated with the log."
|
1189
1241
|
)
|
@@ -1208,7 +1260,7 @@ class QueueFilter(PrefectBaseModel):
|
|
1208
1260
|
class WorkQueue(ObjectBaseModel):
|
1209
1261
|
"""An ORM representation of a work queue"""
|
1210
1262
|
|
1211
|
-
name:
|
1263
|
+
name: Name = Field(default=..., description="The name of the work queue.")
|
1212
1264
|
description: Optional[str] = Field(
|
1213
1265
|
default="", description="An optional description for the work queue."
|
1214
1266
|
)
|
@@ -1234,17 +1286,13 @@ class WorkQueue(ObjectBaseModel):
|
|
1234
1286
|
description="DEPRECATED: Filter criteria for the work queue.",
|
1235
1287
|
deprecated=True,
|
1236
1288
|
)
|
1237
|
-
last_polled: Optional[
|
1289
|
+
last_polled: Optional[DateTime] = Field(
|
1238
1290
|
default=None, description="The last time an agent polled this queue for work."
|
1239
1291
|
)
|
1240
1292
|
status: Optional[WorkQueueStatus] = Field(
|
1241
1293
|
default=None, description="The queue status."
|
1242
1294
|
)
|
1243
1295
|
|
1244
|
-
@validator("name", check_fields=False)
|
1245
|
-
def validate_name_characters(cls, v):
|
1246
|
-
return raise_on_name_with_banned_characters(v)
|
1247
|
-
|
1248
1296
|
|
1249
1297
|
class WorkQueueHealthPolicy(PrefectBaseModel):
|
1250
1298
|
maximum_late_runs: Optional[int] = Field(
|
@@ -1263,7 +1311,7 @@ class WorkQueueHealthPolicy(PrefectBaseModel):
|
|
1263
1311
|
)
|
1264
1312
|
|
1265
1313
|
def evaluate_health_status(
|
1266
|
-
self, late_runs_count: int, last_polled: Optional[
|
1314
|
+
self, late_runs_count: int, last_polled: Optional[DateTime] = None
|
1267
1315
|
) -> bool:
|
1268
1316
|
"""
|
1269
1317
|
Given empirical information about the state of the work queue, evaluate its health status.
|
@@ -1298,7 +1346,7 @@ class WorkQueueStatusDetail(PrefectBaseModel):
|
|
1298
1346
|
late_runs_count: int = Field(
|
1299
1347
|
default=0, description="The number of late flow runs in the work queue."
|
1300
1348
|
)
|
1301
|
-
last_polled: Optional[
|
1349
|
+
last_polled: Optional[DateTime] = Field(
|
1302
1350
|
default=None, description="The last time an agent polled this queue for work."
|
1303
1351
|
)
|
1304
1352
|
health_check_policy: WorkQueueHealthPolicy = Field(
|
@@ -1338,7 +1386,8 @@ class FlowRunNotificationPolicy(ObjectBaseModel):
|
|
1338
1386
|
],
|
1339
1387
|
)
|
1340
1388
|
|
1341
|
-
@
|
1389
|
+
@field_validator("message_template")
|
1390
|
+
@classmethod
|
1342
1391
|
def validate_message_template_variables(cls, v):
|
1343
1392
|
return validate_message_template_variables(v)
|
1344
1393
|
|
@@ -1356,7 +1405,7 @@ class Agent(ObjectBaseModel):
|
|
1356
1405
|
work_queue_id: UUID = Field(
|
1357
1406
|
default=..., description="The work queue with which the agent is associated."
|
1358
1407
|
)
|
1359
|
-
last_activity_time: Optional[
|
1408
|
+
last_activity_time: Optional[DateTime] = Field(
|
1360
1409
|
default=None, description="The last time this agent polled for work."
|
1361
1410
|
)
|
1362
1411
|
|
@@ -1364,7 +1413,7 @@ class Agent(ObjectBaseModel):
|
|
1364
1413
|
class WorkPool(ObjectBaseModel):
|
1365
1414
|
"""An ORM representation of a work pool"""
|
1366
1415
|
|
1367
|
-
name:
|
1416
|
+
name: Name = Field(
|
1368
1417
|
description="The name of the work pool.",
|
1369
1418
|
)
|
1370
1419
|
description: Optional[str] = Field(
|
@@ -1399,11 +1448,8 @@ class WorkPool(ObjectBaseModel):
|
|
1399
1448
|
def is_managed_pool(self) -> bool:
|
1400
1449
|
return self.type.endswith(":managed")
|
1401
1450
|
|
1402
|
-
@
|
1403
|
-
|
1404
|
-
return raise_on_name_with_banned_characters(v)
|
1405
|
-
|
1406
|
-
@validator("default_queue_id", always=True)
|
1451
|
+
@field_validator("default_queue_id")
|
1452
|
+
@classmethod
|
1407
1453
|
def helpful_error_for_missing_default_queue_id(cls, v):
|
1408
1454
|
return validate_default_queue_id_not_none(v)
|
1409
1455
|
|
@@ -1430,8 +1476,8 @@ class Worker(ObjectBaseModel):
|
|
1430
1476
|
)
|
1431
1477
|
|
1432
1478
|
|
1433
|
-
Flow.
|
1434
|
-
FlowRun.
|
1479
|
+
Flow.model_rebuild()
|
1480
|
+
# FlowRun.model_rebuild()
|
1435
1481
|
|
1436
1482
|
|
1437
1483
|
class Artifact(ObjectBaseModel):
|
@@ -1470,7 +1516,8 @@ class Artifact(ObjectBaseModel):
|
|
1470
1516
|
default=None, description="The task run associated with the artifact."
|
1471
1517
|
)
|
1472
1518
|
|
1473
|
-
@
|
1519
|
+
@field_validator("metadata_")
|
1520
|
+
@classmethod
|
1474
1521
|
def validate_metadata_length(cls, v):
|
1475
1522
|
return validate_max_metadata_length(v)
|
1476
1523
|
|
@@ -1519,11 +1566,10 @@ class Variable(ObjectBaseModel):
|
|
1519
1566
|
examples=["my_variable"],
|
1520
1567
|
max_length=MAX_VARIABLE_NAME_LENGTH,
|
1521
1568
|
)
|
1522
|
-
value:
|
1569
|
+
value: StrictVariableValue = Field(
|
1523
1570
|
default=...,
|
1524
1571
|
description="The value of the variable",
|
1525
1572
|
examples=["my_value"],
|
1526
|
-
max_length=MAX_VARIABLE_VALUE_LENGTH,
|
1527
1573
|
)
|
1528
1574
|
tags: List[str] = Field(
|
1529
1575
|
default_factory=list,
|
@@ -1536,7 +1582,7 @@ class FlowRunInput(ObjectBaseModel):
|
|
1536
1582
|
flow_run_id: UUID = Field(description="The flow run ID associated with the input.")
|
1537
1583
|
key: str = Field(description="The key of the input.")
|
1538
1584
|
value: str = Field(description="The value of the input.")
|
1539
|
-
sender: Optional[str] = Field(description="The sender of the input.")
|
1585
|
+
sender: Optional[str] = Field(default=None, description="The sender of the input.")
|
1540
1586
|
|
1541
1587
|
@property
|
1542
1588
|
def decoded_value(self) -> Any:
|
@@ -1548,7 +1594,8 @@ class FlowRunInput(ObjectBaseModel):
|
|
1548
1594
|
"""
|
1549
1595
|
return orjson.loads(self.value)
|
1550
1596
|
|
1551
|
-
@
|
1597
|
+
@field_validator("key", check_fields=False)
|
1598
|
+
@classmethod
|
1552
1599
|
def validate_name_characters(cls, v):
|
1553
1600
|
raise_on_name_alphanumeric_dashes_only(v)
|
1554
1601
|
return v
|
@@ -1589,6 +1636,9 @@ class CsrfToken(ObjectBaseModel):
|
|
1589
1636
|
client: str = Field(
|
1590
1637
|
default=..., description="The client id associated with the CSRF token"
|
1591
1638
|
)
|
1592
|
-
expiration:
|
1639
|
+
expiration: datetime.datetime = Field(
|
1593
1640
|
default=..., description="The expiration time of the CSRF token"
|
1594
1641
|
)
|
1642
|
+
|
1643
|
+
|
1644
|
+
__getattr__ = getattr_migration(__name__)
|