prefect-client 3.1.12__py3-none-any.whl → 3.1.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. prefect/_experimental/lineage.py +63 -0
  2. prefect/_experimental/sla/client.py +53 -27
  3. prefect/_experimental/sla/objects.py +10 -2
  4. prefect/_internal/concurrency/services.py +2 -2
  5. prefect/_internal/concurrency/threads.py +6 -0
  6. prefect/_internal/retries.py +6 -3
  7. prefect/_internal/schemas/validators.py +6 -4
  8. prefect/_version.py +3 -3
  9. prefect/artifacts.py +4 -1
  10. prefect/automations.py +1 -1
  11. prefect/blocks/abstract.py +5 -2
  12. prefect/blocks/notifications.py +1 -0
  13. prefect/cache_policies.py +70 -22
  14. prefect/client/orchestration/_automations/client.py +4 -0
  15. prefect/client/orchestration/_deployments/client.py +3 -3
  16. prefect/client/utilities.py +3 -3
  17. prefect/context.py +16 -6
  18. prefect/deployments/base.py +7 -4
  19. prefect/deployments/flow_runs.py +5 -1
  20. prefect/deployments/runner.py +6 -11
  21. prefect/deployments/steps/core.py +1 -1
  22. prefect/deployments/steps/pull.py +8 -3
  23. prefect/deployments/steps/utility.py +2 -2
  24. prefect/docker/docker_image.py +13 -9
  25. prefect/engine.py +19 -10
  26. prefect/events/cli/automations.py +4 -4
  27. prefect/events/clients.py +17 -14
  28. prefect/events/filters.py +34 -34
  29. prefect/events/schemas/automations.py +12 -8
  30. prefect/events/schemas/events.py +5 -1
  31. prefect/events/worker.py +1 -1
  32. prefect/filesystems.py +1 -1
  33. prefect/flow_engine.py +172 -123
  34. prefect/flows.py +119 -74
  35. prefect/futures.py +14 -7
  36. prefect/infrastructure/provisioners/__init__.py +2 -0
  37. prefect/infrastructure/provisioners/cloud_run.py +4 -4
  38. prefect/infrastructure/provisioners/coiled.py +249 -0
  39. prefect/infrastructure/provisioners/container_instance.py +4 -3
  40. prefect/infrastructure/provisioners/ecs.py +55 -43
  41. prefect/infrastructure/provisioners/modal.py +5 -4
  42. prefect/input/actions.py +5 -1
  43. prefect/input/run_input.py +157 -43
  44. prefect/logging/configuration.py +5 -8
  45. prefect/logging/filters.py +2 -2
  46. prefect/logging/formatters.py +15 -11
  47. prefect/logging/handlers.py +24 -14
  48. prefect/logging/highlighters.py +5 -5
  49. prefect/logging/loggers.py +29 -20
  50. prefect/main.py +3 -1
  51. prefect/results.py +166 -86
  52. prefect/runner/runner.py +112 -84
  53. prefect/runner/server.py +3 -1
  54. prefect/runner/storage.py +18 -18
  55. prefect/runner/submit.py +19 -12
  56. prefect/runtime/deployment.py +15 -8
  57. prefect/runtime/flow_run.py +19 -6
  58. prefect/runtime/task_run.py +7 -3
  59. prefect/settings/base.py +17 -7
  60. prefect/settings/legacy.py +4 -4
  61. prefect/settings/models/api.py +4 -3
  62. prefect/settings/models/cli.py +4 -3
  63. prefect/settings/models/client.py +7 -4
  64. prefect/settings/models/cloud.py +4 -3
  65. prefect/settings/models/deployments.py +4 -3
  66. prefect/settings/models/experiments.py +4 -3
  67. prefect/settings/models/flows.py +4 -3
  68. prefect/settings/models/internal.py +4 -3
  69. prefect/settings/models/logging.py +8 -6
  70. prefect/settings/models/results.py +4 -3
  71. prefect/settings/models/root.py +11 -16
  72. prefect/settings/models/runner.py +8 -5
  73. prefect/settings/models/server/api.py +6 -3
  74. prefect/settings/models/server/database.py +120 -25
  75. prefect/settings/models/server/deployments.py +4 -3
  76. prefect/settings/models/server/ephemeral.py +7 -4
  77. prefect/settings/models/server/events.py +6 -3
  78. prefect/settings/models/server/flow_run_graph.py +4 -3
  79. prefect/settings/models/server/root.py +4 -3
  80. prefect/settings/models/server/services.py +15 -12
  81. prefect/settings/models/server/tasks.py +7 -4
  82. prefect/settings/models/server/ui.py +4 -3
  83. prefect/settings/models/tasks.py +10 -5
  84. prefect/settings/models/testing.py +4 -3
  85. prefect/settings/models/worker.py +7 -4
  86. prefect/settings/profiles.py +13 -12
  87. prefect/settings/sources.py +20 -19
  88. prefect/states.py +17 -13
  89. prefect/task_engine.py +43 -33
  90. prefect/task_runners.py +35 -23
  91. prefect/task_runs.py +20 -11
  92. prefect/task_worker.py +12 -7
  93. prefect/tasks.py +67 -25
  94. prefect/telemetry/bootstrap.py +4 -1
  95. prefect/telemetry/run_telemetry.py +15 -13
  96. prefect/transactions.py +3 -3
  97. prefect/types/__init__.py +9 -6
  98. prefect/types/_datetime.py +19 -0
  99. prefect/utilities/_deprecated.py +38 -0
  100. prefect/utilities/engine.py +11 -4
  101. prefect/utilities/filesystem.py +2 -2
  102. prefect/utilities/generics.py +1 -1
  103. prefect/utilities/pydantic.py +21 -36
  104. prefect/workers/base.py +52 -30
  105. prefect/workers/process.py +20 -15
  106. prefect/workers/server.py +4 -5
  107. {prefect_client-3.1.12.dist-info → prefect_client-3.1.14.dist-info}/METADATA +2 -2
  108. {prefect_client-3.1.12.dist-info → prefect_client-3.1.14.dist-info}/RECORD +111 -108
  109. {prefect_client-3.1.12.dist-info → prefect_client-3.1.14.dist-info}/LICENSE +0 -0
  110. {prefect_client-3.1.12.dist-info → prefect_client-3.1.14.dist-info}/WHEEL +0 -0
  111. {prefect_client-3.1.12.dist-info → prefect_client-3.1.14.dist-info}/top_level.txt +0 -0
