prefect-client 3.1.12__py3-none-any.whl → 3.1.13__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/_experimental/sla/client.py +53 -27
- prefect/_experimental/sla/objects.py +10 -2
- prefect/_internal/concurrency/services.py +2 -2
- prefect/_internal/concurrency/threads.py +6 -0
- prefect/_internal/retries.py +6 -3
- prefect/_internal/schemas/validators.py +6 -4
- prefect/_version.py +3 -3
- prefect/artifacts.py +4 -1
- prefect/automations.py +1 -1
- prefect/blocks/abstract.py +5 -2
- prefect/blocks/notifications.py +1 -0
- prefect/cache_policies.py +20 -20
- prefect/client/utilities.py +3 -3
- prefect/deployments/base.py +7 -4
- prefect/deployments/flow_runs.py +5 -1
- prefect/deployments/runner.py +6 -11
- prefect/deployments/steps/core.py +1 -1
- prefect/deployments/steps/pull.py +8 -3
- prefect/deployments/steps/utility.py +2 -2
- prefect/docker/docker_image.py +13 -9
- prefect/engine.py +19 -10
- prefect/events/cli/automations.py +4 -4
- prefect/events/clients.py +17 -14
- prefect/events/schemas/automations.py +12 -8
- prefect/events/schemas/events.py +5 -1
- prefect/events/worker.py +1 -1
- prefect/filesystems.py +1 -1
- prefect/flow_engine.py +17 -9
- prefect/flows.py +118 -73
- prefect/futures.py +14 -7
- prefect/infrastructure/provisioners/__init__.py +2 -0
- prefect/infrastructure/provisioners/cloud_run.py +4 -4
- prefect/infrastructure/provisioners/coiled.py +249 -0
- prefect/infrastructure/provisioners/container_instance.py +4 -3
- prefect/infrastructure/provisioners/ecs.py +55 -43
- prefect/infrastructure/provisioners/modal.py +5 -4
- prefect/input/actions.py +5 -1
- prefect/input/run_input.py +157 -43
- prefect/logging/configuration.py +3 -3
- prefect/logging/filters.py +2 -2
- prefect/logging/formatters.py +15 -11
- prefect/logging/handlers.py +24 -14
- prefect/logging/highlighters.py +5 -5
- prefect/logging/loggers.py +28 -18
- prefect/main.py +3 -1
- prefect/results.py +166 -86
- prefect/runner/runner.py +34 -27
- prefect/runner/server.py +3 -1
- prefect/runner/storage.py +18 -18
- prefect/runner/submit.py +19 -12
- prefect/runtime/deployment.py +15 -8
- prefect/runtime/flow_run.py +19 -6
- prefect/runtime/task_run.py +7 -3
- prefect/settings/base.py +17 -7
- prefect/settings/legacy.py +4 -4
- prefect/settings/models/api.py +4 -3
- prefect/settings/models/cli.py +4 -3
- prefect/settings/models/client.py +7 -4
- prefect/settings/models/cloud.py +4 -3
- prefect/settings/models/deployments.py +4 -3
- prefect/settings/models/experiments.py +4 -3
- prefect/settings/models/flows.py +4 -3
- prefect/settings/models/internal.py +4 -3
- prefect/settings/models/logging.py +8 -6
- prefect/settings/models/results.py +4 -3
- prefect/settings/models/root.py +11 -16
- prefect/settings/models/runner.py +8 -5
- prefect/settings/models/server/api.py +6 -3
- prefect/settings/models/server/database.py +120 -25
- prefect/settings/models/server/deployments.py +4 -3
- prefect/settings/models/server/ephemeral.py +7 -4
- prefect/settings/models/server/events.py +6 -3
- prefect/settings/models/server/flow_run_graph.py +4 -3
- prefect/settings/models/server/root.py +4 -3
- prefect/settings/models/server/services.py +15 -12
- prefect/settings/models/server/tasks.py +7 -4
- prefect/settings/models/server/ui.py +4 -3
- prefect/settings/models/tasks.py +10 -5
- prefect/settings/models/testing.py +4 -3
- prefect/settings/models/worker.py +7 -4
- prefect/settings/profiles.py +13 -12
- prefect/settings/sources.py +20 -19
- prefect/states.py +17 -13
- prefect/task_engine.py +43 -33
- prefect/task_runners.py +35 -23
- prefect/task_runs.py +20 -11
- prefect/task_worker.py +12 -7
- prefect/tasks.py +30 -24
- prefect/telemetry/bootstrap.py +4 -1
- prefect/telemetry/run_telemetry.py +15 -13
- prefect/transactions.py +3 -3
- prefect/types/__init__.py +3 -1
- prefect/utilities/_deprecated.py +38 -0
- prefect/utilities/engine.py +11 -4
- prefect/utilities/filesystem.py +2 -2
- prefect/utilities/generics.py +1 -1
- prefect/utilities/pydantic.py +21 -36
- prefect/workers/base.py +52 -30
- prefect/workers/process.py +20 -15
- prefect/workers/server.py +4 -5
- {prefect_client-3.1.12.dist-info → prefect_client-3.1.13.dist-info}/METADATA +2 -2
- {prefect_client-3.1.12.dist-info → prefect_client-3.1.13.dist-info}/RECORD +105 -103
- {prefect_client-3.1.12.dist-info → prefect_client-3.1.13.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.12.dist-info → prefect_client-3.1.13.dist-info}/WHEEL +0 -0
- {prefect_client-3.1.12.dist-info → prefect_client-3.1.13.dist-info}/top_level.txt +0 -0
prefect/settings/models/api.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import os
|
2
2
|
from typing import ClassVar, Optional
|
3
3
|
|
4
|
-
from pydantic import
|
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
|
-
|
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[
|
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.",
|
prefect/settings/models/cli.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
from typing import ClassVar, Optional
|
2
2
|
|
3
|
-
from pydantic import
|
3
|
+
from pydantic import Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
6
|
from prefect.settings.base import (
|
6
7
|
PrefectBaseSettings,
|
7
|
-
|
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[
|
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,
|
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
|
-
|
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[
|
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[
|
45
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("client",))
|
43
46
|
|
44
47
|
max_retries: int = Field(
|
45
48
|
default=5,
|
prefect/settings/models/cloud.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import re
|
2
2
|
from typing import ClassVar, Optional
|
3
3
|
|
4
|
-
from pydantic import
|
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
|
-
|
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[
|
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,
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
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[
|
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,
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
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[
|
14
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("experiments",))
|
14
15
|
|
15
16
|
warn: bool = Field(
|
16
17
|
default=True,
|
prefect/settings/models/flows.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
from typing import ClassVar, Union
|
2
2
|
|
3
|
-
from pydantic import AliasChoices, AliasPath,
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
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[
|
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,
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
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[
|
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,
|
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[
|
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[
|
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,
|
4
|
+
from pydantic import AliasChoices, AliasPath, Field
|
5
|
+
from pydantic_settings import SettingsConfigDict
|
5
6
|
|
6
|
-
from prefect.settings.base import PrefectBaseSettings,
|
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[
|
15
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("results",))
|
15
16
|
|
16
17
|
default_serializer: str = Field(
|
17
18
|
default="pickle",
|
prefect/settings/models/root.py
CHANGED
@@ -11,10 +11,11 @@ from typing import (
|
|
11
11
|
)
|
12
12
|
from urllib.parse import urlparse
|
13
13
|
|
14
|
-
from pydantic import BeforeValidator,
|
14
|
+
from pydantic import BeforeValidator, Field, SecretStr, model_validator
|
15
|
+
from pydantic_settings import SettingsConfigDict
|
15
16
|
from typing_extensions import Self
|
16
17
|
|
17
|
-
from prefect.settings.base import PrefectBaseSettings,
|
18
|
+
from prefect.settings.base import PrefectBaseSettings, build_settings_config
|
18
19
|
from prefect.settings.models.tasks import TasksSettings
|
19
20
|
from prefect.settings.models.testing import TestingSettings
|
20
21
|
from prefect.settings.models.worker import WorkerSettings
|
@@ -44,7 +45,7 @@ class Settings(PrefectBaseSettings):
|
|
44
45
|
See https://docs.pydantic.dev/latest/concepts/pydantic_settings
|
45
46
|
"""
|
46
47
|
|
47
|
-
model_config: ClassVar[
|
48
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config()
|
48
49
|
|
49
50
|
home: Annotated[Path, BeforeValidator(lambda x: Path(x).expanduser())] = Field(
|
50
51
|
default=Path("~") / ".prefect",
|
@@ -214,11 +215,7 @@ class Settings(PrefectBaseSettings):
|
|
214
215
|
if self.server.database.connection_url is None:
|
215
216
|
self.server.database.connection_url = _default_database_connection_url(self)
|
216
217
|
self.server.database.__pydantic_fields_set__.remove("connection_url")
|
217
|
-
db_url = (
|
218
|
-
self.server.database.connection_url.get_secret_value()
|
219
|
-
if isinstance(self.server.database.connection_url, SecretStr)
|
220
|
-
else self.server.database.connection_url
|
221
|
-
)
|
218
|
+
db_url = self.server.database.connection_url.get_secret_value()
|
222
219
|
if (
|
223
220
|
"PREFECT_API_DATABASE_PASSWORD" in db_url
|
224
221
|
or "PREFECT_SERVER_DATABASE_PASSWORD" in db_url
|
@@ -275,7 +272,7 @@ class Settings(PrefectBaseSettings):
|
|
275
272
|
# To restore defaults, we need to resolve the setting path and then
|
276
273
|
# set the default value on the new settings object. When restoring
|
277
274
|
# defaults, all settings sources will be ignored.
|
278
|
-
restore_defaults_obj = {}
|
275
|
+
restore_defaults_obj: dict[str, Any] = {}
|
279
276
|
for r in restore_defaults or []:
|
280
277
|
path = r.accessor.split(".")
|
281
278
|
model = self
|
@@ -301,11 +298,11 @@ class Settings(PrefectBaseSettings):
|
|
301
298
|
updates = updates or {}
|
302
299
|
set_defaults = set_defaults or {}
|
303
300
|
|
304
|
-
set_defaults_obj = {}
|
301
|
+
set_defaults_obj: dict[str, Any] = {}
|
305
302
|
for setting, value in set_defaults.items():
|
306
303
|
set_in_dict(set_defaults_obj, setting.accessor, value)
|
307
304
|
|
308
|
-
updates_obj = {}
|
305
|
+
updates_obj: dict[str, Any] = {}
|
309
306
|
for setting, value in updates.items():
|
310
307
|
set_in_dict(updates_obj, setting.accessor, value)
|
311
308
|
|
@@ -377,7 +374,7 @@ def _warn_on_misconfigured_api_url(settings: "Settings"):
|
|
377
374
|
"`PREFECT_API_URL` uses `/workspace/` but should use `/workspaces/`."
|
378
375
|
),
|
379
376
|
}
|
380
|
-
warnings_list = []
|
377
|
+
warnings_list: list[str] = []
|
381
378
|
|
382
379
|
for misconfig, warning in misconfigured_mappings.items():
|
383
380
|
if misconfig in api_url:
|
@@ -399,7 +396,7 @@ def _warn_on_misconfigured_api_url(settings: "Settings"):
|
|
399
396
|
|
400
397
|
|
401
398
|
def _default_database_connection_url(settings: "Settings") -> SecretStr:
|
402
|
-
value =
|
399
|
+
value: str = f"sqlite+aiosqlite:///{settings.home}/prefect.db"
|
403
400
|
if settings.server.database.driver == "postgresql+asyncpg":
|
404
401
|
required = [
|
405
402
|
"host",
|
@@ -417,7 +414,7 @@ def _default_database_connection_url(settings: "Settings") -> SecretStr:
|
|
417
414
|
|
418
415
|
from sqlalchemy import URL
|
419
416
|
|
420
|
-
|
417
|
+
value = URL(
|
421
418
|
drivername=settings.server.database.driver,
|
422
419
|
host=settings.server.database.host,
|
423
420
|
port=settings.server.database.port or 5432,
|
@@ -443,6 +440,4 @@ def _default_database_connection_url(settings: "Settings") -> SecretStr:
|
|
443
440
|
raise ValueError(
|
444
441
|
f"Unsupported database driver: {settings.server.database.driver}"
|
445
442
|
)
|
446
|
-
|
447
|
-
value = value if value else f"sqlite+aiosqlite:///{settings.home}/prefect.db"
|
448
443
|
return SecretStr(value)
|
@@ -1,8 +1,9 @@
|
|
1
1
|
from typing import ClassVar, Optional
|
2
2
|
|
3
|
-
from pydantic import
|
3
|
+
from pydantic import Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
6
|
+
from prefect.settings.base import PrefectBaseSettings, build_settings_config
|
6
7
|
from prefect.types import LogLevel
|
7
8
|
|
8
9
|
|
@@ -11,7 +12,9 @@ class RunnerServerSettings(PrefectBaseSettings):
|
|
11
12
|
Settings for controlling runner server behavior
|
12
13
|
"""
|
13
14
|
|
14
|
-
model_config: ClassVar[
|
15
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
16
|
+
("runner", "server")
|
17
|
+
)
|
15
18
|
|
16
19
|
enable: bool = Field(
|
17
20
|
default=False,
|
@@ -29,7 +32,7 @@ class RunnerServerSettings(PrefectBaseSettings):
|
|
29
32
|
)
|
30
33
|
|
31
34
|
log_level: LogLevel = Field(
|
32
|
-
default="
|
35
|
+
default="ERROR",
|
33
36
|
description="The log level of the runner's webserver.",
|
34
37
|
)
|
35
38
|
|
@@ -44,7 +47,7 @@ class RunnerSettings(PrefectBaseSettings):
|
|
44
47
|
Settings for controlling runner behavior
|
45
48
|
"""
|
46
49
|
|
47
|
-
model_config: ClassVar[
|
50
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("runner",))
|
48
51
|
|
49
52
|
process_limit: int = Field(
|
50
53
|
default=5,
|
@@ -1,9 +1,10 @@
|
|
1
1
|
from datetime import timedelta
|
2
2
|
from typing import ClassVar, Optional
|
3
3
|
|
4
|
-
from pydantic import AliasChoices, AliasPath,
|
4
|
+
from pydantic import AliasChoices, AliasPath, Field, SecretStr
|
5
|
+
from pydantic_settings import SettingsConfigDict
|
5
6
|
|
6
|
-
from prefect.settings.base import PrefectBaseSettings,
|
7
|
+
from prefect.settings.base import PrefectBaseSettings, build_settings_config
|
7
8
|
|
8
9
|
|
9
10
|
class ServerAPISettings(PrefectBaseSettings):
|
@@ -11,7 +12,9 @@ class ServerAPISettings(PrefectBaseSettings):
|
|
11
12
|
Settings for controlling API server behavior
|
12
13
|
"""
|
13
14
|
|
14
|
-
model_config: ClassVar[
|
15
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
16
|
+
("server", "api")
|
17
|
+
)
|
15
18
|
|
16
19
|
auth_string: Optional[SecretStr] = Field(
|
17
20
|
default=None,
|
@@ -1,18 +1,80 @@
|
|
1
1
|
import warnings
|
2
|
-
from typing import ClassVar, Optional
|
2
|
+
from typing import Any, ClassVar, Optional
|
3
3
|
from urllib.parse import quote_plus
|
4
4
|
|
5
5
|
from pydantic import (
|
6
6
|
AliasChoices,
|
7
7
|
AliasPath,
|
8
|
-
ConfigDict,
|
9
8
|
Field,
|
10
9
|
SecretStr,
|
11
10
|
model_validator,
|
12
11
|
)
|
12
|
+
from pydantic_settings import SettingsConfigDict
|
13
13
|
from typing_extensions import Literal, Self
|
14
14
|
|
15
|
-
from prefect.settings.base import PrefectBaseSettings,
|
15
|
+
from prefect.settings.base import PrefectBaseSettings, build_settings_config
|
16
|
+
|
17
|
+
|
18
|
+
class SQLAlchemyConnectArgsSettings(PrefectBaseSettings):
|
19
|
+
"""
|
20
|
+
Settings for controlling SQLAlchemy connection behavior; note that these settings only take effect when
|
21
|
+
using a PostgreSQL database.
|
22
|
+
"""
|
23
|
+
|
24
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
25
|
+
("server", "database", "sqlalchemy", "connect_args")
|
26
|
+
)
|
27
|
+
|
28
|
+
application_name: Optional[str] = Field(
|
29
|
+
default=None,
|
30
|
+
description="Controls the application_name field for connections opened from the connection pool when using a PostgreSQL database with the Prefect backend.",
|
31
|
+
)
|
32
|
+
|
33
|
+
|
34
|
+
class SQLAlchemySettings(PrefectBaseSettings):
|
35
|
+
"""
|
36
|
+
Settings for controlling SQLAlchemy behavior; note that these settings only take effect when
|
37
|
+
using a PostgreSQL database.
|
38
|
+
"""
|
39
|
+
|
40
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
41
|
+
("server", "database", "sqlalchemy")
|
42
|
+
)
|
43
|
+
|
44
|
+
connect_args: SQLAlchemyConnectArgsSettings = Field(
|
45
|
+
default_factory=SQLAlchemyConnectArgsSettings,
|
46
|
+
description="Settings for controlling SQLAlchemy connection behavior",
|
47
|
+
)
|
48
|
+
|
49
|
+
pool_size: int = Field(
|
50
|
+
default=5,
|
51
|
+
description="Controls connection pool size of database connection pools from the Prefect backend.",
|
52
|
+
validation_alias=AliasChoices(
|
53
|
+
AliasPath("pool_size"),
|
54
|
+
"prefect_server_database_sqlalchemy_pool_size",
|
55
|
+
"prefect_sqlalchemy_pool_size",
|
56
|
+
),
|
57
|
+
)
|
58
|
+
|
59
|
+
pool_recycle: int = Field(
|
60
|
+
default=3600,
|
61
|
+
description="This setting causes the pool to recycle connections after the given number of seconds has passed; set it to -1 to avoid recycling entirely.",
|
62
|
+
)
|
63
|
+
|
64
|
+
pool_timeout: Optional[float] = Field(
|
65
|
+
default=30.0,
|
66
|
+
description="Number of seconds to wait before giving up on getting a connection from the pool. Defaults to 30 seconds.",
|
67
|
+
)
|
68
|
+
|
69
|
+
max_overflow: int = Field(
|
70
|
+
default=10,
|
71
|
+
description="Controls maximum overflow of the connection pool. To prevent overflow, set to -1.",
|
72
|
+
validation_alias=AliasChoices(
|
73
|
+
AliasPath("max_overflow"),
|
74
|
+
"prefect_server_database_sqlalchemy_max_overflow",
|
75
|
+
"prefect_sqlalchemy_max_overflow",
|
76
|
+
),
|
77
|
+
)
|
16
78
|
|
17
79
|
|
18
80
|
class ServerDatabaseSettings(PrefectBaseSettings):
|
@@ -20,7 +82,14 @@ class ServerDatabaseSettings(PrefectBaseSettings):
|
|
20
82
|
Settings for controlling server database behavior
|
21
83
|
"""
|
22
84
|
|
23
|
-
model_config: ClassVar[
|
85
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
86
|
+
("server", "database")
|
87
|
+
)
|
88
|
+
|
89
|
+
sqlalchemy: SQLAlchemySettings = Field(
|
90
|
+
default_factory=SQLAlchemySettings,
|
91
|
+
description="Settings for controlling SQLAlchemy behavior",
|
92
|
+
)
|
24
93
|
|
25
94
|
connection_url: Optional[SecretStr] = Field(
|
26
95
|
default=None,
|
@@ -128,7 +197,7 @@ class ServerDatabaseSettings(PrefectBaseSettings):
|
|
128
197
|
|
129
198
|
timeout: Optional[float] = Field(
|
130
199
|
default=10.0,
|
131
|
-
description="A statement timeout, in seconds, applied to all database interactions made by the
|
200
|
+
description="A statement timeout, in seconds, applied to all database interactions made by the Prefect backend. Defaults to 10 seconds.",
|
132
201
|
validation_alias=AliasChoices(
|
133
202
|
AliasPath("timeout"),
|
134
203
|
"prefect_server_database_timeout",
|
@@ -146,25 +215,49 @@ class ServerDatabaseSettings(PrefectBaseSettings):
|
|
146
215
|
),
|
147
216
|
)
|
148
217
|
|
149
|
-
|
150
|
-
default=None,
|
151
|
-
description="Controls connection pool size when using a PostgreSQL database with the Prefect API. If not set, the default SQLAlchemy pool size will be used.",
|
152
|
-
validation_alias=AliasChoices(
|
153
|
-
AliasPath("sqlalchemy_pool_size"),
|
154
|
-
"prefect_server_database_sqlalchemy_pool_size",
|
155
|
-
"prefect_sqlalchemy_pool_size",
|
156
|
-
),
|
157
|
-
)
|
218
|
+
# handle deprecated fields
|
158
219
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
"
|
166
|
-
|
167
|
-
|
220
|
+
def __getattribute__(self, name: str) -> Any:
|
221
|
+
if name in ["sqlalchemy_pool_size", "sqlalchemy_max_overflow"]:
|
222
|
+
warnings.warn(
|
223
|
+
f"Setting {name} has been moved to the `sqlalchemy` settings group.",
|
224
|
+
DeprecationWarning,
|
225
|
+
)
|
226
|
+
field_name = name.replace("sqlalchemy_", "")
|
227
|
+
return getattr(super().__getattribute__("sqlalchemy"), field_name)
|
228
|
+
return super().__getattribute__(name)
|
229
|
+
|
230
|
+
# validators
|
231
|
+
|
232
|
+
@model_validator(mode="before")
|
233
|
+
@classmethod
|
234
|
+
def set_deprecated_sqlalchemy_settings_on_child_model_and_warn(
|
235
|
+
cls, values: dict[str, Any]
|
236
|
+
) -> dict[str, Any]:
|
237
|
+
"""
|
238
|
+
Set deprecated settings on the child model.
|
239
|
+
"""
|
240
|
+
# Initialize sqlalchemy settings if not present
|
241
|
+
if "sqlalchemy" not in values:
|
242
|
+
values["sqlalchemy"] = SQLAlchemySettings()
|
243
|
+
|
244
|
+
if "sqlalchemy_pool_size" in values:
|
245
|
+
warnings.warn(
|
246
|
+
"`sqlalchemy_pool_size` has been moved to the `sqlalchemy` settings group as `pool_size`.",
|
247
|
+
DeprecationWarning,
|
248
|
+
)
|
249
|
+
if "pool_size" not in values["sqlalchemy"].model_fields_set:
|
250
|
+
values["sqlalchemy"].pool_size = values["sqlalchemy_pool_size"]
|
251
|
+
|
252
|
+
if "sqlalchemy_max_overflow" in values:
|
253
|
+
warnings.warn(
|
254
|
+
"`sqlalchemy_max_overflow` has been moved to the `sqlalchemy` settings group as `max_overflow`.",
|
255
|
+
DeprecationWarning,
|
256
|
+
)
|
257
|
+
if "max_overflow" not in values["sqlalchemy"].model_fields_set:
|
258
|
+
values["sqlalchemy"].max_overflow = values["sqlalchemy_max_overflow"]
|
259
|
+
|
260
|
+
return values
|
168
261
|
|
169
262
|
@model_validator(mode="after")
|
170
263
|
def emit_warnings(self) -> Self: # noqa: F821
|
@@ -173,7 +266,9 @@ class ServerDatabaseSettings(PrefectBaseSettings):
|
|
173
266
|
return self
|
174
267
|
|
175
268
|
|
176
|
-
def warn_on_database_password_value_without_usage(
|
269
|
+
def warn_on_database_password_value_without_usage(
|
270
|
+
settings: ServerDatabaseSettings,
|
271
|
+
) -> None:
|
177
272
|
"""
|
178
273
|
Validator for settings warning if the database password is set but not used.
|
179
274
|
"""
|
@@ -201,4 +296,4 @@ def warn_on_database_password_value_without_usage(settings: ServerDatabaseSettin
|
|
201
296
|
"PREFECT_SERVER_DATABASE_CONNECTION_URL. "
|
202
297
|
"The provided password will be ignored."
|
203
298
|
)
|
204
|
-
return
|
299
|
+
return None
|
@@ -1,12 +1,13 @@
|
|
1
1
|
from typing import ClassVar
|
2
2
|
|
3
|
-
from pydantic import AliasChoices, AliasPath,
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
6
|
+
from prefect.settings.base import PrefectBaseSettings, build_settings_config
|
6
7
|
|
7
8
|
|
8
9
|
class ServerDeploymentsSettings(PrefectBaseSettings):
|
9
|
-
model_config: ClassVar[
|
10
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
10
11
|
("server", "deployments")
|
11
12
|
)
|
12
13
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
from typing import ClassVar
|
2
2
|
|
3
|
-
from pydantic import AliasChoices, AliasPath,
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
4
5
|
|
5
|
-
from prefect.settings.base import PrefectBaseSettings,
|
6
|
+
from prefect.settings.base import PrefectBaseSettings, build_settings_config
|
6
7
|
|
7
8
|
|
8
9
|
class ServerEphemeralSettings(PrefectBaseSettings):
|
@@ -10,7 +11,9 @@ class ServerEphemeralSettings(PrefectBaseSettings):
|
|
10
11
|
Settings for controlling ephemeral server behavior
|
11
12
|
"""
|
12
13
|
|
13
|
-
model_config: ClassVar[
|
14
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
15
|
+
("server", "ephemeral")
|
16
|
+
)
|
14
17
|
|
15
18
|
enabled: bool = Field(
|
16
19
|
default=False,
|
@@ -28,6 +31,6 @@ class ServerEphemeralSettings(PrefectBaseSettings):
|
|
28
31
|
default=20,
|
29
32
|
description="""
|
30
33
|
The number of seconds to wait for the server to start when ephemeral mode is enabled.
|
31
|
-
Defaults to `
|
34
|
+
Defaults to `20`.
|
32
35
|
""",
|
33
36
|
)
|