prefect-client 2.16.9__py3-none-any.whl → 2.17.1__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 +0 -18
- prefect/_internal/compatibility/deprecated.py +108 -5
- prefect/_internal/pydantic/__init__.py +4 -0
- prefect/_internal/pydantic/_base_model.py +36 -4
- prefect/_internal/pydantic/_compat.py +33 -2
- prefect/_internal/pydantic/_flags.py +3 -0
- prefect/_internal/pydantic/utilities/config_dict.py +72 -0
- prefect/_internal/pydantic/utilities/field_validator.py +135 -0
- prefect/_internal/pydantic/utilities/model_fields_set.py +29 -0
- prefect/_internal/pydantic/utilities/model_validator.py +79 -0
- prefect/agent.py +1 -1
- prefect/blocks/notifications.py +18 -18
- prefect/blocks/webhook.py +1 -1
- prefect/client/base.py +7 -0
- prefect/client/orchestration.py +44 -4
- prefect/client/schemas/actions.py +27 -20
- prefect/client/schemas/filters.py +28 -28
- prefect/client/schemas/objects.py +31 -21
- prefect/client/schemas/responses.py +17 -11
- prefect/client/schemas/schedules.py +6 -8
- prefect/context.py +2 -1
- prefect/deployments/base.py +2 -10
- prefect/deployments/deployments.py +34 -9
- prefect/deployments/runner.py +2 -2
- prefect/engine.py +32 -596
- prefect/events/clients.py +45 -13
- prefect/events/filters.py +19 -2
- prefect/events/utilities.py +12 -4
- prefect/events/worker.py +26 -8
- prefect/exceptions.py +3 -8
- prefect/filesystems.py +7 -7
- prefect/flows.py +4 -3
- prefect/manifests.py +1 -8
- prefect/profiles.toml +1 -1
- prefect/pydantic/__init__.py +27 -1
- prefect/pydantic/main.py +26 -2
- prefect/settings.py +33 -10
- prefect/task_server.py +2 -2
- prefect/utilities/dispatch.py +1 -0
- prefect/utilities/engine.py +629 -0
- prefect/utilities/pydantic.py +1 -1
- prefect/utilities/visualization.py +1 -1
- prefect/variables.py +88 -12
- prefect/workers/base.py +1 -1
- prefect/workers/block.py +1 -1
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/METADATA +3 -3
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/RECORD +50 -45
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/LICENSE +0 -0
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/WHEEL +0 -0
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/top_level.txt +0 -0
prefect/events/clients.py
CHANGED
@@ -17,6 +17,7 @@ from uuid import UUID
|
|
17
17
|
import orjson
|
18
18
|
import pendulum
|
19
19
|
from cachetools import TTLCache
|
20
|
+
from typing_extensions import Self
|
20
21
|
from websockets.client import WebSocketClientProtocol, connect
|
21
22
|
from websockets.exceptions import (
|
22
23
|
ConnectionClosed,
|
@@ -118,8 +119,8 @@ def _get_api_url_and_key(
|
|
118
119
|
return api_url, api_key
|
119
120
|
|
120
121
|
|
121
|
-
class
|
122
|
-
"""A Prefect Events client that streams
|
122
|
+
class PrefectEventsClient(EventsClient):
|
123
|
+
"""A Prefect Events client that streams events to a Prefect server"""
|
123
124
|
|
124
125
|
_websocket: Optional[WebSocketClientProtocol]
|
125
126
|
_unconfirmed_events: List[Event]
|
@@ -127,37 +128,36 @@ class PrefectCloudEventsClient(EventsClient):
|
|
127
128
|
def __init__(
|
128
129
|
self,
|
129
130
|
api_url: str = None,
|
130
|
-
api_key: str = None,
|
131
131
|
reconnection_attempts: int = 10,
|
132
132
|
checkpoint_every: int = 20,
|
133
133
|
):
|
134
134
|
"""
|
135
135
|
Args:
|
136
|
-
api_url: The base URL for a Prefect
|
137
|
-
api_key: The API of an actor with the manage_events scope
|
136
|
+
api_url: The base URL for a Prefect server
|
138
137
|
reconnection_attempts: When the client is disconnected, how many times
|
139
138
|
the client should attempt to reconnect
|
140
139
|
checkpoint_every: How often the client should sync with the server to
|
141
140
|
confirm receipt of all previously sent events
|
142
141
|
"""
|
143
|
-
api_url
|
142
|
+
api_url = api_url or PREFECT_API_URL.value()
|
143
|
+
if not api_url:
|
144
|
+
raise ValueError(
|
145
|
+
"api_url must be provided or set in the Prefect configuration"
|
146
|
+
)
|
144
147
|
|
145
|
-
|
148
|
+
self._events_socket_url = (
|
146
149
|
api_url.replace("https://", "wss://")
|
147
150
|
.replace("http://", "ws://")
|
148
151
|
.rstrip("/")
|
152
|
+
+ "/events/in"
|
149
153
|
)
|
150
|
-
|
151
|
-
self._connect = connect(
|
152
|
-
socket_url + "/events/in",
|
153
|
-
extra_headers={"Authorization": f"bearer {api_key}"},
|
154
|
-
)
|
154
|
+
self._connect = connect(self._events_socket_url)
|
155
155
|
self._websocket = None
|
156
156
|
self._reconnection_attempts = reconnection_attempts
|
157
157
|
self._unconfirmed_events = []
|
158
158
|
self._checkpoint_every = checkpoint_every
|
159
159
|
|
160
|
-
async def __aenter__(self) ->
|
160
|
+
async def __aenter__(self) -> Self:
|
161
161
|
# Don't handle any errors in the initial connection, because these are most
|
162
162
|
# likely a permission or configuration issue that should propagate
|
163
163
|
await super().__aenter__()
|
@@ -238,6 +238,38 @@ class PrefectCloudEventsClient(EventsClient):
|
|
238
238
|
await asyncio.sleep(1)
|
239
239
|
|
240
240
|
|
241
|
+
class PrefectCloudEventsClient(PrefectEventsClient):
|
242
|
+
"""A Prefect Events client that streams events to a Prefect Cloud Workspace"""
|
243
|
+
|
244
|
+
def __init__(
|
245
|
+
self,
|
246
|
+
api_url: str = None,
|
247
|
+
api_key: str = None,
|
248
|
+
reconnection_attempts: int = 10,
|
249
|
+
checkpoint_every: int = 20,
|
250
|
+
):
|
251
|
+
"""
|
252
|
+
Args:
|
253
|
+
api_url: The base URL for a Prefect Cloud workspace
|
254
|
+
api_key: The API of an actor with the manage_events scope
|
255
|
+
reconnection_attempts: When the client is disconnected, how many times
|
256
|
+
the client should attempt to reconnect
|
257
|
+
checkpoint_every: How often the client should sync with the server to
|
258
|
+
confirm receipt of all previously sent events
|
259
|
+
"""
|
260
|
+
api_url, api_key = _get_api_url_and_key(api_url, api_key)
|
261
|
+
super().__init__(
|
262
|
+
api_url=api_url,
|
263
|
+
reconnection_attempts=reconnection_attempts,
|
264
|
+
checkpoint_every=checkpoint_every,
|
265
|
+
)
|
266
|
+
|
267
|
+
self._connect = connect(
|
268
|
+
self._events_socket_url,
|
269
|
+
extra_headers={"Authorization": f"bearer {api_key}"},
|
270
|
+
)
|
271
|
+
|
272
|
+
|
241
273
|
SEEN_EVENTS_SIZE = 500_000
|
242
274
|
SEEN_EVENTS_TTL = 120
|
243
275
|
|
prefect/events/filters.py
CHANGED
@@ -6,18 +6,21 @@ import pendulum
|
|
6
6
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
7
7
|
from prefect._internal.schemas.bases import PrefectBaseModel
|
8
8
|
from prefect._internal.schemas.fields import DateTimeTZ
|
9
|
+
from prefect.utilities.collections import AutoEnum
|
9
10
|
|
10
11
|
from .schemas.events import Event, Resource, ResourceSpecification
|
11
12
|
|
12
13
|
if HAS_PYDANTIC_V2:
|
13
|
-
from pydantic.v1 import Field
|
14
|
+
from pydantic.v1 import Field, PrivateAttr
|
14
15
|
else:
|
15
|
-
from pydantic import Field
|
16
|
+
from pydantic import Field, PrivateAttr
|
16
17
|
|
17
18
|
|
18
19
|
class EventDataFilter(PrefectBaseModel, extra="forbid"):
|
19
20
|
"""A base class for filtering event data."""
|
20
21
|
|
22
|
+
_top_level_filter: "EventFilter | None" = PrivateAttr(None)
|
23
|
+
|
21
24
|
def get_filters(self) -> List["EventDataFilter"]:
|
22
25
|
return [
|
23
26
|
filter
|
@@ -103,6 +106,10 @@ class EventResourceFilter(EventDataFilter):
|
|
103
106
|
labels: Optional[ResourceSpecification] = Field(
|
104
107
|
None, description="Only include events for resources with these labels"
|
105
108
|
)
|
109
|
+
distinct: bool = Field(
|
110
|
+
False,
|
111
|
+
description="Only include events for distinct resources",
|
112
|
+
)
|
106
113
|
|
107
114
|
def includes(self, event: Event) -> bool:
|
108
115
|
if self.id:
|
@@ -189,6 +196,11 @@ class EventIDFilter(EventDataFilter):
|
|
189
196
|
return True
|
190
197
|
|
191
198
|
|
199
|
+
class EventOrder(AutoEnum):
|
200
|
+
ASC = "ASC"
|
201
|
+
DESC = "DESC"
|
202
|
+
|
203
|
+
|
192
204
|
class EventFilter(EventDataFilter):
|
193
205
|
occurred: EventOccurredFilter = Field(
|
194
206
|
default_factory=EventOccurredFilter,
|
@@ -211,3 +223,8 @@ class EventFilter(EventDataFilter):
|
|
211
223
|
default_factory=EventIDFilter,
|
212
224
|
description="Filter criteria for the events' ID",
|
213
225
|
)
|
226
|
+
|
227
|
+
order: EventOrder = Field(
|
228
|
+
EventOrder.DESC,
|
229
|
+
description="The order to return filtered events",
|
230
|
+
)
|
prefect/events/utilities.py
CHANGED
@@ -6,9 +6,13 @@ import pendulum
|
|
6
6
|
|
7
7
|
from prefect._internal.schemas.fields import DateTimeTZ
|
8
8
|
|
9
|
-
from .clients import
|
9
|
+
from .clients import (
|
10
|
+
AssertingEventsClient,
|
11
|
+
PrefectCloudEventsClient,
|
12
|
+
PrefectEventsClient,
|
13
|
+
)
|
10
14
|
from .schemas.events import Event, RelatedResource
|
11
|
-
from .worker import EventsWorker,
|
15
|
+
from .worker import EventsWorker, should_emit_events
|
12
16
|
|
13
17
|
TIGHT_TIMING = timedelta(minutes=5)
|
14
18
|
|
@@ -42,10 +46,14 @@ def emit_event(
|
|
42
46
|
The event that was emitted if worker is using a client that emit
|
43
47
|
events, otherwise None
|
44
48
|
"""
|
45
|
-
if not
|
49
|
+
if not should_emit_events():
|
46
50
|
return None
|
47
51
|
|
48
|
-
operational_clients = [
|
52
|
+
operational_clients = [
|
53
|
+
AssertingEventsClient,
|
54
|
+
PrefectCloudEventsClient,
|
55
|
+
PrefectEventsClient,
|
56
|
+
]
|
49
57
|
worker_instance = EventsWorker.instance()
|
50
58
|
|
51
59
|
if worker_instance.client_type not in operational_clients:
|
prefect/events/worker.py
CHANGED
@@ -4,25 +4,41 @@ from typing import Any, Optional, Tuple, Type
|
|
4
4
|
|
5
5
|
from typing_extensions import Self
|
6
6
|
|
7
|
-
from prefect._internal.compatibility.experimental import experiment_enabled
|
8
7
|
from prefect._internal.concurrency.services import QueueService
|
9
|
-
from prefect.settings import
|
8
|
+
from prefect.settings import (
|
9
|
+
PREFECT_API_KEY,
|
10
|
+
PREFECT_API_URL,
|
11
|
+
PREFECT_CLOUD_API_URL,
|
12
|
+
PREFECT_EXPERIMENTAL_EVENTS,
|
13
|
+
)
|
10
14
|
from prefect.utilities.context import temporary_context
|
11
15
|
|
12
|
-
from .clients import
|
16
|
+
from .clients import (
|
17
|
+
EventsClient,
|
18
|
+
NullEventsClient,
|
19
|
+
PrefectCloudEventsClient,
|
20
|
+
PrefectEventsClient,
|
21
|
+
)
|
13
22
|
from .related import related_resources_from_run_context
|
14
23
|
from .schemas.events import Event
|
15
24
|
|
16
25
|
|
26
|
+
def should_emit_events() -> bool:
|
27
|
+
return emit_events_to_cloud() or should_emit_events_to_running_server()
|
28
|
+
|
29
|
+
|
17
30
|
def emit_events_to_cloud() -> bool:
|
18
|
-
|
19
|
-
return (
|
20
|
-
|
21
|
-
and api
|
22
|
-
and api.startswith(PREFECT_CLOUD_API_URL.value())
|
31
|
+
api_url = PREFECT_API_URL.value()
|
32
|
+
return isinstance(api_url, str) and api_url.startswith(
|
33
|
+
PREFECT_CLOUD_API_URL.value()
|
23
34
|
)
|
24
35
|
|
25
36
|
|
37
|
+
def should_emit_events_to_running_server() -> bool:
|
38
|
+
api_url = PREFECT_API_URL.value()
|
39
|
+
return isinstance(api_url, str) and PREFECT_EXPERIMENTAL_EVENTS
|
40
|
+
|
41
|
+
|
26
42
|
class EventsWorker(QueueService[Event]):
|
27
43
|
def __init__(
|
28
44
|
self, client_type: Type[EventsClient], client_options: Tuple[Tuple[str, Any]]
|
@@ -67,6 +83,8 @@ class EventsWorker(QueueService[Event]):
|
|
67
83
|
"api_url": PREFECT_API_URL.value(),
|
68
84
|
"api_key": PREFECT_API_KEY.value(),
|
69
85
|
}
|
86
|
+
elif should_emit_events_to_running_server():
|
87
|
+
client_type = PrefectEventsClient
|
70
88
|
|
71
89
|
else:
|
72
90
|
client_type = NullEventsClient
|
prefect/exceptions.py
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
"""
|
2
2
|
Prefect-specific exceptions.
|
3
3
|
"""
|
4
|
+
|
4
5
|
import inspect
|
5
6
|
import traceback
|
6
7
|
from types import ModuleType, TracebackType
|
7
8
|
from typing import Callable, Dict, Iterable, List, Optional, Type
|
8
9
|
|
9
|
-
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
10
|
-
|
11
|
-
if HAS_PYDANTIC_V2:
|
12
|
-
import pydantic.v1 as pydantic
|
13
|
-
else:
|
14
|
-
import pydantic
|
15
|
-
|
16
10
|
from httpx._exceptions import HTTPStatusError
|
11
|
+
from pydantic import ValidationError
|
17
12
|
from rich.traceback import Traceback
|
18
13
|
from typing_extensions import Self
|
19
14
|
|
@@ -182,7 +177,7 @@ class ParameterTypeError(PrefectException):
|
|
182
177
|
super().__init__(msg)
|
183
178
|
|
184
179
|
@classmethod
|
185
|
-
def from_validation_error(cls, exc:
|
180
|
+
def from_validation_error(cls, exc: ValidationError) -> Self:
|
186
181
|
bad_params = [f'{err["loc"][0]}: {err["msg"]}' for err in exc.errors()]
|
187
182
|
msg = "Flow run received invalid parameters:\n - " + "\n - ".join(bad_params)
|
188
183
|
return cls(msg)
|
prefect/filesystems.py
CHANGED
@@ -270,7 +270,7 @@ class RemoteFileSystem(WritableFileSystem, WritableDeploymentStorage):
|
|
270
270
|
basepath: str = Field(
|
271
271
|
default=...,
|
272
272
|
description="Default path for this block to write to.",
|
273
|
-
|
273
|
+
examples=["s3://my-bucket/my-folder/"],
|
274
274
|
)
|
275
275
|
settings: Dict[str, Any] = Field(
|
276
276
|
default_factory=dict,
|
@@ -451,19 +451,19 @@ class S3(WritableFileSystem, WritableDeploymentStorage):
|
|
451
451
|
bucket_path: str = Field(
|
452
452
|
default=...,
|
453
453
|
description="An S3 bucket path.",
|
454
|
-
|
454
|
+
examples=["my-bucket/a-directory-within"],
|
455
455
|
)
|
456
456
|
aws_access_key_id: Optional[SecretStr] = Field(
|
457
457
|
default=None,
|
458
458
|
title="AWS Access Key ID",
|
459
459
|
description="Equivalent to the AWS_ACCESS_KEY_ID environment variable.",
|
460
|
-
|
460
|
+
examples=["AKIAIOSFODNN7EXAMPLE"],
|
461
461
|
)
|
462
462
|
aws_secret_access_key: Optional[SecretStr] = Field(
|
463
463
|
default=None,
|
464
464
|
title="AWS Secret Access Key",
|
465
465
|
description="Equivalent to the AWS_SECRET_ACCESS_KEY environment variable.",
|
466
|
-
|
466
|
+
examples=["wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"],
|
467
467
|
)
|
468
468
|
|
469
469
|
_remote_file_system: RemoteFileSystem = None
|
@@ -549,7 +549,7 @@ class GCS(WritableFileSystem, WritableDeploymentStorage):
|
|
549
549
|
bucket_path: str = Field(
|
550
550
|
default=...,
|
551
551
|
description="A GCS bucket path.",
|
552
|
-
|
552
|
+
examples=["my-bucket/a-directory-within"],
|
553
553
|
)
|
554
554
|
service_account_info: Optional[SecretStr] = Field(
|
555
555
|
default=None,
|
@@ -653,7 +653,7 @@ class Azure(WritableFileSystem, WritableDeploymentStorage):
|
|
653
653
|
bucket_path: str = Field(
|
654
654
|
default=...,
|
655
655
|
description="An Azure storage bucket path.",
|
656
|
-
|
656
|
+
examples=["my-bucket/a-directory-within"],
|
657
657
|
)
|
658
658
|
azure_storage_connection_string: Optional[SecretStr] = Field(
|
659
659
|
default=None,
|
@@ -804,7 +804,7 @@ class SMB(WritableFileSystem, WritableDeploymentStorage):
|
|
804
804
|
share_path: str = Field(
|
805
805
|
default=...,
|
806
806
|
description="SMB target (requires <SHARE>, followed by <PATH>).",
|
807
|
-
|
807
|
+
examples=["/SHARE/dir/subdir"],
|
808
808
|
)
|
809
809
|
smb_username: Optional[SecretStr] = Field(
|
810
810
|
default=None,
|
prefect/flows.py
CHANGED
@@ -590,13 +590,13 @@ class Flow(Generic[P, R]):
|
|
590
590
|
@sync_compatible
|
591
591
|
@deprecated_parameter(
|
592
592
|
"schedule",
|
593
|
-
start_date="Mar
|
593
|
+
start_date="Mar 2024",
|
594
594
|
when=lambda p: p is not None,
|
595
595
|
help="Use `schedules` instead.",
|
596
596
|
)
|
597
597
|
@deprecated_parameter(
|
598
598
|
"is_schedule_active",
|
599
|
-
start_date="Mar
|
599
|
+
start_date="Mar 2024",
|
600
600
|
when=lambda p: p is not None,
|
601
601
|
help="Use `paused` instead.",
|
602
602
|
)
|
@@ -1125,10 +1125,11 @@ class Flow(Generic[P, R]):
|
|
1125
1125
|
style="blue",
|
1126
1126
|
)
|
1127
1127
|
if PREFECT_UI_URL:
|
1128
|
-
|
1128
|
+
message = (
|
1129
1129
|
"\nYou can also run your flow via the Prefect UI:"
|
1130
1130
|
f" [blue]{PREFECT_UI_URL.value()}/deployments/deployment/{deployment_ids[0]}[/]\n"
|
1131
1131
|
)
|
1132
|
+
console.print(message, soft_wrap=True)
|
1132
1133
|
|
1133
1134
|
return deployment_ids[0]
|
1134
1135
|
|
prefect/manifests.py
CHANGED
@@ -4,14 +4,7 @@ Manifests are portable descriptions of one or more workflows within a given dire
|
|
4
4
|
They are the foundational building blocks for defining Flow Deployments.
|
5
5
|
"""
|
6
6
|
|
7
|
-
|
8
|
-
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
9
|
-
|
10
|
-
if HAS_PYDANTIC_V2:
|
11
|
-
from pydantic.v1 import BaseModel, Field
|
12
|
-
else:
|
13
|
-
from pydantic import BaseModel, Field
|
14
|
-
|
7
|
+
from prefect.pydantic import BaseModel, Field
|
15
8
|
from prefect.utilities.callables import ParameterSchema
|
16
9
|
|
17
10
|
|
prefect/profiles.toml
CHANGED
prefect/pydantic/__init__.py
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
"""
|
2
|
+
This initialization file makes the `BaseModel` and `PrefectBaseModel` classes available for import from the pydantic module within Prefect. This setup allows other parts of the Prefect codebase to use these models without needing to understand the underlying compatibility layer.
|
3
|
+
"""
|
1
4
|
import typing
|
2
5
|
from prefect._internal.pydantic._flags import HAS_PYDANTIC_V2, USE_PYDANTIC_V2
|
3
6
|
|
@@ -5,15 +8,32 @@ if typing.TYPE_CHECKING:
|
|
5
8
|
# import of virtually everything is supported via `__getattr__` below,
|
6
9
|
# but we need them here for type checking and IDE support
|
7
10
|
from pydantic import validator, root_validator
|
8
|
-
from .main import
|
11
|
+
from .main import (
|
12
|
+
BaseModel,
|
13
|
+
PrefectBaseModel,
|
14
|
+
FieldInfo,
|
15
|
+
Field,
|
16
|
+
PrivateAttr,
|
17
|
+
SecretStr,
|
18
|
+
field_validator,
|
19
|
+
model_validator,
|
20
|
+
ConfigDict,
|
21
|
+
ValidationError,
|
22
|
+
)
|
9
23
|
|
10
24
|
__all__ = [
|
11
25
|
"BaseModel",
|
12
26
|
"PrefectBaseModel",
|
13
27
|
"Field",
|
14
28
|
"FieldInfo",
|
29
|
+
"PrivateAttr",
|
30
|
+
"SecretStr",
|
15
31
|
"validator",
|
16
32
|
"root_validator",
|
33
|
+
"field_validator",
|
34
|
+
"model_validator",
|
35
|
+
"ConfigDict",
|
36
|
+
"ValidationError",
|
17
37
|
]
|
18
38
|
|
19
39
|
_dynamic_imports: "typing.Dict[str, typing.Tuple[str, str]]" = {
|
@@ -21,6 +41,12 @@ _dynamic_imports: "typing.Dict[str, typing.Tuple[str, str]]" = {
|
|
21
41
|
"PrefectBaseModel": ("prefect.pydantic", ".main"),
|
22
42
|
"Field": ("prefect.pydantic", ".main"),
|
23
43
|
"FieldInfo": ("prefect.pydantic", ".main"),
|
44
|
+
"PrivateAttr": ("prefect.pydantic", ".main"),
|
45
|
+
"SecretStr": ("prefect.pydantic", ".main"),
|
46
|
+
"field_validator": ("prefect.pydantic", ".main"),
|
47
|
+
"model_validator": ("prefect.pydantic", ".main"),
|
48
|
+
"ConfigDict": ("prefect.pydantic", ".main"),
|
49
|
+
"ValidationError": ("prefect.pydantic", ".main"),
|
24
50
|
}
|
25
51
|
|
26
52
|
|
prefect/pydantic/main.py
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
+
"""
|
2
|
+
This file defines a `PrefectBaseModel` class that extends the `BaseModel` (imported from the internal compatibility layer).
|
3
|
+
"""
|
1
4
|
import typing
|
2
5
|
|
3
|
-
from prefect._internal.pydantic._compat import
|
6
|
+
from prefect._internal.pydantic._compat import (
|
7
|
+
BaseModel,
|
8
|
+
ConfigDict,
|
9
|
+
Field,
|
10
|
+
FieldInfo,
|
11
|
+
PrivateAttr,
|
12
|
+
SecretStr,
|
13
|
+
ValidationError,
|
14
|
+
field_validator,
|
15
|
+
model_validator,
|
16
|
+
)
|
4
17
|
|
5
18
|
|
6
19
|
class PrefectBaseModel(BaseModel):
|
@@ -12,4 +25,15 @@ class PrefectBaseModel(BaseModel):
|
|
12
25
|
return set()
|
13
26
|
|
14
27
|
|
15
|
-
__all__ = [
|
28
|
+
__all__ = [
|
29
|
+
"BaseModel",
|
30
|
+
"PrefectBaseModel",
|
31
|
+
"Field",
|
32
|
+
"FieldInfo",
|
33
|
+
"PrivateAttr",
|
34
|
+
"SecretStr",
|
35
|
+
"field_validator",
|
36
|
+
"model_validator",
|
37
|
+
"ConfigDict",
|
38
|
+
"ValidationError",
|
39
|
+
]
|
prefect/settings.py
CHANGED
@@ -107,6 +107,8 @@ DEFAULT_PROFILES_PATH = Path(__file__).parent.joinpath("profiles.toml")
|
|
107
107
|
REMOVED_EXPERIMENTAL_FLAGS = {
|
108
108
|
"PREFECT_EXPERIMENTAL_ENABLE_ENHANCED_SCHEDULING_UI",
|
109
109
|
"PREFECT_EXPERIMENTAL_ENABLE_ENHANCED_DEPLOYMENT_PARAMETERS",
|
110
|
+
"PREFECT_EXPERIMENTAL_ENABLE_EVENTS_CLIENT",
|
111
|
+
"PREFECT_EXPERIMENTAL_WARN_EVENTS_CLIENT",
|
110
112
|
}
|
111
113
|
|
112
114
|
|
@@ -1367,16 +1369,6 @@ PREFECT_EXPERIMENTAL_ENABLE_STATES_ON_FLOW_RUN_GRAPH = Setting(bool, default=Tru
|
|
1367
1369
|
Whether or not to enable flow run states on the flow run graph.
|
1368
1370
|
"""
|
1369
1371
|
|
1370
|
-
PREFECT_EXPERIMENTAL_ENABLE_EVENTS_CLIENT = Setting(bool, default=True)
|
1371
|
-
"""
|
1372
|
-
Whether or not to enable experimental Prefect work pools.
|
1373
|
-
"""
|
1374
|
-
|
1375
|
-
PREFECT_EXPERIMENTAL_WARN_EVENTS_CLIENT = Setting(bool, default=False)
|
1376
|
-
"""
|
1377
|
-
Whether or not to warn when experimental Prefect work pools are used.
|
1378
|
-
"""
|
1379
|
-
|
1380
1372
|
PREFECT_EXPERIMENTAL_ENABLE_WORK_POOLS = Setting(bool, default=True)
|
1381
1373
|
"""
|
1382
1374
|
Whether or not to enable experimental Prefect work pools.
|
@@ -1679,6 +1671,37 @@ PREFECT_API_SERVICES_EVENT_LOGGER_ENABLED = Setting(bool, default=True)
|
|
1679
1671
|
Whether or not to start the event debug logger service in the server application.
|
1680
1672
|
"""
|
1681
1673
|
|
1674
|
+
PREFECT_API_SERVICES_TRIGGERS_ENABLED = Setting(bool, default=True)
|
1675
|
+
"""
|
1676
|
+
Whether or not to start the triggers service in the server application.
|
1677
|
+
"""
|
1678
|
+
|
1679
|
+
PREFECT_EVENTS_EXPIRED_BUCKET_BUFFER = Setting(timedelta, default=timedelta(seconds=60))
|
1680
|
+
"""
|
1681
|
+
The amount of time to retain expired automation buckets
|
1682
|
+
"""
|
1683
|
+
|
1684
|
+
PREFECT_EVENTS_PROACTIVE_GRANULARITY = Setting(timedelta, default=timedelta(seconds=5))
|
1685
|
+
"""
|
1686
|
+
How frequently proactive automations are evaluated
|
1687
|
+
"""
|
1688
|
+
|
1689
|
+
PREFECT_API_SERVICES_EVENT_PERSISTER_ENABLED = Setting(bool, default=True)
|
1690
|
+
"""
|
1691
|
+
Whether or not to start the event persister service in the server application.
|
1692
|
+
"""
|
1693
|
+
|
1694
|
+
PREFECT_API_SERVICES_EVENT_PERSISTER_BATCH_SIZE = Setting(int, default=20, gt=0)
|
1695
|
+
"""
|
1696
|
+
The number of events the event persister will attempt to insert in one batch.
|
1697
|
+
"""
|
1698
|
+
|
1699
|
+
PREFECT_API_SERVICES_EVENT_PERSISTER_FLUSH_INTERVAL = Setting(float, default=5, gt=0.0)
|
1700
|
+
"""
|
1701
|
+
The maximum number of seconds between flushes of the event persister.
|
1702
|
+
"""
|
1703
|
+
|
1704
|
+
|
1682
1705
|
# Deprecated settings ------------------------------------------------------------------
|
1683
1706
|
|
1684
1707
|
|
prefect/task_server.py
CHANGED
@@ -53,8 +53,8 @@ def should_try_to_read_parameters(task: Task, task_run: TaskRun) -> bool:
|
|
53
53
|
|
54
54
|
|
55
55
|
class TaskServer:
|
56
|
-
"""This class is responsible for serving tasks that may be executed
|
57
|
-
task runner
|
56
|
+
"""This class is responsible for serving tasks that may be executed in the background
|
57
|
+
by a task runner via the traditional engine machinery.
|
58
58
|
|
59
59
|
When `start()` is called, the task server will open a websocket connection to a
|
60
60
|
server-side queue of scheduled task runs. When a scheduled task run is found, the
|