prefect-client 2.16.8__py3-none-any.whl → 2.17.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prefect/__init__.py +0 -18
- prefect/_internal/compatibility/deprecated.py +108 -5
- prefect/_internal/compatibility/experimental.py +9 -8
- prefect/_internal/concurrency/api.py +23 -42
- prefect/_internal/concurrency/waiters.py +25 -22
- prefect/_internal/pydantic/__init__.py +16 -3
- prefect/_internal/pydantic/_base_model.py +39 -4
- prefect/_internal/pydantic/_compat.py +69 -452
- prefect/_internal/pydantic/_flags.py +5 -0
- prefect/_internal/pydantic/_types.py +8 -0
- prefect/_internal/pydantic/utilities/__init__.py +0 -0
- prefect/_internal/pydantic/utilities/config_dict.py +72 -0
- prefect/_internal/pydantic/utilities/field_validator.py +135 -0
- prefect/_internal/pydantic/utilities/model_construct.py +56 -0
- prefect/_internal/pydantic/utilities/model_copy.py +55 -0
- prefect/_internal/pydantic/utilities/model_dump.py +136 -0
- prefect/_internal/pydantic/utilities/model_dump_json.py +112 -0
- prefect/_internal/pydantic/utilities/model_fields.py +50 -0
- prefect/_internal/pydantic/utilities/model_fields_set.py +29 -0
- prefect/_internal/pydantic/utilities/model_json_schema.py +82 -0
- prefect/_internal/pydantic/utilities/model_rebuild.py +80 -0
- prefect/_internal/pydantic/utilities/model_validate.py +75 -0
- prefect/_internal/pydantic/utilities/model_validate_json.py +68 -0
- prefect/_internal/pydantic/utilities/model_validator.py +79 -0
- prefect/_internal/pydantic/utilities/type_adapter.py +71 -0
- prefect/_internal/schemas/bases.py +1 -17
- prefect/_internal/schemas/validators.py +425 -4
- prefect/agent.py +1 -1
- prefect/blocks/kubernetes.py +7 -3
- prefect/blocks/notifications.py +18 -18
- prefect/blocks/webhook.py +1 -1
- prefect/client/base.py +7 -0
- prefect/client/cloud.py +1 -1
- prefect/client/orchestration.py +51 -11
- prefect/client/schemas/actions.py +367 -297
- prefect/client/schemas/filters.py +28 -28
- prefect/client/schemas/objects.py +78 -147
- prefect/client/schemas/responses.py +240 -60
- prefect/client/schemas/schedules.py +6 -8
- prefect/concurrency/events.py +2 -2
- prefect/context.py +4 -2
- prefect/deployments/base.py +6 -13
- prefect/deployments/deployments.py +34 -9
- prefect/deployments/runner.py +9 -27
- prefect/deprecated/packaging/base.py +5 -6
- prefect/deprecated/packaging/docker.py +19 -25
- prefect/deprecated/packaging/file.py +10 -5
- prefect/deprecated/packaging/orion.py +9 -4
- prefect/deprecated/packaging/serializers.py +8 -58
- prefect/engine.py +55 -618
- prefect/events/actions.py +16 -1
- prefect/events/clients.py +45 -13
- prefect/events/filters.py +19 -2
- prefect/events/related.py +4 -4
- prefect/events/schemas/automations.py +13 -2
- prefect/events/schemas/deployment_triggers.py +73 -5
- prefect/events/schemas/events.py +1 -1
- 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 +7 -3
- prefect/infrastructure/provisioners/ecs.py +1 -0
- prefect/logging/configuration.py +2 -2
- prefect/manifests.py +1 -8
- prefect/profiles.toml +1 -1
- prefect/pydantic/__init__.py +74 -2
- prefect/pydantic/main.py +26 -2
- prefect/serializers.py +6 -31
- prefect/settings.py +72 -26
- prefect/software/python.py +3 -5
- prefect/task_server.py +2 -2
- prefect/utilities/callables.py +1 -1
- prefect/utilities/collections.py +2 -1
- prefect/utilities/dispatch.py +1 -0
- prefect/utilities/engine.py +629 -0
- prefect/utilities/pydantic.py +1 -1
- prefect/utilities/schema_tools/validation.py +2 -2
- prefect/utilities/visualization.py +1 -1
- prefect/variables.py +88 -12
- prefect/workers/base.py +20 -11
- prefect/workers/block.py +4 -8
- prefect/workers/process.py +2 -5
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/METADATA +4 -3
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/RECORD +88 -72
- prefect/_internal/schemas/transformations.py +0 -106
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/LICENSE +0 -0
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/WHEEL +0 -0
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/top_level.txt +0 -0
prefect/__init__.py
CHANGED
@@ -106,24 +106,6 @@ from prefect._internal.compatibility.deprecated import (
|
|
106
106
|
register_renamed_module,
|
107
107
|
)
|
108
108
|
|
109
|
-
register_renamed_module(
|
110
|
-
"prefect.client.orchestration",
|
111
|
-
"prefect.client.orchestration",
|
112
|
-
start_date="Feb 2023",
|
113
|
-
)
|
114
|
-
register_renamed_module(
|
115
|
-
"prefect.docker",
|
116
|
-
"prefect.utilities.dockerutils",
|
117
|
-
start_date="Mar 2023",
|
118
|
-
)
|
119
|
-
register_renamed_module(
|
120
|
-
"prefect.infrastructure.docker",
|
121
|
-
"prefect.infrastructure.container",
|
122
|
-
start_date="Mar 2023",
|
123
|
-
)
|
124
|
-
register_renamed_module(
|
125
|
-
"prefect.projects", "prefect.deployments", start_date="Jun 2023"
|
126
|
-
)
|
127
109
|
register_renamed_module(
|
128
110
|
"prefect.packaging", "prefect.deprecated.packaging", start_date="Mar 2024"
|
129
111
|
)
|
@@ -12,16 +12,18 @@ e.g. Jan 2023.
|
|
12
12
|
import functools
|
13
13
|
import sys
|
14
14
|
import warnings
|
15
|
-
from typing import Any, Callable, List, Optional, Type, TypeVar
|
15
|
+
from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union
|
16
16
|
|
17
17
|
import pendulum
|
18
18
|
|
19
19
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
20
20
|
|
21
21
|
if HAS_PYDANTIC_V2:
|
22
|
-
|
22
|
+
from pydantic.v1 import BaseModel, Field, root_validator
|
23
|
+
from pydantic.v1.schema import default_ref_template
|
23
24
|
else:
|
24
|
-
import
|
25
|
+
from pydantic import BaseModel, Field, root_validator
|
26
|
+
from pydantic.schema import default_ref_template
|
25
27
|
|
26
28
|
from prefect.utilities.callables import get_call_parameters
|
27
29
|
from prefect.utilities.importtools import (
|
@@ -31,7 +33,7 @@ from prefect.utilities.importtools import (
|
|
31
33
|
)
|
32
34
|
|
33
35
|
T = TypeVar("T", bound=Callable)
|
34
|
-
M = TypeVar("M", bound=
|
36
|
+
M = TypeVar("M", bound=BaseModel)
|
35
37
|
|
36
38
|
|
37
39
|
DEPRECATED_WARNING = (
|
@@ -207,7 +209,7 @@ def deprecated_field(
|
|
207
209
|
```python
|
208
210
|
|
209
211
|
@deprecated_field("x", when=lambda x: x is not None)
|
210
|
-
class Model(
|
212
|
+
class Model(BaseModel)
|
211
213
|
x: Optional[int] = None
|
212
214
|
y: str
|
213
215
|
```
|
@@ -276,3 +278,104 @@ def register_renamed_module(old_name: str, new_name: str, start_date: str):
|
|
276
278
|
DEPRECATED_MODULE_ALIASES.append(
|
277
279
|
AliasedModuleDefinition(old_name, new_name, callback)
|
278
280
|
)
|
281
|
+
|
282
|
+
|
283
|
+
class DeprecatedInfraOverridesField(BaseModel):
|
284
|
+
"""
|
285
|
+
A model mixin that handles the deprecated `infra_overrides` field.
|
286
|
+
|
287
|
+
The `infra_overrides` field has been renamed to `job_variables`. This mixin maintains
|
288
|
+
backwards compatibility with users of the `infra_overrides` field while presenting
|
289
|
+
`job_variables` as the user-facing field.
|
290
|
+
|
291
|
+
When we remove support for `infra_overrides`, we can remove this class as a parent of
|
292
|
+
all schemas that use it, leaving them with only the `job_variables` field.
|
293
|
+
"""
|
294
|
+
|
295
|
+
infra_overrides: Optional[Dict[str, Any]] = Field(
|
296
|
+
default_factory=dict,
|
297
|
+
description="Deprecated field. Use `job_variables` instead.",
|
298
|
+
)
|
299
|
+
|
300
|
+
@root_validator(pre=True)
|
301
|
+
def _job_variables_from_infra_overrides(
|
302
|
+
cls, values: Dict[str, Any]
|
303
|
+
) -> Dict[str, Any]:
|
304
|
+
"""
|
305
|
+
Validate that only one of `infra_overrides` or `job_variables` is used
|
306
|
+
and keep them in sync during init.
|
307
|
+
"""
|
308
|
+
job_variables = values.get("job_variables")
|
309
|
+
infra_overrides = values.get("infra_overrides")
|
310
|
+
|
311
|
+
if job_variables is not None and infra_overrides is not None:
|
312
|
+
if job_variables != infra_overrides:
|
313
|
+
raise ValueError(
|
314
|
+
"The `infra_overrides` field has been renamed to `job_variables`."
|
315
|
+
"Use one of these fields, but not both."
|
316
|
+
)
|
317
|
+
return values
|
318
|
+
elif job_variables is not None and infra_overrides is None:
|
319
|
+
values["infra_overrides"] = job_variables
|
320
|
+
elif job_variables is None and infra_overrides is not None:
|
321
|
+
values["job_variables"] = infra_overrides
|
322
|
+
return values
|
323
|
+
|
324
|
+
def __setattr__(self, key: str, value: Any) -> None:
|
325
|
+
"""
|
326
|
+
Override the default __setattr__ to ensure that setting `infra_overrides` or
|
327
|
+
`job_variables` will update both fields.
|
328
|
+
"""
|
329
|
+
if key == "infra_overrides" or key == "job_variables":
|
330
|
+
updates = {"infra_overrides": value, "job_variables": value}
|
331
|
+
self.__dict__.update(updates)
|
332
|
+
return
|
333
|
+
super().__setattr__(key, value)
|
334
|
+
|
335
|
+
def dict(self, **kwargs) -> Dict[str, Any]:
|
336
|
+
"""
|
337
|
+
Override the default dict method to ensure only `infra_overrides` is serialized.
|
338
|
+
This preserves backwards compatibility for newer clients talking to older servers.
|
339
|
+
"""
|
340
|
+
exclude: Union[set, Dict[str, Any]] = kwargs.pop("exclude", set())
|
341
|
+
exclude_type = type(exclude)
|
342
|
+
|
343
|
+
if exclude_type is set:
|
344
|
+
exclude.add("job_variables")
|
345
|
+
elif exclude_type is dict:
|
346
|
+
exclude["job_variables"] = True
|
347
|
+
kwargs["exclude"] = exclude
|
348
|
+
|
349
|
+
return super().dict(**kwargs)
|
350
|
+
|
351
|
+
@classmethod
|
352
|
+
def schema(
|
353
|
+
cls, by_alias: bool = True, ref_template: str = default_ref_template
|
354
|
+
) -> Dict[str, Any]:
|
355
|
+
"""
|
356
|
+
Don't use the mixin docstring as the description if this class is missing a
|
357
|
+
docstring.
|
358
|
+
"""
|
359
|
+
schema = super().schema(by_alias=by_alias, ref_template=ref_template)
|
360
|
+
|
361
|
+
if not cls.__doc__:
|
362
|
+
schema.pop("description", None)
|
363
|
+
|
364
|
+
return schema
|
365
|
+
|
366
|
+
|
367
|
+
def handle_deprecated_infra_overrides_parameter(
|
368
|
+
job_variables: Dict[str, Any], infra_overrides: Dict[str, Any]
|
369
|
+
) -> Optional[Dict[str, Any]]:
|
370
|
+
if infra_overrides is not None and job_variables is not None:
|
371
|
+
raise RuntimeError(
|
372
|
+
"The `infra_overrides` argument has been renamed to `job_variables`."
|
373
|
+
"Use one or the other, but not both."
|
374
|
+
)
|
375
|
+
elif infra_overrides is not None and job_variables is None:
|
376
|
+
jv = infra_overrides
|
377
|
+
elif job_variables is not None and infra_overrides is None:
|
378
|
+
jv = job_variables
|
379
|
+
else:
|
380
|
+
jv = None
|
381
|
+
return jv
|
@@ -10,6 +10,7 @@ Warnings may also be disabled globally with the setting `PREFECT_EXPERIMENTAL_WA
|
|
10
10
|
Some experimental features require opt-in to enable any usage. These require the setting
|
11
11
|
`PREFECT_EXPERIMENTAL_ENABLE_<GROUP>` to be set or an error will be thrown on use.
|
12
12
|
"""
|
13
|
+
|
13
14
|
import functools
|
14
15
|
import warnings
|
15
16
|
from typing import Any, Callable, Optional, Set, Type, TypeVar
|
@@ -24,7 +25,7 @@ else:
|
|
24
25
|
from prefect.settings import PREFECT_EXPERIMENTAL_WARN, SETTING_VARIABLES, Setting
|
25
26
|
from prefect.utilities.callables import get_call_parameters
|
26
27
|
|
27
|
-
T = TypeVar("T", bound=Callable)
|
28
|
+
T = TypeVar("T", bound=Callable[..., Any])
|
28
29
|
M = TypeVar("M", bound=pydantic.BaseModel)
|
29
30
|
|
30
31
|
|
@@ -47,12 +48,6 @@ class ExperimentalWarning(Warning):
|
|
47
48
|
"""
|
48
49
|
|
49
50
|
|
50
|
-
class ExperimentalError(Exception):
|
51
|
-
"""
|
52
|
-
An exception related to experimental code.
|
53
|
-
"""
|
54
|
-
|
55
|
-
|
56
51
|
class ExperimentalFeature(ExperimentalWarning):
|
57
52
|
"""
|
58
53
|
A warning displayed on use of an experimental feature.
|
@@ -61,6 +56,12 @@ class ExperimentalFeature(ExperimentalWarning):
|
|
61
56
|
"""
|
62
57
|
|
63
58
|
|
59
|
+
class ExperimentalError(Exception):
|
60
|
+
"""
|
61
|
+
An exception related to experimental code.
|
62
|
+
"""
|
63
|
+
|
64
|
+
|
64
65
|
class ExperimentalFeatureDisabled(ExperimentalError):
|
65
66
|
"""
|
66
67
|
An error displayed on use of a disabled experimental feature that requires opt-in.
|
@@ -112,7 +113,7 @@ def experimental(
|
|
112
113
|
|
113
114
|
group_warn = _warn_setting_for_group(group)
|
114
115
|
|
115
|
-
def decorator(fn: T):
|
116
|
+
def decorator(fn: T) -> T:
|
116
117
|
@functools.wraps(fn)
|
117
118
|
def wrapper(*args, **kwargs):
|
118
119
|
if opt_in and not group_opt_in:
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""
|
2
2
|
Primary developer-facing API for concurrency management.
|
3
3
|
"""
|
4
|
+
|
4
5
|
import abc
|
5
6
|
import asyncio
|
6
7
|
import concurrent.futures
|
@@ -18,6 +19,7 @@ from typing import (
|
|
18
19
|
|
19
20
|
from typing_extensions import ParamSpec
|
20
21
|
|
22
|
+
from prefect._internal.concurrency.calls import get_current_call
|
21
23
|
from prefect._internal.concurrency.threads import (
|
22
24
|
WorkerThread,
|
23
25
|
get_global_loop,
|
@@ -104,40 +106,6 @@ class _base(abc.ABC):
|
|
104
106
|
runner.submit(call)
|
105
107
|
return call
|
106
108
|
|
107
|
-
@staticmethod
|
108
|
-
def call_soon_in_waiting_thread(
|
109
|
-
__call: Union[Callable[[], T], Call[T]],
|
110
|
-
thread: threading.Thread,
|
111
|
-
timeout: Optional[float] = None,
|
112
|
-
) -> Call[T]:
|
113
|
-
"""
|
114
|
-
Schedule a call for execution in the thread that is waiting for the current
|
115
|
-
call.
|
116
|
-
|
117
|
-
Returns the submitted call.
|
118
|
-
"""
|
119
|
-
call = _cast_to_call(__call)
|
120
|
-
waiter = get_waiter_for_thread(thread)
|
121
|
-
if waiter is None:
|
122
|
-
raise RuntimeError(f"No waiter found for thread {thread}.")
|
123
|
-
|
124
|
-
call.set_timeout(timeout)
|
125
|
-
waiter.submit(call)
|
126
|
-
return call
|
127
|
-
|
128
|
-
@staticmethod
|
129
|
-
def call_in_waiting_thread(
|
130
|
-
__call: Union[Callable[[], T], Call[T]],
|
131
|
-
thread: threading.Thread,
|
132
|
-
timeout: Optional[float] = None,
|
133
|
-
) -> T:
|
134
|
-
"""
|
135
|
-
Run a call in the thread that is waiting for the current call.
|
136
|
-
|
137
|
-
Returns the result of the call.
|
138
|
-
"""
|
139
|
-
raise NotImplementedError()
|
140
|
-
|
141
109
|
@staticmethod
|
142
110
|
def call_in_new_thread(
|
143
111
|
__call: Union[Callable[[], T], Call[T]], timeout: Optional[float] = None
|
@@ -196,13 +164,20 @@ class from_async(_base):
|
|
196
164
|
return call.result()
|
197
165
|
|
198
166
|
@staticmethod
|
199
|
-
def
|
167
|
+
def call_soon_in_waiting_thread(
|
200
168
|
__call: Union[Callable[[], T], Call[T]],
|
201
169
|
thread: threading.Thread,
|
202
170
|
timeout: Optional[float] = None,
|
203
|
-
) ->
|
204
|
-
call =
|
205
|
-
|
171
|
+
) -> Call[T]:
|
172
|
+
call = _cast_to_call(__call)
|
173
|
+
parent_call = get_current_call()
|
174
|
+
waiter = get_waiter_for_thread(thread, parent_call)
|
175
|
+
if waiter is None:
|
176
|
+
raise RuntimeError(f"No waiter found for thread {thread}.")
|
177
|
+
|
178
|
+
call.set_timeout(timeout)
|
179
|
+
waiter.submit(call)
|
180
|
+
return call
|
206
181
|
|
207
182
|
@staticmethod
|
208
183
|
def call_in_new_thread(
|
@@ -257,13 +232,19 @@ class from_sync(_base):
|
|
257
232
|
return call.result()
|
258
233
|
|
259
234
|
@staticmethod
|
260
|
-
def
|
235
|
+
def call_soon_in_waiting_thread(
|
261
236
|
__call: Union[Callable[[], T], Call[T]],
|
262
237
|
thread: threading.Thread,
|
263
238
|
timeout: Optional[float] = None,
|
264
|
-
) -> T:
|
265
|
-
call =
|
266
|
-
|
239
|
+
) -> Call[T]:
|
240
|
+
call = _cast_to_call(__call)
|
241
|
+
waiter = get_waiter_for_thread(thread)
|
242
|
+
if waiter is None:
|
243
|
+
raise RuntimeError(f"No waiter found for thread {thread}.")
|
244
|
+
|
245
|
+
call.set_timeout(timeout)
|
246
|
+
waiter.submit(call)
|
247
|
+
return call
|
267
248
|
|
268
249
|
@staticmethod
|
269
250
|
def call_in_new_thread(
|
@@ -9,9 +9,9 @@ import contextlib
|
|
9
9
|
import inspect
|
10
10
|
import queue
|
11
11
|
import threading
|
12
|
-
import weakref
|
13
12
|
from collections import deque
|
14
13
|
from typing import Awaitable, Generic, List, Optional, TypeVar, Union
|
14
|
+
from weakref import WeakKeyDictionary
|
15
15
|
|
16
16
|
import anyio
|
17
17
|
|
@@ -24,34 +24,37 @@ T = TypeVar("T")
|
|
24
24
|
|
25
25
|
|
26
26
|
# Waiters are stored in a stack for each thread
|
27
|
-
_WAITERS_BY_THREAD: "
|
28
|
-
|
27
|
+
_WAITERS_BY_THREAD: "WeakKeyDictionary[threading.Thread, deque[Waiter]]" = (
|
28
|
+
WeakKeyDictionary()
|
29
29
|
)
|
30
30
|
|
31
31
|
|
32
|
-
def get_waiter_for_thread(
|
32
|
+
def get_waiter_for_thread(
|
33
|
+
thread: threading.Thread, parent_call: Optional[Call] = None
|
34
|
+
) -> Optional["Waiter"]:
|
33
35
|
"""
|
34
|
-
Get the current waiter for a thread.
|
36
|
+
Get the current waiter for a thread and an optional parent call.
|
35
37
|
|
36
|
-
|
38
|
+
To avoid assigning outer callbacks to inner waiters in the case of nested calls,
|
39
|
+
the parent call is used to determine which waiter to return. If a parent call is
|
40
|
+
not provided, we return the most recently created waiter (last in the stack).
|
41
|
+
|
42
|
+
see https://github.com/PrefectHQ/prefect/issues/12036
|
43
|
+
|
44
|
+
Returns `None` if no active waiter is found for the thread.
|
37
45
|
"""
|
38
|
-
waiters = _WAITERS_BY_THREAD.get(thread)
|
39
|
-
|
40
|
-
if waiters:
|
41
|
-
idx = -1
|
42
|
-
while abs(idx) <= len(waiters):
|
43
|
-
try:
|
44
|
-
waiter = waiters[idx]
|
45
|
-
if not waiter.call_is_done():
|
46
|
-
return waiter
|
47
|
-
idx = idx - 1
|
48
|
-
# It is possible that items are being added or removed
|
49
|
-
# from the deque, so the index we're using may not always
|
50
|
-
# be valid.
|
51
|
-
except IndexError:
|
52
|
-
break
|
53
46
|
|
54
|
-
|
47
|
+
waiters: "Optional[deque[Waiter]]" = _WAITERS_BY_THREAD.get(thread)
|
48
|
+
|
49
|
+
if waiters and (active_waiters := [w for w in waiters if not w.call_is_done()]):
|
50
|
+
if parent_call and (
|
51
|
+
matching_waiter := next(
|
52
|
+
(w for w in active_waiters if w._call == parent_call), None
|
53
|
+
)
|
54
|
+
): # if exists an active waiter responsible for the parent call, return it
|
55
|
+
return matching_waiter
|
56
|
+
else: # otherwise, return the most recently created waiter
|
57
|
+
return active_waiters[-1]
|
55
58
|
|
56
59
|
|
57
60
|
def add_waiter_for_thread(waiter: "Waiter", thread: threading.Thread):
|
@@ -6,21 +6,27 @@
|
|
6
6
|
### This is a tradeoff we're willing to make for now until pydantic v1 is
|
7
7
|
### no longer supported.
|
8
8
|
|
9
|
-
from pydantic.version import VERSION as PYDANTIC_VERSION
|
10
9
|
|
11
|
-
|
10
|
+
from ._flags import HAS_PYDANTIC_V2
|
12
11
|
|
13
12
|
from ._compat import (
|
14
13
|
model_dump,
|
15
14
|
model_json_schema,
|
16
15
|
model_validate,
|
17
|
-
IncEx,
|
18
16
|
model_dump_json,
|
19
17
|
model_copy,
|
20
18
|
model_validate_json,
|
19
|
+
TypeAdapter,
|
21
20
|
validate_python,
|
21
|
+
BaseModel,
|
22
|
+
Field,
|
23
|
+
FieldInfo,
|
24
|
+
field_validator,
|
25
|
+
model_validator,
|
22
26
|
)
|
23
27
|
|
28
|
+
from ._types import IncEx
|
29
|
+
|
24
30
|
__all__ = [
|
25
31
|
"model_dump",
|
26
32
|
"model_json_schema",
|
@@ -29,5 +35,12 @@ __all__ = [
|
|
29
35
|
"model_dump_json",
|
30
36
|
"model_copy",
|
31
37
|
"model_validate_json",
|
38
|
+
"TypeAdapter",
|
32
39
|
"validate_python",
|
40
|
+
"BaseModel",
|
41
|
+
"HAS_PYDANTIC_V2",
|
42
|
+
"Field",
|
43
|
+
"FieldInfo",
|
44
|
+
"field_validator",
|
45
|
+
"model_validator",
|
33
46
|
]
|
@@ -1,3 +1,6 @@
|
|
1
|
+
"""
|
2
|
+
This file introduces a conditional import of `BaseModel` from Pydantic, depending on the Pydantic version available. If Pydantic V2 is not used, it falls back to importing `BaseModel` from Pydantic V1. This is to ensure compatibility with different versions of Pydantic.
|
3
|
+
"""
|
1
4
|
import typing
|
2
5
|
|
3
6
|
from prefect._internal.pydantic._flags import (
|
@@ -6,11 +9,43 @@ from prefect._internal.pydantic._flags import (
|
|
6
9
|
)
|
7
10
|
|
8
11
|
if typing.TYPE_CHECKING:
|
9
|
-
from pydantic import
|
12
|
+
from pydantic import (
|
13
|
+
BaseModel,
|
14
|
+
ConfigDict,
|
15
|
+
Field,
|
16
|
+
PrivateAttr,
|
17
|
+
SecretStr,
|
18
|
+
ValidationError,
|
19
|
+
)
|
20
|
+
from pydantic.fields import FieldInfo
|
10
21
|
|
11
22
|
if HAS_PYDANTIC_V2 and not USE_PYDANTIC_V2:
|
12
|
-
from pydantic.v1 import
|
23
|
+
from pydantic.v1 import (
|
24
|
+
BaseModel,
|
25
|
+
ConfigDict,
|
26
|
+
Field,
|
27
|
+
PrivateAttr,
|
28
|
+
SecretStr,
|
29
|
+
ValidationError,
|
30
|
+
)
|
31
|
+
from pydantic.v1.fields import FieldInfo
|
13
32
|
else:
|
14
|
-
from pydantic import
|
33
|
+
from pydantic import (
|
34
|
+
BaseModel,
|
35
|
+
ConfigDict,
|
36
|
+
Field,
|
37
|
+
PrivateAttr,
|
38
|
+
SecretStr,
|
39
|
+
ValidationError,
|
40
|
+
)
|
41
|
+
from pydantic.fields import FieldInfo
|
15
42
|
|
16
|
-
__all__ = [
|
43
|
+
__all__ = [
|
44
|
+
"BaseModel",
|
45
|
+
"Field",
|
46
|
+
"FieldInfo",
|
47
|
+
"PrivateAttr",
|
48
|
+
"SecretStr",
|
49
|
+
"ConfigDict",
|
50
|
+
"ValidationError",
|
51
|
+
]
|