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
@@ -1,9 +1,10 @@
|
|
1
1
|
from datetime import timedelta
|
2
2
|
from typing import ClassVar
|
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 ServerEventsSettings(PrefectBaseSettings):
|
@@ -11,7 +12,9 @@ class ServerEventsSettings(PrefectBaseSettings):
|
|
11
12
|
Settings for controlling behavior of the events subsystem
|
12
13
|
"""
|
13
14
|
|
14
|
-
model_config: ClassVar[
|
15
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
16
|
+
("server", "events")
|
17
|
+
)
|
15
18
|
|
16
19
|
###########################################################################
|
17
20
|
# Events settings
|
@@ -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 ServerFlowRunGraphSettings(PrefectBaseSettings):
|
@@ -10,7 +11,7 @@ class ServerFlowRunGraphSettings(PrefectBaseSettings):
|
|
10
11
|
Settings for controlling behavior of the flow run graph
|
11
12
|
"""
|
12
13
|
|
13
|
-
model_config: ClassVar[
|
14
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
14
15
|
("server", "flow_run_graph")
|
15
16
|
)
|
16
17
|
|
@@ -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
|
from prefect.types import LogLevel
|
8
9
|
|
9
10
|
from .api import ServerAPISettings
|
@@ -22,7 +23,7 @@ class ServerSettings(PrefectBaseSettings):
|
|
22
23
|
Settings for controlling server behavior
|
23
24
|
"""
|
24
25
|
|
25
|
-
model_config: ClassVar[
|
26
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("server",))
|
26
27
|
|
27
28
|
logging_level: LogLevel = Field(
|
28
29
|
default="WARNING",
|
@@ -1,9 +1,10 @@
|
|
1
1
|
from datetime import timedelta
|
2
2
|
from typing import ClassVar
|
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 ServerServicesCancellationCleanupSettings(PrefectBaseSettings):
|
@@ -11,7 +12,7 @@ class ServerServicesCancellationCleanupSettings(PrefectBaseSettings):
|
|
11
12
|
Settings for controlling the cancellation cleanup service
|
12
13
|
"""
|
13
14
|
|
14
|
-
model_config: ClassVar[
|
15
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
15
16
|
("server", "services", "cancellation_cleanup")
|
16
17
|
)
|
17
18
|
|
@@ -41,7 +42,7 @@ class ServerServicesEventPersisterSettings(PrefectBaseSettings):
|
|
41
42
|
Settings for controlling the event persister service
|
42
43
|
"""
|
43
44
|
|
44
|
-
model_config: ClassVar[
|
45
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
45
46
|
("server", "services", "event_persister")
|
46
47
|
)
|
47
48
|
|
@@ -83,7 +84,7 @@ class ServerServicesFlowRunNotificationsSettings(PrefectBaseSettings):
|
|
83
84
|
Settings for controlling the flow run notifications service
|
84
85
|
"""
|
85
86
|
|
86
|
-
model_config: ClassVar[
|
87
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
87
88
|
("server", "services", "flow_run_notifications")
|
88
89
|
)
|
89
90
|
|
@@ -103,7 +104,7 @@ class ServerServicesForemanSettings(PrefectBaseSettings):
|
|
103
104
|
Settings for controlling the foreman service
|
104
105
|
"""
|
105
106
|
|
106
|
-
model_config: ClassVar[
|
107
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
107
108
|
("server", "services", "foreman")
|
108
109
|
)
|
109
110
|
|
@@ -184,7 +185,7 @@ class ServerServicesLateRunsSettings(PrefectBaseSettings):
|
|
184
185
|
Settings for controlling the late runs service
|
185
186
|
"""
|
186
187
|
|
187
|
-
model_config: ClassVar[
|
188
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
188
189
|
("server", "services", "late_runs")
|
189
190
|
)
|
190
191
|
|
@@ -228,7 +229,7 @@ class ServerServicesSchedulerSettings(PrefectBaseSettings):
|
|
228
229
|
Settings for controlling the scheduler service
|
229
230
|
"""
|
230
231
|
|
231
|
-
model_config: ClassVar[
|
232
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
232
233
|
("server", "services", "scheduler")
|
233
234
|
)
|
234
235
|
|
@@ -353,7 +354,7 @@ class ServerServicesPauseExpirationsSettings(PrefectBaseSettings):
|
|
353
354
|
Settings for controlling the pause expiration service
|
354
355
|
"""
|
355
356
|
|
356
|
-
model_config: ClassVar[
|
357
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
357
358
|
("server", "services", "pause_expirations")
|
358
359
|
)
|
359
360
|
|
@@ -389,7 +390,7 @@ class ServerServicesTaskRunRecorderSettings(PrefectBaseSettings):
|
|
389
390
|
Settings for controlling the task run recorder service
|
390
391
|
"""
|
391
392
|
|
392
|
-
model_config: ClassVar[
|
393
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
393
394
|
("server", "services", "task_run_recorder")
|
394
395
|
)
|
395
396
|
|
@@ -409,7 +410,7 @@ class ServerServicesTriggersSettings(PrefectBaseSettings):
|
|
409
410
|
Settings for controlling the triggers service
|
410
411
|
"""
|
411
412
|
|
412
|
-
model_config: ClassVar[
|
413
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
413
414
|
("server", "services", "triggers")
|
414
415
|
)
|
415
416
|
|
@@ -429,7 +430,9 @@ class ServerServicesSettings(PrefectBaseSettings):
|
|
429
430
|
Settings for controlling server services
|
430
431
|
"""
|
431
432
|
|
432
|
-
model_config: ClassVar[
|
433
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
434
|
+
("server", "services")
|
435
|
+
)
|
433
436
|
|
434
437
|
cancellation_cleanup: ServerServicesCancellationCleanupSettings = Field(
|
435
438
|
default_factory=ServerServicesCancellationCleanupSettings,
|
@@ -1,9 +1,10 @@
|
|
1
1
|
from datetime import timedelta
|
2
2
|
from typing import ClassVar
|
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 ServerTasksSchedulingSettings(PrefectBaseSettings):
|
@@ -11,7 +12,7 @@ class ServerTasksSchedulingSettings(PrefectBaseSettings):
|
|
11
12
|
Settings for controlling server-side behavior related to task scheduling
|
12
13
|
"""
|
13
14
|
|
14
|
-
model_config: ClassVar[
|
15
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
15
16
|
("server", "tasks", "scheduling")
|
16
17
|
)
|
17
18
|
|
@@ -51,7 +52,9 @@ class ServerTasksSettings(PrefectBaseSettings):
|
|
51
52
|
Settings for controlling server-side behavior related to tasks
|
52
53
|
"""
|
53
54
|
|
54
|
-
model_config: ClassVar[
|
55
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
56
|
+
("server", "tasks")
|
57
|
+
)
|
55
58
|
|
56
59
|
tag_concurrency_slot_wait_seconds: float = Field(
|
57
60
|
default=30,
|
@@ -1,12 +1,13 @@
|
|
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 ServerUISettings(PrefectBaseSettings):
|
9
|
-
model_config: ClassVar[
|
10
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("server", "ui"))
|
10
11
|
|
11
12
|
enabled: bool = Field(
|
12
13
|
default=True,
|
prefect/settings/models/tasks.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
from typing import ClassVar, Optional, 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 TasksRunnerSettings(PrefectBaseSettings):
|
9
|
-
model_config: ClassVar[
|
10
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
11
|
+
("tasks", "runner")
|
12
|
+
)
|
10
13
|
|
11
14
|
thread_pool_max_workers: Optional[int] = Field(
|
12
15
|
default=None,
|
@@ -21,7 +24,9 @@ class TasksRunnerSettings(PrefectBaseSettings):
|
|
21
24
|
|
22
25
|
|
23
26
|
class TasksSchedulingSettings(PrefectBaseSettings):
|
24
|
-
model_config: ClassVar[
|
27
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
28
|
+
("tasks", "scheduling")
|
29
|
+
)
|
25
30
|
|
26
31
|
default_storage_block: Optional[str] = Field(
|
27
32
|
default=None,
|
@@ -45,7 +50,7 @@ class TasksSchedulingSettings(PrefectBaseSettings):
|
|
45
50
|
|
46
51
|
|
47
52
|
class TasksSettings(PrefectBaseSettings):
|
48
|
-
model_config: ClassVar[
|
53
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("tasks",))
|
49
54
|
|
50
55
|
refresh_cache: bool = Field(
|
51
56
|
default=False,
|
@@ -1,12 +1,13 @@
|
|
1
1
|
from typing import Any, 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 TestingSettings(PrefectBaseSettings):
|
9
|
-
model_config: ClassVar[
|
10
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("testing",))
|
10
11
|
|
11
12
|
test_mode: bool = Field(
|
12
13
|
default=False,
|
@@ -1,12 +1,15 @@
|
|
1
1
|
from typing import ClassVar
|
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
|
|
7
8
|
|
8
9
|
class WorkerWebserverSettings(PrefectBaseSettings):
|
9
|
-
model_config: ClassVar[
|
10
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(
|
11
|
+
("worker", "webserver")
|
12
|
+
)
|
10
13
|
|
11
14
|
host: str = Field(
|
12
15
|
default="0.0.0.0",
|
@@ -20,7 +23,7 @@ class WorkerWebserverSettings(PrefectBaseSettings):
|
|
20
23
|
|
21
24
|
|
22
25
|
class WorkerSettings(PrefectBaseSettings):
|
23
|
-
model_config: ClassVar[
|
26
|
+
model_config: ClassVar[SettingsConfigDict] = build_settings_config(("worker",))
|
24
27
|
|
25
28
|
heartbeat_seconds: float = Field(
|
26
29
|
default=30,
|
prefect/settings/profiles.py
CHANGED
@@ -7,10 +7,9 @@ from typing import (
|
|
7
7
|
ClassVar,
|
8
8
|
Dict,
|
9
9
|
Iterable,
|
10
|
-
|
10
|
+
Iterator,
|
11
11
|
Optional,
|
12
12
|
Set,
|
13
|
-
Tuple,
|
14
13
|
Union,
|
15
14
|
)
|
16
15
|
|
@@ -77,8 +76,8 @@ class Profile(BaseModel):
|
|
77
76
|
if value is not None
|
78
77
|
}
|
79
78
|
|
80
|
-
def validate_settings(self):
|
81
|
-
errors:
|
79
|
+
def validate_settings(self) -> None:
|
80
|
+
errors: list[tuple[Setting, ValidationError]] = []
|
82
81
|
for setting, value in self.settings.items():
|
83
82
|
try:
|
84
83
|
model_fields = Settings.model_fields
|
@@ -109,7 +108,9 @@ class ProfilesCollection:
|
|
109
108
|
def __init__(
|
110
109
|
self, profiles: Iterable[Profile], active: Optional[str] = None
|
111
110
|
) -> None:
|
112
|
-
self.profiles_by_name
|
111
|
+
self.profiles_by_name: dict[str, Profile] = {
|
112
|
+
profile.name: profile for profile in profiles
|
113
|
+
}
|
113
114
|
self.active_name = active
|
114
115
|
|
115
116
|
@property
|
@@ -128,7 +129,7 @@ class ProfilesCollection:
|
|
128
129
|
return None
|
129
130
|
return self[self.active_name]
|
130
131
|
|
131
|
-
def set_active(self, name: Optional[str], check: bool = True):
|
132
|
+
def set_active(self, name: Optional[str], check: bool = True) -> None:
|
132
133
|
"""
|
133
134
|
Set the active profile name in the collection.
|
134
135
|
|
@@ -142,7 +143,7 @@ class ProfilesCollection:
|
|
142
143
|
def update_profile(
|
143
144
|
self,
|
144
145
|
name: str,
|
145
|
-
settings:
|
146
|
+
settings: dict[Setting, Any],
|
146
147
|
source: Optional[Path] = None,
|
147
148
|
) -> Profile:
|
148
149
|
"""
|
@@ -214,7 +215,7 @@ class ProfilesCollection:
|
|
214
215
|
active=self.active_name,
|
215
216
|
)
|
216
217
|
|
217
|
-
def to_dict(self):
|
218
|
+
def to_dict(self) -> dict[str, Any]:
|
218
219
|
"""
|
219
220
|
Convert to a dictionary suitable for writing to disk.
|
220
221
|
"""
|
@@ -229,11 +230,11 @@ class ProfilesCollection:
|
|
229
230
|
def __getitem__(self, name: str) -> Profile:
|
230
231
|
return self.profiles_by_name[name]
|
231
232
|
|
232
|
-
def __iter__(self):
|
233
|
+
def __iter__(self) -> Iterator[str]:
|
233
234
|
return self.profiles_by_name.__iter__()
|
234
235
|
|
235
|
-
def items(self):
|
236
|
-
return self.profiles_by_name.items()
|
236
|
+
def items(self) -> list[tuple[str, Profile]]:
|
237
|
+
return list(self.profiles_by_name.items())
|
237
238
|
|
238
239
|
def __eq__(self, __o: object) -> bool:
|
239
240
|
if not isinstance(__o, ProfilesCollection):
|
@@ -325,7 +326,7 @@ def load_profiles(include_defaults: bool = True) -> ProfilesCollection:
|
|
325
326
|
return profiles
|
326
327
|
|
327
328
|
|
328
|
-
def load_current_profile():
|
329
|
+
def load_current_profile() -> Profile:
|
329
330
|
"""
|
330
331
|
Load the current profile from the default and current profile paths.
|
331
332
|
|
prefect/settings/sources.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2
2
|
import sys
|
3
3
|
import warnings
|
4
4
|
from pathlib import Path
|
5
|
-
from typing import Any, Dict, List, Optional, Tuple, Type
|
5
|
+
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Type
|
6
6
|
|
7
7
|
import dotenv
|
8
8
|
import toml
|
@@ -54,6 +54,7 @@ class EnvFilterSettingsSource(EnvSettingsSource):
|
|
54
54
|
env_parse_none_str,
|
55
55
|
env_parse_enums,
|
56
56
|
)
|
57
|
+
self.env_vars: Mapping[str, str | None]
|
57
58
|
if env_filter:
|
58
59
|
if isinstance(self.env_vars, dict):
|
59
60
|
for key in env_filter:
|
@@ -97,7 +98,7 @@ class FilteredDotEnvSettingsSource(DotEnvSettingsSource):
|
|
97
98
|
for key in self.env_blacklist:
|
98
99
|
self.env_vars.pop(key, None)
|
99
100
|
else:
|
100
|
-
self.env_vars = {
|
101
|
+
self.env_vars: dict[str, str | None] = {
|
101
102
|
key: value
|
102
103
|
for key, value in self.env_vars.items() # type: ignore
|
103
104
|
if key.lower() not in env_blacklist
|
@@ -114,8 +115,8 @@ class ProfileSettingsTomlLoader(PydanticBaseSettingsSource):
|
|
114
115
|
def __init__(self, settings_cls: Type[BaseSettings]):
|
115
116
|
super().__init__(settings_cls)
|
116
117
|
self.settings_cls = settings_cls
|
117
|
-
self.profiles_path = _get_profiles_path()
|
118
|
-
self.profile_settings = self._load_profile_settings()
|
118
|
+
self.profiles_path: Path = _get_profiles_path()
|
119
|
+
self.profile_settings: dict[str, Any] = self._load_profile_settings()
|
119
120
|
|
120
121
|
def _load_profile_settings(self) -> Dict[str, Any]:
|
121
122
|
"""Helper method to load the profile settings from the profiles.toml file"""
|
@@ -213,14 +214,14 @@ class TomlConfigSettingsSourceBase(PydanticBaseSettingsSource, ConfigFileSourceM
|
|
213
214
|
def __init__(self, settings_cls: Type[BaseSettings]):
|
214
215
|
super().__init__(settings_cls)
|
215
216
|
self.settings_cls = settings_cls
|
216
|
-
self.toml_data = {}
|
217
|
+
self.toml_data: dict[str, Any] = {}
|
217
218
|
|
218
|
-
def _read_file(self, path: Path) ->
|
219
|
+
def _read_file(self, path: Path) -> dict[str, Any]:
|
219
220
|
return toml.load(path)
|
220
221
|
|
221
222
|
def get_field_value(
|
222
223
|
self, field: FieldInfo, field_name: str
|
223
|
-
) ->
|
224
|
+
) -> tuple[Any, str, bool]:
|
224
225
|
"""Concrete implementation to get the field value from toml data"""
|
225
226
|
value = self.toml_data.get(field_name)
|
226
227
|
if isinstance(value, dict):
|
@@ -244,9 +245,9 @@ class TomlConfigSettingsSourceBase(PydanticBaseSettingsSource, ConfigFileSourceM
|
|
244
245
|
break
|
245
246
|
return value, name, self.field_is_complex(field)
|
246
247
|
|
247
|
-
def __call__(self) ->
|
248
|
+
def __call__(self) -> dict[str, Any]:
|
248
249
|
"""Called by pydantic to get the settings from our custom source"""
|
249
|
-
toml_setings:
|
250
|
+
toml_setings: dict[str, Any] = {}
|
250
251
|
for field_name, field in self.settings_cls.model_fields.items():
|
251
252
|
value, key, is_complex = self.get_field_value(field, field_name)
|
252
253
|
if value is not None:
|
@@ -265,15 +266,15 @@ class PrefectTomlConfigSettingsSource(TomlConfigSettingsSourceBase):
|
|
265
266
|
settings_cls: Type[BaseSettings],
|
266
267
|
):
|
267
268
|
super().__init__(settings_cls)
|
268
|
-
self.toml_file_path
|
269
|
-
|
270
|
-
)
|
271
|
-
self.toml_data = self._read_files(self.toml_file_path)
|
272
|
-
self.toml_table_header = settings_cls.model_config.get(
|
269
|
+
self.toml_file_path: Path | str | Sequence[
|
270
|
+
Path | str
|
271
|
+
] | None = settings_cls.model_config.get("toml_file", DEFAULT_PREFECT_TOML_PATH)
|
272
|
+
self.toml_data: dict[str, Any] = self._read_files(self.toml_file_path)
|
273
|
+
self.toml_table_header: tuple[str, ...] = settings_cls.model_config.get(
|
273
274
|
"prefect_toml_table_header", tuple()
|
274
275
|
)
|
275
276
|
for key in self.toml_table_header:
|
276
|
-
self.toml_data = self.toml_data.get(key, {})
|
277
|
+
self.toml_data: dict[str, Any] = self.toml_data.get(key, {})
|
277
278
|
|
278
279
|
|
279
280
|
class PyprojectTomlConfigSettingsSource(TomlConfigSettingsSourceBase):
|
@@ -284,13 +285,13 @@ class PyprojectTomlConfigSettingsSource(TomlConfigSettingsSourceBase):
|
|
284
285
|
settings_cls: Type[BaseSettings],
|
285
286
|
):
|
286
287
|
super().__init__(settings_cls)
|
287
|
-
self.toml_file_path = Path("pyproject.toml")
|
288
|
-
self.toml_data = self._read_files(self.toml_file_path)
|
289
|
-
self.toml_table_header = settings_cls.model_config.get(
|
288
|
+
self.toml_file_path: Path = Path("pyproject.toml")
|
289
|
+
self.toml_data: dict[str, Any] = self._read_files(self.toml_file_path)
|
290
|
+
self.toml_table_header: tuple[str, ...] = settings_cls.model_config.get(
|
290
291
|
"pyproject_toml_table_header", ("tool", "prefect")
|
291
292
|
)
|
292
293
|
for key in self.toml_table_header:
|
293
|
-
self.toml_data = self.toml_data.get(key, {})
|
294
|
+
self.toml_data: dict[str, Any] = self.toml_data.get(key, {})
|
294
295
|
|
295
296
|
|
296
297
|
def _is_test_mode() -> bool:
|
prefect/states.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import asyncio
|
2
4
|
import datetime
|
3
5
|
import sys
|
@@ -33,12 +35,14 @@ from prefect.utilities.asyncutils import in_async_main_thread, sync_compatible
|
|
33
35
|
from prefect.utilities.collections import ensure_iterable
|
34
36
|
|
35
37
|
if TYPE_CHECKING:
|
38
|
+
import logging
|
39
|
+
|
36
40
|
from prefect.results import (
|
37
41
|
R,
|
38
42
|
ResultStore,
|
39
43
|
)
|
40
44
|
|
41
|
-
logger = get_logger("states")
|
45
|
+
logger: "logging.Logger" = get_logger("states")
|
42
46
|
|
43
47
|
|
44
48
|
@deprecated.deprecated_parameter(
|
@@ -245,8 +249,8 @@ async def exception_to_failed_state(
|
|
245
249
|
exc: Optional[BaseException] = None,
|
246
250
|
result_store: Optional["ResultStore"] = None,
|
247
251
|
write_result: bool = False,
|
248
|
-
**kwargs,
|
249
|
-
) -> State:
|
252
|
+
**kwargs: Any,
|
253
|
+
) -> State[BaseException]:
|
250
254
|
"""
|
251
255
|
Convenience function for creating `Failed` states from exceptions
|
252
256
|
"""
|
@@ -553,17 +557,17 @@ def is_state_iterable(obj: Any) -> TypeGuard[Iterable[State]]:
|
|
553
557
|
|
554
558
|
|
555
559
|
class StateGroup:
|
556
|
-
def __init__(self, states:
|
557
|
-
self.states = states
|
558
|
-
self.type_counts = self._get_type_counts(states)
|
559
|
-
self.total_count = len(states)
|
560
|
-
self.cancelled_count = self.type_counts[StateType.CANCELLED]
|
561
|
-
self.final_count = sum(state.is_final() for state in states)
|
562
|
-
self.not_final_count = self.total_count - self.final_count
|
563
|
-
self.paused_count = self.type_counts[StateType.PAUSED]
|
560
|
+
def __init__(self, states: list[State]) -> None:
|
561
|
+
self.states: list[State] = states
|
562
|
+
self.type_counts: dict[StateType, int] = self._get_type_counts(states)
|
563
|
+
self.total_count: int = len(states)
|
564
|
+
self.cancelled_count: int = self.type_counts[StateType.CANCELLED]
|
565
|
+
self.final_count: int = sum(state.is_final() for state in states)
|
566
|
+
self.not_final_count: int = self.total_count - self.final_count
|
567
|
+
self.paused_count: int = self.type_counts[StateType.PAUSED]
|
564
568
|
|
565
569
|
@property
|
566
|
-
def fail_count(self):
|
570
|
+
def fail_count(self) -> int:
|
567
571
|
return self.type_counts[StateType.FAILED] + self.type_counts[StateType.CRASHED]
|
568
572
|
|
569
573
|
def all_completed(self) -> bool:
|
@@ -741,7 +745,7 @@ def Suspended(
|
|
741
745
|
pause_expiration_time: Optional[datetime.datetime] = None,
|
742
746
|
pause_key: Optional[str] = None,
|
743
747
|
**kwargs: Any,
|
744
|
-
):
|
748
|
+
) -> "State[R]":
|
745
749
|
"""Convenience function for creating `Suspended` states.
|
746
750
|
|
747
751
|
Returns:
|