prefect/runner/submit.py CHANGED
@@ -1,11 +1,13 @@
1
+ from __future__ import annotations
2
+
1
3
  import asyncio
2
4
  import inspect
3
5
  import uuid
4
- from typing import Any, Dict, List, Optional, Union, overload
6
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, overload
5
7
 
6
8
  import anyio
7
9
  import httpx
8
- from typing_extensions import Literal
10
+ from typing_extensions import Literal, TypeAlias
9
11
 
10
12
  from prefect.client.orchestration import get_client
11
13
  from prefect.client.schemas.filters import FlowRunFilter, TaskRunFilter
@@ -22,12 +24,17 @@ from prefect.states import Pending
22
24
  from prefect.tasks import Task
23
25
  from prefect.utilities.asyncutils import sync_compatible
24
26
 
25
- logger = get_logger("webserver")
27
+ if TYPE_CHECKING:
28
+ import logging
29
+
30
+ logger: "logging.Logger" = get_logger("webserver")
31
+
32
+ FlowOrTask: TypeAlias = Union[Flow[Any, Any], Task[Any, Any]]
26
33
 
27
34
 
28
35
  async def _submit_flow_to_runner(
29
- flow: Flow,
30
- parameters: Dict[str, Any],
36
+ flow: Flow[Any, Any],
37
+ parameters: dict[str, Any],
31
38
  retry_failed_submissions: bool = True,
32
39
  ) -> FlowRun:
