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/blocks/system.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import json
|
2
4
|
from typing import Annotated, Any, Generic, TypeVar, Union
|
3
5
|
|
4
6
|
from pydantic import (
|
5
7
|
Field,
|
8
|
+
HttpUrl,
|
6
9
|
JsonValue,
|
7
10
|
SecretStr,
|
8
11
|
StrictStr,
|
@@ -43,8 +46,10 @@ class JSON(Block):
|
|
43
46
|
```
|
44
47
|
"""
|
45
48
|
|
46
|
-
_logo_url =
|
47
|
-
|
49
|
+
_logo_url = HttpUrl(
|
50
|
+
"https://cdn.sanity.io/images/3ugk85nk/production/4fcef2294b6eeb423b1332d1ece5156bf296ff96-48x48.png"
|
51
|
+
)
|
52
|
+
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
|
48
53
|
|
49
54
|
value: Any = Field(default=..., description="A JSON-compatible value.")
|
50
55
|
|
@@ -70,8 +75,10 @@ class String(Block):
|
|
70
75
|
```
|
71
76
|
"""
|
72
77
|
|
73
|
-
_logo_url =
|
74
|
-
|
78
|
+
_logo_url = HttpUrl(
|
79
|
+
"https://cdn.sanity.io/images/3ugk85nk/production/c262ea2c80a2c043564e8763f3370c3db5a6b3e6-48x48.png"
|
80
|
+
)
|
81
|
+
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
|
75
82
|
|
76
83
|
value: str = Field(default=..., description="A string value.")
|
77
84
|
|
@@ -98,8 +105,10 @@ class DateTime(Block):
|
|
98
105
|
"""
|
99
106
|
|
100
107
|
_block_type_name = "Date Time"
|
101
|
-
_logo_url =
|
102
|
-
|
108
|
+
_logo_url = HttpUrl(
|
109
|
+
"https://cdn.sanity.io/images/3ugk85nk/production/8b3da9a6621e92108b8e6a75b82e15374e170ff7-48x48.png"
|
110
|
+
)
|
111
|
+
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
|
103
112
|
|
104
113
|
value: PydanticDateTime = Field(
|
105
114
|
default=...,
|
@@ -128,8 +137,10 @@ class Secret(Block, Generic[T]):
|
|
128
137
|
```
|
129
138
|
"""
|
130
139
|
|
131
|
-
_logo_url =
|
132
|
-
|
140
|
+
_logo_url = HttpUrl(
|
141
|
+
"https://cdn.sanity.io/images/3ugk85nk/production/c6f20e556dd16effda9df16551feecfb5822092b-48x48.png"
|
142
|
+
)
|
143
|
+
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
|
133
144
|
_description = "A block that represents a secret value. The value stored in this block will be obfuscated when this block is viewed or edited in the UI."
|
134
145
|
|
135
146
|
value: Union[SecretStr, PydanticSecret[T]] = Field(
|
@@ -151,9 +162,11 @@ class Secret(Block, Generic[T]):
|
|
151
162
|
else:
|
152
163
|
return PydanticSecret[type(value)](value)
|
153
164
|
|
154
|
-
def get(self) -> T:
|
165
|
+
def get(self) -> T | str:
|
166
|
+
value = self.value.get_secret_value()
|
155
167
|
try:
|
156
|
-
value
|
157
|
-
|
168
|
+
if isinstance(value, (str)):
|
169
|
+
return json.loads(value)
|
170
|
+
return value
|
158
171
|
except (TypeError, json.JSONDecodeError):
|
159
172
|
return value
|
prefect/blocks/webhook.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
from
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Any
|
2
4
|
|
3
5
|
from httpx import AsyncClient, AsyncHTTPTransport, Response
|
4
|
-
from pydantic import Field, SecretStr
|
6
|
+
from pydantic import Field, HttpUrl, SecretStr
|
5
7
|
from typing_extensions import Literal
|
6
8
|
|
7
9
|
from prefect.blocks.core import Block
|
@@ -21,7 +23,7 @@ class Webhook(Block):
|
|
21
23
|
|
22
24
|
_block_type_name = "Webhook"
|
23
25
|
_logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/c7247cb359eb6cf276734d4b1fbf00fb8930e89e-250x250.png" # type: ignore
|
24
|
-
_documentation_url = (
|
26
|
+
_documentation_url = HttpUrl(
|
25
27
|
"https://docs.prefect.io/latest/automate/events/webhook-triggers"
|
26
28
|
)
|
27
29
|
|
@@ -50,13 +52,13 @@ class Webhook(Block):
|
|
50
52
|
description="Whether or not to enforce a secure connection to the webhook.",
|
51
53
|
)
|
52
54
|
|
53
|
-
def block_initialization(self):
|
55
|
+
def block_initialization(self) -> None:
|
54
56
|
if self.verify:
|
55
57
|
self._client = AsyncClient(transport=_http_transport)
|
56
58
|
else:
|
57
59
|
self._client = AsyncClient(transport=_insecure_http_transport)
|
58
60
|
|
59
|
-
async def call(self, payload:
|
61
|
+
async def call(self, payload: dict[str, Any] | None = None) -> Response:
|
60
62
|
"""
|
61
63
|
Call the webhook.
|
62
64
|
|
prefect/cache_policies.py
CHANGED
@@ -2,7 +2,7 @@ import inspect
|
|
2
2
|
from copy import deepcopy
|
3
3
|
from dataclasses import dataclass, field
|
4
4
|
from pathlib import Path
|
5
|
-
from typing import TYPE_CHECKING, Any, Callable, Dict,
|
5
|
+
from typing import TYPE_CHECKING, Any, Callable, Dict, Literal, Optional, Union
|
6
6
|
|
7
7
|
from typing_extensions import Self
|
8
8
|
|
@@ -73,8 +73,8 @@ class CachePolicy:
|
|
73
73
|
def compute_key(
|
74
74
|
self,
|
75
75
|
task_ctx: TaskRunContext,
|
76
|
-
inputs:
|
77
|
-
flow_parameters:
|
76
|
+
inputs: dict[str, Any],
|
77
|
+
flow_parameters: dict[str, Any],
|
78
78
|
**kwargs: Any,
|
79
79
|
) -> Optional[str]:
|
80
80
|
raise NotImplementedError
|
@@ -132,14 +132,14 @@ class CacheKeyFnPolicy(CachePolicy):
|
|
132
132
|
|
133
133
|
# making it optional for tests
|
134
134
|
cache_key_fn: Optional[
|
135
|
-
Callable[["TaskRunContext",
|
135
|
+
Callable[["TaskRunContext", dict[str, Any]], Optional[str]]
|
136
136
|
] = None
|
137
137
|
|
138
138
|
def compute_key(
|
139
139
|
self,
|
140
140
|
task_ctx: TaskRunContext,
|
141
|
-
inputs:
|
142
|
-
flow_parameters:
|
141
|
+
inputs: dict[str, Any],
|
142
|
+
flow_parameters: dict[str, Any],
|
143
143
|
**kwargs: Any,
|
144
144
|
) -> Optional[str]:
|
145
145
|
if self.cache_key_fn:
|
@@ -155,13 +155,13 @@ class CompoundCachePolicy(CachePolicy):
|
|
155
155
|
Any keys that return `None` will be ignored.
|
156
156
|
"""
|
157
157
|
|
158
|
-
policies:
|
158
|
+
policies: list[CachePolicy] = field(default_factory=list)
|
159
159
|
|
160
160
|
def compute_key(
|
161
161
|
self,
|
162
162
|
task_ctx: TaskRunContext,
|
163
|
-
inputs:
|
164
|
-
flow_parameters:
|
163
|
+
inputs: dict[str, Any],
|
164
|
+
flow_parameters: dict[str, Any],
|
165
165
|
**kwargs: Any,
|
166
166
|
) -> Optional[str]:
|
167
167
|
keys: list[str] = []
|
@@ -183,14 +183,14 @@ class CompoundCachePolicy(CachePolicy):
|
|
183
183
|
class _None(CachePolicy):
|
184
184
|
"""
|
185
185
|
Policy that always returns `None` for the computed cache key.
|
186
|
-
This policy prevents persistence.
|
186
|
+
This policy prevents persistence and avoids caching entirely.
|
187
187
|
"""
|
188
188
|
|
189
189
|
def compute_key(
|
190
190
|
self,
|
191
191
|
task_ctx: TaskRunContext,
|
192
|
-
inputs:
|
193
|
-
flow_parameters:
|
192
|
+
inputs: dict[str, Any],
|
193
|
+
flow_parameters: dict[str, Any],
|
194
194
|
**kwargs: Any,
|
195
195
|
) -> Optional[str]:
|
196
196
|
return None
|
@@ -209,8 +209,8 @@ class TaskSource(CachePolicy):
|
|
209
209
|
def compute_key(
|
210
210
|
self,
|
211
211
|
task_ctx: TaskRunContext,
|
212
|
-
inputs: Optional[
|
213
|
-
flow_parameters: Optional[
|
212
|
+
inputs: Optional[dict[str, Any]],
|
213
|
+
flow_parameters: Optional[dict[str, Any]],
|
214
214
|
**kwargs: Any,
|
215
215
|
) -> Optional[str]:
|
216
216
|
if not task_ctx:
|
@@ -236,8 +236,8 @@ class FlowParameters(CachePolicy):
|
|
236
236
|
def compute_key(
|
237
237
|
self,
|
238
238
|
task_ctx: TaskRunContext,
|
239
|
-
inputs:
|
240
|
-
flow_parameters:
|
239
|
+
inputs: dict[str, Any],
|
240
|
+
flow_parameters: dict[str, Any],
|
241
241
|
**kwargs: Any,
|
242
242
|
) -> Optional[str]:
|
243
243
|
if not flow_parameters:
|
@@ -255,8 +255,8 @@ class RunId(CachePolicy):
|
|
255
255
|
def compute_key(
|
256
256
|
self,
|
257
257
|
task_ctx: TaskRunContext,
|
258
|
-
inputs:
|
259
|
-
flow_parameters:
|
258
|
+
inputs: dict[str, Any],
|
259
|
+
flow_parameters: dict[str, Any],
|
260
260
|
**kwargs: Any,
|
261
261
|
) -> Optional[str]:
|
262
262
|
if not task_ctx:
|
@@ -273,13 +273,13 @@ class Inputs(CachePolicy):
|
|
273
273
|
Policy that computes a cache key based on a hash of the runtime inputs provided to the task..
|
274
274
|
"""
|
275
275
|
|
276
|
-
exclude:
|
276
|
+
exclude: list[str] = field(default_factory=list)
|
277
277
|
|
278
278
|
def compute_key(
|
279
279
|
self,
|
280
280
|
task_ctx: TaskRunContext,
|
281
|
-
inputs:
|
282
|
-
flow_parameters:
|
281
|
+
inputs: dict[str, Any],
|
282
|
+
flow_parameters: dict[str, Any],
|
283
283
|
**kwargs: Any,
|
284
284
|
) -> Optional[str]:
|
285
285
|
hashed_inputs = {}
|
@@ -302,7 +302,7 @@ class Inputs(CachePolicy):
|
|
302
302
|
"like locks, file handles, or other system resources.\n\n"
|
303
303
|
"To resolve this, you can:\n"
|
304
304
|
" 1. Exclude these arguments by defining a custom `cache_key_fn`\n"
|
305
|
-
" 2. Disable caching by passing `cache_policy=
|
305
|
+
" 2. Disable caching by passing `cache_policy=NO_CACHE`\n"
|
306
306
|
)
|
307
307
|
raise ValueError(msg) from exc
|
308
308
|
|
@@ -314,6 +314,7 @@ class Inputs(CachePolicy):
|
|
314
314
|
|
315
315
|
INPUTS = Inputs()
|
316
316
|
NONE = _None()
|
317
|
+
NO_CACHE = _None()
|
317
318
|
TASK_SOURCE = TaskSource()
|
318
319
|
FLOW_PARAMETERS = FlowParameters()
|
319
320
|
RUN_ID = RunId()
|