prefect-client 3.1.11__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/__init__.py +0 -0
- prefect/_experimental/sla/client.py +92 -0
- prefect/_experimental/sla/objects.py +61 -0
- 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 +236 -30
- prefect/blocks/__init__.py +3 -3
- prefect/blocks/abstract.py +57 -31
- prefect/blocks/core.py +181 -82
- prefect/blocks/notifications.py +134 -73
- prefect/blocks/redis.py +13 -9
- prefect/blocks/system.py +24 -11
- prefect/blocks/webhook.py +7 -5
- prefect/cache_policies.py +23 -22
- prefect/client/orchestration/__init__.py +103 -2006
- prefect/client/orchestration/_automations/__init__.py +0 -0
- prefect/client/orchestration/_automations/client.py +329 -0
- prefect/client/orchestration/_blocks_documents/__init__.py +0 -0
- prefect/client/orchestration/_blocks_documents/client.py +334 -0
- prefect/client/orchestration/_blocks_schemas/__init__.py +0 -0
- prefect/client/orchestration/_blocks_schemas/client.py +200 -0
- prefect/client/orchestration/_blocks_types/__init__.py +0 -0
- prefect/client/orchestration/_blocks_types/client.py +380 -0
- prefect/client/orchestration/_deployments/__init__.py +0 -0
- prefect/client/orchestration/_deployments/client.py +1128 -0
- prefect/client/orchestration/_flow_runs/__init__.py +0 -0
- prefect/client/orchestration/_flow_runs/client.py +903 -0
- prefect/client/orchestration/_flows/__init__.py +0 -0
- prefect/client/orchestration/_flows/client.py +343 -0
- prefect/client/orchestration/_logs/client.py +16 -14
- prefect/client/schemas/__init__.py +68 -28
- prefect/client/schemas/objects.py +5 -5
- prefect/client/utilities.py +3 -3
- prefect/context.py +15 -1
- prefect/deployments/base.py +13 -4
- prefect/deployments/flow_runs.py +5 -1
- prefect/deployments/runner.py +37 -1
- 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 +33 -11
- 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 +7 -3
- prefect/flow_engine.py +64 -47
- prefect/flows.py +128 -74
- 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/logging/logging.yml +1 -1
- prefect/main.py +3 -1
- prefect/results.py +166 -86
- prefect/runner/runner.py +38 -29
- 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 +9 -3
- prefect/settings/models/deployments.py +4 -3
- prefect/settings/models/experiments.py +4 -8
- 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 +74 -51
- prefect/task_engine.py +43 -33
- prefect/task_runners.py +85 -72
- prefect/task_runs.py +20 -11
- prefect/task_worker.py +14 -9
- prefect/tasks.py +36 -28
- prefect/telemetry/bootstrap.py +13 -9
- prefect/telemetry/run_telemetry.py +15 -13
- prefect/telemetry/services.py +4 -0
- 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/utilities/templating.py +25 -1
- prefect/workers/base.py +58 -33
- prefect/workers/process.py +20 -15
- prefect/workers/server.py +4 -5
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/METADATA +3 -3
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/RECORD +133 -114
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/WHEEL +0 -0
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/top_level.txt +0 -0
prefect/logging/loggers.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import io
|
2
4
|
import logging
|
3
5
|
import sys
|
@@ -5,7 +7,7 @@ from builtins import print
|
|
5
7
|
from contextlib import contextmanager
|
6
8
|
from functools import lru_cache
|
7
9
|
from logging import LogRecord
|
8
|
-
from typing import TYPE_CHECKING, Any,
|
10
|
+
from typing import TYPE_CHECKING, Any, List, Mapping, MutableMapping, Optional, Union
|
9
11
|
|
10
12
|
from typing_extensions import Self
|
11
13
|
|
@@ -13,6 +15,14 @@ from prefect.exceptions import MissingContextError
|
|
13
15
|
from prefect.logging.filters import ObfuscateApiKeyFilter
|
14
16
|
from prefect.telemetry.logging import add_telemetry_log_handler
|
15
17
|
|
18
|
+
if sys.version_info >= (3, 12):
|
19
|
+
LoggingAdapter = logging.LoggerAdapter[logging.Logger]
|
20
|
+
else:
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
LoggingAdapter = logging.LoggerAdapter[logging.Logger]
|
23
|
+
else:
|
24
|
+
LoggingAdapter = logging.LoggerAdapter
|
25
|
+
|
16
26
|
if TYPE_CHECKING:
|
17
27
|
from prefect.client.schemas import FlowRun as ClientFlowRun
|
18
28
|
from prefect.client.schemas.objects import FlowRun, TaskRun
|
@@ -21,11 +31,6 @@ if TYPE_CHECKING:
|
|
21
31
|
from prefect.tasks import Task
|
22
32
|
from prefect.workers.base import BaseWorker
|
23
33
|
|
24
|
-
if sys.version_info >= (3, 12):
|
25
|
-
LoggingAdapter = logging.LoggerAdapter[logging.Logger]
|
26
|
-
else:
|
27
|
-
LoggingAdapter = logging.LoggerAdapter
|
28
|
-
|
29
34
|
|
30
35
|
class PrefectLogAdapter(LoggingAdapter):
|
31
36
|
"""
|
@@ -37,27 +42,28 @@ class PrefectLogAdapter(LoggingAdapter):
|
|
37
42
|
not a bug in the LoggingAdapter and subclassing is the intended workaround.
|
38
43
|
"""
|
39
44
|
|
40
|
-
def process(
|
45
|
+
def process(
|
46
|
+
self, msg: str, kwargs: MutableMapping[str, Any]
|
47
|
+
) -> tuple[str, MutableMapping[str, Any]]:
|
41
48
|
kwargs["extra"] = {**(self.extra or {}), **(kwargs.get("extra") or {})}
|
42
49
|
return (msg, kwargs)
|
43
50
|
|
44
51
|
def getChild(
|
45
|
-
self, suffix: str, extra:
|
52
|
+
self, suffix: str, extra: dict[str, Any] | None = None
|
46
53
|
) -> "PrefectLogAdapter":
|
47
|
-
|
48
|
-
extra = {}
|
54
|
+
_extra: Mapping[str, object] = extra or {}
|
49
55
|
|
50
56
|
return PrefectLogAdapter(
|
51
57
|
self.logger.getChild(suffix),
|
52
58
|
extra={
|
53
|
-
**self.extra,
|
54
|
-
**
|
59
|
+
**(self.extra or {}),
|
60
|
+
**_extra,
|
55
61
|
},
|
56
62
|
)
|
57
63
|
|
58
64
|
|
59
65
|
@lru_cache()
|
60
|
-
def get_logger(name:
|
66
|
+
def get_logger(name: str | None = None) -> logging.Logger:
|
61
67
|
"""
|
62
68
|
Get a `prefect` logger. These loggers are intended for internal use within the
|
63
69
|
`prefect` package.
|
@@ -161,7 +167,7 @@ def flow_run_logger(
|
|
161
167
|
flow_run: Union["FlowRun", "ClientFlowRun"],
|
162
168
|
flow: Optional["Flow[Any, Any]"] = None,
|
163
169
|
**kwargs: str,
|
164
|
-
) ->
|
170
|
+
) -> PrefectLogAdapter:
|
165
171
|
"""
|
166
172
|
Create a flow run logger with the run's metadata attached.
|
167
173
|
|
@@ -189,7 +195,7 @@ def task_run_logger(
|
|
189
195
|
flow_run: Optional["FlowRun"] = None,
|
190
196
|
flow: Optional["Flow[Any, Any]"] = None,
|
191
197
|
**kwargs: Any,
|
192
|
-
):
|
198
|
+
) -> LoggingAdapter:
|
193
199
|
"""
|
194
200
|
Create a task run logger with the run's metadata attached.
|
195
201
|
|
@@ -225,7 +231,9 @@ def task_run_logger(
|
|
225
231
|
)
|
226
232
|
|
227
233
|
|
228
|
-
def get_worker_logger(
|
234
|
+
def get_worker_logger(
|
235
|
+
worker: "BaseWorker[Any, Any, Any]", name: Optional[str] = None
|
236
|
+
) -> logging.Logger | LoggingAdapter:
|
229
237
|
"""
|
230
238
|
Create a worker logger with the worker's metadata attached.
|
231
239
|
|
@@ -361,7 +369,9 @@ class LogEavesdropper(logging.Handler):
|
|
361
369
|
# It's important that we use a very minimalistic formatter for use cases where
|
362
370
|
# we may present these logs back to the user. We shouldn't leak filenames,
|
363
371
|
# versions, or other environmental information.
|
364
|
-
self.formatter = logging.Formatter(
|
372
|
+
self.formatter: logging.Formatter | None = logging.Formatter(
|
373
|
+
"[%(levelname)s]: %(message)s"
|
374
|
+
)
|
365
375
|
|
366
376
|
def __enter__(self) -> Self:
|
367
377
|
self._target_logger = logging.getLogger(self.eavesdrop_on)
|
@@ -371,7 +381,7 @@ class LogEavesdropper(logging.Handler):
|
|
371
381
|
self._lines = []
|
372
382
|
return self
|
373
383
|
|
374
|
-
def __exit__(self, *_):
|
384
|
+
def __exit__(self, *_: Any) -> None:
|
375
385
|
if self._target_logger:
|
376
386
|
self._target_logger.removeHandler(self)
|
377
387
|
self._target_logger.level = self._original_level
|
prefect/logging/logging.yml
CHANGED
@@ -32,7 +32,7 @@ formatters:
|
|
32
32
|
# Define any custom filters to drops records containing
|
33
33
|
# sensitive information
|
34
34
|
# my_filter:
|
35
|
-
#
|
35
|
+
# (): your_module.FilterClass
|
36
36
|
|
37
37
|
handlers:
|
38
38
|
# The handlers we define here will output all logs they receive by default
|
prefect/main.py
CHANGED
@@ -3,7 +3,7 @@ from typing import Any
|
|
3
3
|
from prefect.deployments import deploy
|
4
4
|
from prefect.states import State
|
5
5
|
from prefect.logging import get_run_logger
|
6
|
-
from prefect.flows import flow, Flow, serve, aserve
|
6
|
+
from prefect.flows import FlowDecorator, flow, Flow, serve, aserve
|
7
7
|
from prefect.transactions import Transaction
|
8
8
|
from prefect.tasks import task, Task
|
9
9
|
from prefect.context import tags
|
@@ -58,6 +58,8 @@ from prefect._internal.compatibility.deprecated import (
|
|
58
58
|
|
59
59
|
inject_renamed_module_alias_finder()
|
60
60
|
|
61
|
+
flow: FlowDecorator
|
62
|
+
|
61
63
|
|
62
64
|
# Declare API for type-checkers
|
63
65
|
__all__ = [
|