33
40
  """
@@ -91,7 +98,7 @@ async def _submit_flow_to_runner(
91
98
 
92
99
  @overload
93
100
  def submit_to_runner(
94
- prefect_callable: Union[Flow, Task],
101
+ prefect_callable: Union[Flow[Any, Any], Task[Any, Any]],
95
102
  parameters: Dict[str, Any],
96
103
  retry_failed_submissions: bool = True,
97
104
  ) -> FlowRun:
@@ -100,19 +107,19 @@ def submit_to_runner(
100
107
 
101
108
  @overload
102
109
  def submit_to_runner(
103
- prefect_callable: Union[Flow, Task],
104
- parameters: List[Dict[str, Any]],
110
+ prefect_callable: Union[Flow[Any, Any], Task[Any, Any]],
111
+ parameters: list[dict[str, Any]],
105
112
  retry_failed_submissions: bool = True,
106
- ) -> List[FlowRun]:
113
+ ) -> list[FlowRun]:
107
114
  ...
108
115
 
109
116
 
110
117
  @sync_compatible
111
118
  async def submit_to_runner(
112
- prefect_callable: Union[Flow, Task],
113
- parameters: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,
119
+ prefect_callable: FlowOrTask,
120
+ parameters: Optional[Union[dict[str, Any], list[dict[str, Any]]]] = None,
114
121
  retry_failed_submissions: bool = True,
115
- ) -> Union[FlowRun, List[FlowRun]]:
122
+ ) -> Union[FlowRun, list[FlowRun]]:
116
123
  """
117
124
  Submit a callable in the background via the runner webserver one or more times.
118
125
 
@@ -25,8 +25,10 @@ Available attributes:
25
25
  object or those directly provided via API for this run
26
26
  """
27
27
 
28
+ from __future__ import annotations
29
+
28
30
  import os
29
- from typing import Any, Dict, List, Optional
31
+ from typing import TYPE_CHECKING, Any, Callable, List, Optional
30
32
 
31
33
  from prefect._internal.concurrency.api import create_call, from_sync
32
34
  from prefect.client.orchestration import get_client
@@ -34,12 +36,17 @@ from prefect.context import FlowRunContext
34
36
 
35
37
  from .flow_run import _get_flow_run
36
38
 
39
+ if TYPE_CHECKING:
40
+ from prefect.client.schemas.responses import DeploymentResponse
41
+
37
42
  __all__ = ["id", "flow_run_id", "name", "parameters", "version"]
38
43
 
39
- CACHED_DEPLOYMENT = {}
44
+ CACHED_DEPLOYMENT: dict[str, "DeploymentResponse"] = {}
40
45
 
41
46
 
42
- type_cast = {
47
+ type_cast: dict[
48
+ type[bool] | type[int] | type[float] | type[str] | type[None], Callable[[Any], Any]
49
+ ] = {
43
50
  bool: lambda x: x.lower() == "true",
44
51
  int: int,
45
52
  float: float,
@@ -88,7 +95,7 @@ def __dir__() -> List[str]:
88
95
  return sorted(__all__)
89
96
 
90
97
 
91
- async def _get_deployment(deployment_id):
98
+ async def _get_deployment(deployment_id: str) -> "DeploymentResponse":
92
99
  # deployments won't change between calls so let's avoid the lifecycle of a client
93
100
  if CACHED_DEPLOYMENT.get(deployment_id):
94
101
  return CACHED_DEPLOYMENT[deployment_id]
@@ -115,7 +122,7 @@ def get_id() -> Optional[str]:
115
122
  return str(deployment_id)
116
123
 
117
124
 
118
- def get_parameters() -> Dict:
125
+ def get_parameters() -> dict[str, Any]:
119
126
  run_id = get_flow_run_id()
120
127
  if run_id is None:
121
128
  return {}
@@ -126,7 +133,7 @@ def get_parameters() -> Dict:
126
133
  return flow_run.parameters or {}
127
134
 
128
135
 
129
- def get_name() -> Optional[Dict]:
136
+ def get_name() -> Optional[str]:
130
137
  dep_id = get_id()
131
138
 
132
139
  if dep_id is None:
@@ -138,7 +145,7 @@ def get_name() -> Optional[Dict]:
138
145
  return deployment.name
139
146
 
140
147
 
141
- def get_version() -> Optional[Dict]:
148
+ def get_version() -> Optional[str]:
142
149
  dep_id = get_id()
143
150
 
144
151
  if dep_id is None:
@@ -154,7 +161,7 @@ def get_flow_run_id() -> Optional[str]:
154
161
  return os.getenv("PREFECT__FLOW_RUN_ID")
155
162
 
156
163
 
157
- FIELDS = {
164
+ FIELDS: dict[str, Callable[[], Any]] = {
158
165
  "id": get_id,
159
166
  "flow_run_id": get_flow_run_id,
160
167
  "parameters": get_parameters,
@@ -20,8 +20,10 @@ Available attributes:
20
20
  - `run_count`: the number of times this flow run has been run
21
21
  """
