prefect-client 3.0.10__py3-none-any.whl → 3.0.11__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 +17 -14
- prefect/_internal/schemas/bases.py +1 -0
- prefect/_internal/schemas/validators.py +5 -3
- prefect/_version.py +3 -3
- prefect/client/cloud.py +2 -2
- prefect/client/orchestration.py +4 -4
- prefect/client/schemas/filters.py +14 -0
- prefect/context.py +3 -2
- prefect/deployments/runner.py +15 -6
- prefect/events/schemas/automations.py +3 -3
- prefect/events/schemas/deployment_triggers.py +10 -5
- prefect/flow_engine.py +4 -4
- prefect/flows.py +24 -9
- prefect/futures.py +4 -4
- prefect/logging/handlers.py +1 -1
- prefect/logging/highlighters.py +2 -0
- prefect/logging/logging.yml +82 -83
- prefect/runner/runner.py +1 -2
- prefect/runner/server.py +12 -1
- prefect/settings/__init__.py +59 -0
- prefect/settings/base.py +131 -0
- prefect/settings/constants.py +8 -0
- prefect/settings/context.py +65 -0
- prefect/settings/legacy.py +167 -0
- prefect/settings/models/__init__.py +0 -0
- prefect/settings/models/api.py +41 -0
- prefect/settings/models/cli.py +31 -0
- prefect/settings/models/client.py +90 -0
- prefect/settings/models/cloud.py +58 -0
- prefect/settings/models/deployments.py +40 -0
- prefect/settings/models/flows.py +37 -0
- prefect/settings/models/internal.py +21 -0
- prefect/settings/models/logging.py +137 -0
- prefect/settings/models/results.py +47 -0
- prefect/settings/models/root.py +447 -0
- prefect/settings/models/runner.py +65 -0
- prefect/settings/models/server/__init__.py +1 -0
- prefect/settings/models/server/api.py +133 -0
- prefect/settings/models/server/database.py +202 -0
- prefect/settings/models/server/deployments.py +24 -0
- prefect/settings/models/server/ephemeral.py +34 -0
- prefect/settings/models/server/events.py +140 -0
- prefect/settings/models/server/flow_run_graph.py +34 -0
- prefect/settings/models/server/root.py +143 -0
- prefect/settings/models/server/services.py +485 -0
- prefect/settings/models/server/tasks.py +86 -0
- prefect/settings/models/server/ui.py +52 -0
- prefect/settings/models/tasks.py +91 -0
- prefect/settings/models/testing.py +52 -0
- prefect/settings/models/ui.py +0 -0
- prefect/settings/models/worker.py +46 -0
- prefect/settings/profiles.py +390 -0
- prefect/settings/sources.py +162 -0
- prefect/task_engine.py +24 -29
- prefect/task_runners.py +6 -1
- prefect/tasks.py +63 -28
- prefect/utilities/asyncutils.py +1 -1
- prefect/utilities/engine.py +11 -3
- prefect/utilities/services.py +3 -3
- prefect/workers/base.py +8 -2
- {prefect_client-3.0.10.dist-info → prefect_client-3.0.11.dist-info}/METADATA +2 -2
- {prefect_client-3.0.10.dist-info → prefect_client-3.0.11.dist-info}/RECORD +66 -33
- prefect/settings.py +0 -2172
- /prefect/{profiles.toml → settings/profiles.toml} +0 -0
- {prefect_client-3.0.10.dist-info → prefect_client-3.0.11.dist-info}/LICENSE +0 -0
- {prefect_client-3.0.10.dist-info → prefect_client-3.0.11.dist-info}/WHEEL +0 -0
- {prefect_client-3.0.10.dist-info → prefect_client-3.0.11.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
import re
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
from pydantic import Field, model_validator
|
5
|
+
from pydantic_settings import SettingsConfigDict
|
6
|
+
from typing_extensions import Self
|
7
|
+
|
8
|
+
from prefect.settings.base import PrefectBaseSettings
|
9
|
+
|
10
|
+
|
11
|
+
def default_cloud_ui_url(settings: "CloudSettings") -> Optional[str]:
|
12
|
+
value = settings.ui_url
|
13
|
+
if value is not None:
|
14
|
+
return value
|
15
|
+
|
16
|
+
# Otherwise, infer a value from the API URL
|
17
|
+
ui_url = api_url = settings.api_url
|
18
|
+
|
19
|
+
if re.match(r"^https://api[\.\w]*.prefect.[^\.]+/", api_url):
|
20
|
+
ui_url = ui_url.replace("https://api", "https://app", 1)
|
21
|
+
|
22
|
+
if ui_url.endswith("/api"):
|
23
|
+
ui_url = ui_url[:-4]
|
24
|
+
|
25
|
+
return ui_url
|
26
|
+
|
27
|
+
|
28
|
+
class CloudSettings(PrefectBaseSettings):
|
29
|
+
"""
|
30
|
+
Settings for interacting with Prefect Cloud
|
31
|
+
"""
|
32
|
+
|
33
|
+
model_config = SettingsConfigDict(
|
34
|
+
env_prefix="PREFECT_CLOUD_", env_file=".env", extra="ignore"
|
35
|
+
)
|
36
|
+
|
37
|
+
api_url: str = Field(
|
38
|
+
default="https://api.prefect.cloud/api",
|
39
|
+
description="API URL for Prefect Cloud. Used for authentication with Prefect Cloud.",
|
40
|
+
)
|
41
|
+
|
42
|
+
ui_url: Optional[str] = Field(
|
43
|
+
default=None,
|
44
|
+
description="The URL of the Prefect Cloud UI. If not set, the client will attempt to infer it.",
|
45
|
+
)
|
46
|
+
|
47
|
+
@model_validator(mode="after")
|
48
|
+
def post_hoc_settings(self) -> Self:
|
49
|
+
"""refactor on resolution of https://github.com/pydantic/pydantic/issues/9789
|
50
|
+
|
51
|
+
we should not be modifying __pydantic_fields_set__ directly, but until we can
|
52
|
+
define dependencies between defaults in a first-class way, we need clean up
|
53
|
+
post-hoc default assignments to keep set/unset fields correct after instantiation.
|
54
|
+
"""
|
55
|
+
if self.ui_url is None:
|
56
|
+
self.ui_url = default_cloud_ui_url(self)
|
57
|
+
self.__pydantic_fields_set__.remove("ui_url")
|
58
|
+
return self
|
@@ -0,0 +1,40 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
5
|
+
|
6
|
+
from prefect.settings.base import PrefectBaseSettings
|
7
|
+
|
8
|
+
|
9
|
+
class DeploymentsSettings(PrefectBaseSettings):
|
10
|
+
"""
|
11
|
+
Settings for configuring deployments defaults
|
12
|
+
"""
|
13
|
+
|
14
|
+
model_config = SettingsConfigDict(
|
15
|
+
env_prefix="PREFECT_DEPLOYMENTS_", env_file=".env", extra="ignore"
|
16
|
+
)
|
17
|
+
|
18
|
+
default_work_pool_name: Optional[str] = Field(
|
19
|
+
default=None,
|
20
|
+
description="The default work pool to use when creating deployments.",
|
21
|
+
validation_alias=AliasChoices(
|
22
|
+
AliasPath("default_work_pool_name"),
|
23
|
+
"prefect_deployments_default_work_pool_name",
|
24
|
+
"prefect_default_work_pool_name",
|
25
|
+
),
|
26
|
+
)
|
27
|
+
|
28
|
+
default_docker_build_namespace: Optional[str] = Field(
|
29
|
+
default=None,
|
30
|
+
description="The default Docker namespace to use when building images.",
|
31
|
+
validation_alias=AliasChoices(
|
32
|
+
AliasPath("default_docker_build_namespace"),
|
33
|
+
"prefect_deployments_default_docker_build_namespace",
|
34
|
+
"prefect_default_docker_build_namespace",
|
35
|
+
),
|
36
|
+
examples=[
|
37
|
+
"my-dockerhub-registry",
|
38
|
+
"4999999999999.dkr.ecr.us-east-2.amazonaws.com/my-ecr-repo",
|
39
|
+
],
|
40
|
+
)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
from typing import Union
|
2
|
+
|
3
|
+
from pydantic import AliasChoices, AliasPath, Field
|
4
|
+
from pydantic_settings import SettingsConfigDict
|
5
|
+
|
6
|
+
from prefect.settings.base import PrefectBaseSettings
|
7
|
+
|
8
|
+
|
9
|
+
class FlowsSettings(PrefectBaseSettings):
|
10
|
+
"""
|
11
|
+
Settings for controlling flow behavior
|
12
|
+
"""
|
13
|
+
|
14
|
+
model_config = SettingsConfigDict(
|
15
|
+
env_prefix="PREFECT_FLOWS_", env_file=".env", extra="ignore"
|
16
|
+
)
|
17
|
+
|
18
|
+
default_retries: int = Field(
|
19
|
+
default=0,
|
20
|
+
ge=0,
|
21
|
+
description="This value sets the default number of retries for all flows.",
|
22
|
+
validation_alias=AliasChoices(
|
23
|
+
AliasPath("default_retries"),
|
24
|
+
"prefect_flows_default_retries",
|
25
|
+
"prefect_flow_default_retries",
|
26
|
+
),
|
27
|
+
)
|
28
|
+
|
29
|
+
default_retry_delay_seconds: Union[int, float, list[float]] = Field(
|
30
|
+
default=0,
|
31
|
+
description="This value sets the default retry delay seconds for all flows.",
|
32
|
+
validation_alias=AliasChoices(
|
33
|
+
AliasPath("default_retry_delay_seconds"),
|
34
|
+
"prefect_flows_default_retry_delay_seconds",
|
35
|
+
"prefect_flow_default_retry_delay_seconds",
|
36
|
+
),
|
37
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from pydantic import AliasChoices, AliasPath, Field
|
2
|
+
from pydantic_settings import SettingsConfigDict
|
3
|
+
|
4
|
+
from prefect.settings.base import PrefectBaseSettings
|
5
|
+
from prefect.types import LogLevel
|
6
|
+
|
7
|
+
|
8
|
+
class InternalSettings(PrefectBaseSettings):
|
9
|
+
model_config = SettingsConfigDict(
|
10
|
+
env_prefix="PREFECT_INTERNAL_", env_file=".env", extra="ignore"
|
11
|
+
)
|
12
|
+
|
13
|
+
logging_level: LogLevel = Field(
|
14
|
+
default="ERROR",
|
15
|
+
description="The default logging level for Prefect's internal machinery loggers.",
|
16
|
+
validation_alias=AliasChoices(
|
17
|
+
AliasPath("logging_level"),
|
18
|
+
"prefect_internal_logging_level",
|
19
|
+
"prefect_logging_internal_level",
|
20
|
+
),
|
21
|
+
)
|
@@ -0,0 +1,137 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Annotated, Literal, Optional, Union
|
3
|
+
|
4
|
+
from pydantic import AfterValidator, AliasChoices, AliasPath, Field, model_validator
|
5
|
+
from pydantic_settings import SettingsConfigDict
|
6
|
+
from typing_extensions import Self
|
7
|
+
|
8
|
+
from prefect.settings.base import PrefectBaseSettings
|
9
|
+
from prefect.types import LogLevel
|
10
|
+
|
11
|
+
|
12
|
+
def max_log_size_smaller_than_batch_size(values):
|
13
|
+
"""
|
14
|
+
Validator for settings asserting the batch size and match log size are compatible
|
15
|
+
"""
|
16
|
+
if values["batch_size"] < values["max_log_size"]:
|
17
|
+
raise ValueError(
|
18
|
+
"`PREFECT_LOGGING_TO_API_MAX_LOG_SIZE` cannot be larger than"
|
19
|
+
" `PREFECT_LOGGING_TO_API_BATCH_SIZE`"
|
20
|
+
)
|
21
|
+
return values
|
22
|
+
|
23
|
+
|
24
|
+
class LoggingToAPISettings(PrefectBaseSettings):
|
25
|
+
"""
|
26
|
+
Settings for controlling logging to the API
|
27
|
+
"""
|
28
|
+
|
29
|
+
model_config = SettingsConfigDict(
|
30
|
+
env_prefix="PREFECT_LOGGING_TO_API_", env_file=".env", extra="ignore"
|
31
|
+
)
|
32
|
+
|
33
|
+
enabled: bool = Field(
|
34
|
+
default=True,
|
35
|
+
description="If `True`, logs will be sent to the API.",
|
36
|
+
)
|
37
|
+
|
38
|
+
batch_interval: float = Field(
|
39
|
+
default=2.0,
|
40
|
+
description="The number of seconds between batched writes of logs to the API.",
|
41
|
+
)
|
42
|
+
|
43
|
+
batch_size: int = Field(
|
44
|
+
default=4_000_000,
|
45
|
+
description="The number of logs to batch before sending to the API.",
|
46
|
+
)
|
47
|
+
|
48
|
+
max_log_size: int = Field(
|
49
|
+
default=1_000_000,
|
50
|
+
description="The maximum size in bytes for a single log.",
|
51
|
+
)
|
52
|
+
|
53
|
+
when_missing_flow: Literal["warn", "error", "ignore"] = Field(
|
54
|
+
default="warn",
|
55
|
+
description="""
|
56
|
+
Controls the behavior when loggers attempt to send logs to the API handler from outside of a flow.
|
57
|
+
|
58
|
+
All logs sent to the API must be associated with a flow run. The API log handler can
|
59
|
+
only be used outside of a flow by manually providing a flow run identifier. Logs
|
60
|
+
that are not associated with a flow run will not be sent to the API. This setting can
|
61
|
+
be used to determine if a warning or error is displayed when the identifier is missing.
|
62
|
+
|
63
|
+
The following options are available:
|
64
|
+
|
65
|
+
- "warn": Log a warning message.
|
66
|
+
- "error": Raise an error.
|
67
|
+
- "ignore": Do not log a warning message or raise an error.
|
68
|
+
""",
|
69
|
+
)
|
70
|
+
|
71
|
+
@model_validator(mode="after")
|
72
|
+
def emit_warnings(self) -> Self:
|
73
|
+
"""Emits warnings for misconfiguration of logging settings."""
|
74
|
+
values = self.model_dump()
|
75
|
+
values = max_log_size_smaller_than_batch_size(values)
|
76
|
+
return self
|
77
|
+
|
78
|
+
|
79
|
+
class LoggingSettings(PrefectBaseSettings):
|
80
|
+
"""
|
81
|
+
Settings for controlling logging behavior
|
82
|
+
"""
|
83
|
+
|
84
|
+
model_config = SettingsConfigDict(
|
85
|
+
env_prefix="PREFECT_LOGGING_", env_file=".env", extra="ignore"
|
86
|
+
)
|
87
|
+
|
88
|
+
level: LogLevel = Field(
|
89
|
+
default="INFO",
|
90
|
+
description="The default logging level for Prefect loggers.",
|
91
|
+
)
|
92
|
+
|
93
|
+
config_path: Optional[Path] = Field(
|
94
|
+
default=None,
|
95
|
+
description="The path to a custom YAML logging configuration file.",
|
96
|
+
validation_alias=AliasChoices(
|
97
|
+
AliasPath("config_path"),
|
98
|
+
"prefect_logging_config_path",
|
99
|
+
"prefect_logging_settings_path",
|
100
|
+
),
|
101
|
+
)
|
102
|
+
|
103
|
+
extra_loggers: Annotated[
|
104
|
+
Union[str, list[str], None],
|
105
|
+
AfterValidator(lambda v: [n.strip() for n in v.split(",")] if v else []),
|
106
|
+
] = Field(
|
107
|
+
default=None,
|
108
|
+
description="Additional loggers to attach to Prefect logging at runtime.",
|
109
|
+
)
|
110
|
+
|
111
|
+
log_prints: bool = Field(
|
112
|
+
default=False,
|
113
|
+
description="If `True`, `print` statements in flows and tasks will be redirected to the Prefect logger for the given run.",
|
114
|
+
)
|
115
|
+
|
116
|
+
colors: bool = Field(
|
117
|
+
default=True,
|
118
|
+
description="If `True`, use colors in CLI output. If `False`, output will not include colors codes.",
|
119
|
+
)
|
120
|
+
|
121
|
+
markup: bool = Field(
|
122
|
+
default=False,
|
123
|
+
description="""
|
124
|
+
Whether to interpret strings wrapped in square brackets as a style.
|
125
|
+
This allows styles to be conveniently added to log messages, e.g.
|
126
|
+
`[red]This is a red message.[/red]`. However, the downside is, if enabled,
|
127
|
+
strings that contain square brackets may be inaccurately interpreted and
|
128
|
+
lead to incomplete output, e.g.
|
129
|
+
`[red]This is a red message.[/red]` may be interpreted as
|
130
|
+
`[red]This is a red message.[/red]`.
|
131
|
+
""",
|
132
|
+
)
|
133
|
+
|
134
|
+
to_api: LoggingToAPISettings = Field(
|
135
|
+
default_factory=LoggingToAPISettings,
|
136
|
+
description="Settings for controlling logging to the API",
|
137
|
+
)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
from pydantic import AliasChoices, AliasPath, Field
|
5
|
+
from pydantic_settings import SettingsConfigDict
|
6
|
+
|
7
|
+
from prefect.settings.base import PrefectBaseSettings
|
8
|
+
|
9
|
+
|
10
|
+
class ResultsSettings(PrefectBaseSettings):
|
11
|
+
"""
|
12
|
+
Settings for controlling result storage behavior
|
13
|
+
"""
|
14
|
+
|
15
|
+
model_config = SettingsConfigDict(
|
16
|
+
env_prefix="PREFECT_RESULTS_", env_file=".env", extra="ignore"
|
17
|
+
)
|
18
|
+
|
19
|
+
default_serializer: str = Field(
|
20
|
+
default="pickle",
|
21
|
+
description="The default serializer to use when not otherwise specified.",
|
22
|
+
)
|
23
|
+
|
24
|
+
persist_by_default: bool = Field(
|
25
|
+
default=False,
|
26
|
+
description="The default setting for persisting results when not otherwise specified.",
|
27
|
+
)
|
28
|
+
|
29
|
+
default_storage_block: Optional[str] = Field(
|
30
|
+
default=None,
|
31
|
+
description="The `block-type/block-document` slug of a block to use as the default result storage.",
|
32
|
+
validation_alias=AliasChoices(
|
33
|
+
AliasPath("default_storage_block"),
|
34
|
+
"prefect_results_default_storage_block",
|
35
|
+
"prefect_default_result_storage_block",
|
36
|
+
),
|
37
|
+
)
|
38
|
+
|
39
|
+
local_storage_path: Optional[Path] = Field(
|
40
|
+
default=None,
|
41
|
+
description="The path to a directory to store results in.",
|
42
|
+
validation_alias=AliasChoices(
|
43
|
+
AliasPath("local_storage_path"),
|
44
|
+
"prefect_results_local_storage_path",
|
45
|
+
"prefect_local_storage_path",
|
46
|
+
),
|
47
|
+
)
|