22
22
 
23
+ from __future__ import annotations
24
+
23
25
  import os
24
- from typing import Any, Dict, List, Optional
26
+ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional
25
27
 
26
28
  import pendulum
27
29
 
@@ -30,6 +32,9 @@ from prefect.client.orchestration import get_client
30
32
  from prefect.context import FlowRunContext, TaskRunContext
31
33
  from prefect.settings import PREFECT_API_URL, PREFECT_UI_URL
32
34
 
35
+ if TYPE_CHECKING:
36
+ from prefect.client.schemas.objects import Flow, FlowRun, TaskRun
37
+
33
38
  __all__ = [
34
39
  "id",
35
40
  "tags",
@@ -56,7 +61,15 @@ def _pendulum_parse(dt: str) -> pendulum.DateTime:
56
61
  return pendulum.parse(dt, tz=None, strict=False).set(tz="UTC")
57
62
 
58
63
 
59
- type_cast = {
64
+ type_cast: dict[
65
+ type[bool]
66
+ | type[int]
67
+ | type[float]
68
+ | type[str]
69
+ | type[None]
70
+ | type[pendulum.DateTime],
71
+ Callable[[Any], Any],
72
+ ] = {
60
73
  bool: lambda x: x.lower() == "true",
61
74
  int: int,
62
75
  float: float,
@@ -106,17 +119,17 @@ def __dir__() -> List[str]:
106
119
  return sorted(__all__)
107
120
 
108
121
 
109
- async def _get_flow_run(flow_run_id):
122
+ async def _get_flow_run(flow_run_id: str) -> "FlowRun":
110
123
  async with get_client() as client:
111
124
  return await client.read_flow_run(flow_run_id)
112
125
 
113
126
 
114
- async def _get_task_run(task_run_id):
127
+ async def _get_task_run(task_run_id: str) -> "TaskRun":
115
128
  async with get_client() as client:
116
129
  return await client.read_task_run(task_run_id)
117
130
 
118
131
 
119
- async def _get_flow_from_run(flow_run_id):
132
+ async def _get_flow_from_run(flow_run_id: str) -> "Flow":
120
133
  async with get_client() as client:
121
134
  flow_run = await client.read_flow_run(flow_run_id)
122
135
  return await client.read_flow(flow_run.flow_id)
@@ -323,7 +336,7 @@ def get_job_variables() -> Optional[Dict[str, Any]]:
323
336
  return flow_run_ctx.flow_run.job_variables if flow_run_ctx else None
324
337
 
325
338
 
326
- FIELDS = {
339
+ FIELDS: dict[str, Callable[[], Any]] = {
327
340
  "id": get_id,
328
341
  "tags": get_tags,
329
342
  "scheduled_start_time": get_scheduled_start_time,
@@ -15,15 +15,19 @@ Available attributes:
15
15
  - `task_name`: the name of the task
16
16
  """
17
17
 
18
+ from __future__ import annotations
19
+
18
20
  import os
19
- from typing import Any, Dict, List, Optional
21
+ from typing import Any, Callable, Dict, List, Optional
20
22
 
21
23
  from prefect.context import TaskRunContext
22
24
 
23
25
  __all__ = ["id", "tags", "name", "parameters", "run_count", "task_name"]
24
26
 
25
27
 
26
- type_cast = {
28
+ type_cast: dict[
29
+ type[bool] | type[int] | type[float] | type[str] | type[None], Callable[[Any], Any]
30
+ ] = {
27
31
  bool: lambda x: x.lower() == "true",
28
32
  int: int,
29
33
  float: float,
@@ -118,7 +122,7 @@ def get_parameters() -> Dict[str, Any]:
118
122
  return {}
119
123
 
120
124
 
121
- FIELDS = {
125
+ FIELDS: dict[str, Callable[[], Any]] = {
122
126
  "id": get_id,
123
127
  "tags": get_tags,
124
128
  "name": get_name,
prefect/settings/base.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import inspect
2
4
  from functools import partial
3
5
  from typing import Any, Dict, Tuple, Type
@@ -43,13 +45,17 @@ class PrefectBaseSettings(BaseSettings):
43
45
 
44
46
  See https://docs.pydantic.dev/latest/concepts/pydantic_settings/#customise-settings-sources
45
47
  """
46
- env_filter = set()
48
+ env_filter: set[str] = set()
47
49
  for field_name, field in settings_cls.model_fields.items():
48
50
  if field.validation_alias is not None and isinstance(
49
51
  field.validation_alias, AliasChoices
50
52
  ):
51
53
  for alias in field.validation_alias.choices:
52
- if isinstance(alias, AliasPath) and len(alias.path) > 0:
54
+ if (
55
+ isinstance(alias, AliasPath)
56
+ and len(alias.path) > 0
57
+ and isinstance(alias.path[0], str)
58
+ ):
53
59
  env_filter.add(alias.path[0])
54
60
  env_filter.add(field_name)
55
61
  return (
@@ -88,13 +94,12 @@ class PrefectBaseSettings(BaseSettings):
88
94
  include_secrets: bool = True,
89
95
  ) -> Dict[str, str]:
90
96
  """Convert the settings object to a dictionary of environment variables."""
91
-
92
97
  env: Dict[str, Any] = self.model_dump(
93
98
  exclude_unset=exclude_unset,
94
99
  mode="json",
95
100
  context={"include_secrets": include_secrets},
96
101
  )
97
- env_variables = {}
102
+ env_variables: dict[str, str] = {}
98
103
  for key in self.model_fields.keys():
99
104
  if isinstance(child_settings := getattr(self, key), PrefectBaseSettings):
100
105
  child_env = child_settings.to_environment_variables(
@@ -175,7 +180,7 @@ def _add_environment_variables(
175
180
  schema: Dict[str, Any], model: Type[PrefectBaseSettings]
176
181
  ) -> None:
177
182
  for property in schema["properties"]:
178
- env_vars = []
183
+ env_vars: list[str] = []
179
184
  schema["properties"][property]["supported_environment_variables"] = env_vars
180
185
  field = model.model_fields[property]
181
186
  if inspect.isclass(field.annotation) and issubclass(
@@ -191,7 +196,7 @@ def _add_environment_variables(
191
196
  env_vars.append(f"{model.model_config.get('env_prefix')}{property.upper()}")
192
197
 
193
198
 
194
- def _build_settings_config(
199
+ def build_settings_config(
195
200
  path: Tuple[str, ...] = tuple(), frozen: bool = False
196
201
  ) -> PrefectSettingsConfigDict:
197
202
  env_prefix = f"PREFECT_{'_'.join(path).upper()}_" if path else "PREFECT_"
@@ -207,7 +212,12 @@ def _build_settings_config(
207
212
  )
208
213
 
209
214
 
210
- def _to_environment_variable_value(value: Any) -> str:
215
+ _build_settings_config = build_settings_config # noqa # TODO: remove once all usage updated
216
+
217
+
218
+ def _to_environment_variable_value(
219
+ value: list[object] | set[object] | tuple[object] | Any,
220
+ ) -> str:
211
221
  if isinstance(value, (list, set, tuple)):
212
222
  return ",".join(str(v) for v in value)
213
223
  return str(value)
@@ -28,11 +28,11 @@ class Setting:
28
28
  self.accessor: str = accessor
29
29
 
30
30
  @property
31
- def name(self):
31
+ def name(self) -> str:
32
32
  return self._name
33
33
 
34
34
  @property
35
- def is_secret(self):
35
+ def is_secret(self) -> bool:
36
36
  if self._type in _SECRET_TYPES:
37
37
  return True
38
38
  for secret_type in _SECRET_TYPES:
@@ -40,7 +40,7 @@ class Setting:
40
40
  return True
41
41
  return False
42
42
 
43
- def default(self):
43
+ def default(self) -> Any:
44
44
  return self._default
45
45
 
46
46
  def value(self: Self) -> Any:
@@ -123,7 +123,7 @@ def _get_settings_fields(
123
123
  settings: Type[BaseSettings], accessor_prefix: Optional[str] = None
124
124
  ) -> Dict[str, "Setting"]:
125
125
  """Get the settings fields for the settings object"""
126
- settings_fields: Dict[str, Setting] = {}
126
+ settings_fields: dict[str, Setting] = {}
127
127
  for field_name, field in settings.model_fields.items():
128
128
  if inspect.isclass(field.annotation) and issubclass(
129
129
  field.annotation, PrefectBaseSettings
@@ -1,11 +1,12 @@
1
1
  import os
2
2
  from typing import ClassVar, Optional
3
3
 
4
- from pydantic import ConfigDict, Field, SecretStr
4
+ from pydantic import Field, SecretStr
5
+ from pydantic_settings import SettingsConfigDict
5
6
 
6
7
  from prefect.settings.base import (
7
8
  PrefectBaseSettings,
8
- _build_settings_config,
9
+ build_settings_config,
9
10
  )
10
11
 
11
12
 
@@ -14,7 +15,7 @@ class APISettings(PrefectBaseSettings):
14
15
  Settings for interacting with the Prefect API
15
16
  """
16
17
 
17
- model_config: ClassVar[ConfigDict] = _build_settings_config(("api",))
18
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("api",))
18
19
  url: Optional[str] = Field(
19
20
  default=None,
20
21
  description="The URL of the Prefect API. If not set, the client will attempt to infer it.",
@@ -1,10 +1,11 @@
1
1
  from typing import ClassVar, Optional
2
2
 
3
- from pydantic import ConfigDict, Field
3
+ from pydantic import Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
6
  from prefect.settings.base import (
6
7
  PrefectBaseSettings,
7
- _build_settings_config,
8
+ build_settings_config,
8
9
  )
9
10
 
10
11
 
@@ -13,7 +14,7 @@ class CLISettings(PrefectBaseSettings):
13
14
  Settings for controlling CLI behavior
14
15
  """
15
16
 
16
- model_config: ClassVar[ConfigDict] = _build_settings_config(("cli",))
17
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("cli",))
17
18
 
18
19
  colors: bool = Field(
19
20
  default=True,
@@ -1,10 +1,11 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
6
  from prefect.settings.base import (
6
7
  PrefectBaseSettings,
7
- _build_settings_config,
8
+ build_settings_config,
8
9
  )
9
10
  from prefect.types import ClientRetryExtraCodes
10
11
 
@@ -14,7 +15,9 @@ class ClientMetricsSettings(PrefectBaseSettings):
14
15
  Settings for controlling metrics reporting from the client
15
16
  """
16
17
 
17
- model_config: ClassVar[ConfigDict] = _build_settings_config(("client", "metrics"))
18
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
19
+ ("client", "metrics")
20
+ )
18
21
 
19
22
  enabled: bool = Field(
20
23
  default=False,
@@ -39,7 +42,7 @@ class ClientSettings(PrefectBaseSettings):
39
42
  Settings for controlling API client behavior
40
43
  """
41
44
 
42
- model_config: ClassVar[ConfigDict] = _build_settings_config(("client",))
45
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("client",))
43
46
 
44
47
  max_retries: int = Field(
45
48
  default=5,
@@ -1,12 +1,13 @@
1
1
  import re
2
2
  from typing import ClassVar, Optional
3
3
 
4
- from pydantic import ConfigDict, Field, model_validator
4
+ from pydantic import Field, model_validator
5
+ from pydantic_settings import SettingsConfigDict
5
6
  from typing_extensions import Self
6
7
 
7
8
  from prefect.settings.base import (
8
9
  PrefectBaseSettings,
9
- _build_settings_config,
10
+ build_settings_config,
10
11
  )
11
12
 
12
13
 
@@ -32,7 +33,7 @@ class CloudSettings(PrefectBaseSettings):
32
33
  Settings for interacting with Prefect Cloud
33
34
  """
34
35
 
35
- model_config: ClassVar[ConfigDict] = _build_settings_config(("cloud",))
36
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("cloud",))
36
37
 
37
38
  api_url: str = Field(
38
39
  default="https://api.prefect.cloud/api",
@@ -1,8 +1,9 @@
1
1
  from typing import ClassVar, Optional
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class DeploymentsSettings(PrefectBaseSettings):
@@ -10,7 +11,7 @@ class DeploymentsSettings(PrefectBaseSettings):
10
11
  Settings for configuring deployments defaults
11
12
  """
12
13
 
13
- model_config: ClassVar[ConfigDict] = _build_settings_config(("deployments",))
14
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("deployments",))
14
15
 
15
16
  default_work_pool_name: Optional[str] = Field(
16
17
  default=None,
@@ -1,8 +1,9 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class ExperimentsSettings(PrefectBaseSettings):
@@ -10,7 +11,7 @@ class ExperimentsSettings(PrefectBaseSettings):
10
11
  Settings for configuring experimental features
11
12
  """
12
13
 
13
- model_config: ClassVar[ConfigDict] = _build_settings_config(("experiments",))
14
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("experiments",))
14
15
 
15
16
  warn: bool = Field(
16
17
  default=True,
@@ -1,8 +1,9 @@
1
1
  from typing import ClassVar, Union
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class FlowsSettings(PrefectBaseSettings):
@@ -10,7 +11,7 @@ class FlowsSettings(PrefectBaseSettings):
10
11
  Settings for controlling flow behavior
11
12
  """
12
13
 
13
- model_config: ClassVar[ConfigDict] = _build_settings_config(("flows",))
14
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("flows",))
14
15
 
15
16
  default_retries: int = Field(
16
17
  default=0,
@@ -1,13 +1,14 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
  from prefect.types import LogLevel
7
8
 
8
9
 
9
10
  class InternalSettings(PrefectBaseSettings):
10
- model_config: ClassVar[ConfigDict] = _build_settings_config(("internal",))
11
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("internal",))
11
12
 
12
13
  logging_level: LogLevel = Field(
13
14
  default="ERROR",
@@ -1,22 +1,22 @@
1
1
  from functools import partial
2
2
  from pathlib import Path
3
- from typing import Annotated, ClassVar, Literal, Optional, Union
3
+ from typing import Annotated, Any, ClassVar, Literal, Optional, Union
4
4
 
5
5
  from pydantic import (
6
6
  AliasChoices,
7
7
  AliasPath,
8
8
  BeforeValidator,
9
- ConfigDict,
10
9
  Field,
11
10
  model_validator,
12
11
  )
12
+ from pydantic_settings import SettingsConfigDict
13
13
  from typing_extensions import Self
14
14
 
15
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
15
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
16
16
  from prefect.types import LogLevel, validate_set_T_from_delim_string
17
17
 
18
18
 
19
- def max_log_size_smaller_than_batch_size(values):
19
+ def max_log_size_smaller_than_batch_size(values: dict[str, Any]) -> dict[str, Any]:
20
20
  """
21
21
  Validator for settings asserting the batch size and match log size are compatible
22
22
  """
@@ -33,7 +33,9 @@ class LoggingToAPISettings(PrefectBaseSettings):
33
33
  Settings for controlling logging to the API
34
34
  """
35
35
 
36
- model_config: ClassVar[ConfigDict] = _build_settings_config(("logging", "to_api"))
36
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
37
+ ("logging", "to_api")
38
+ )
37
39
 
38
40
  enabled: bool = Field(
39
41
  default=True,
@@ -86,7 +88,7 @@ class LoggingSettings(PrefectBaseSettings):
86
88
  Settings for controlling logging behavior
87
89
  """
88
90
 
89
- model_config: ClassVar[ConfigDict] = _build_settings_config(("logging",))
91
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("logging",))
90
92
 
91
93
  level: LogLevel = Field(
92
94
  default="INFO",
@@ -1,9 +1,10 @@
1
1
  from pathlib import Path
2
2
  from typing import ClassVar, Optional
3
3
 
4
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
4
+ from pydantic import AliasChoices, AliasPath, Field
5
+ from pydantic_settings import SettingsConfigDict
5
6
 
6
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
7
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
7
8
 
8
9
 
9
10
  class ResultsSettings(PrefectBaseSettings):
@@ -11,7 +12,7 @@ class ResultsSettings(PrefectBaseSettings):
11
12
  Settings for controlling result storage behavior
12
13
  """
13
14
 
14
- model_config: ClassVar[ConfigDict] = _build_settings_config(("results",))
15
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("results",))
15
16
 
16
17
  default_serializer: str = Field(
17
18
  default="pickle",