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/abstract.py
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import logging
|
4
|
+
import sys
|
1
5
|
from abc import ABC, abstractmethod
|
2
6
|
from contextlib import contextmanager
|
3
|
-
from logging import Logger
|
7
|
+
from logging import Logger
|
4
8
|
from pathlib import Path
|
5
9
|
from typing import (
|
6
10
|
Any,
|
7
11
|
BinaryIO,
|
8
|
-
Dict,
|
9
12
|
Generator,
|
10
13
|
Generic,
|
11
|
-
List,
|
12
|
-
Optional,
|
13
|
-
Tuple,
|
14
14
|
TypeVar,
|
15
15
|
Union,
|
16
16
|
)
|
17
17
|
|
18
|
-
from typing_extensions import Self, TypeAlias
|
18
|
+
from typing_extensions import TYPE_CHECKING, Self, TypeAlias
|
19
19
|
|
20
20
|
from prefect.blocks.core import Block
|
21
21
|
from prefect.exceptions import MissingContextError
|
@@ -23,7 +23,15 @@ from prefect.logging.loggers import get_logger, get_run_logger
|
|
23
23
|
|
24
24
|
T = TypeVar("T")
|
25
25
|
|
26
|
-
|
26
|
+
if sys.version_info >= (3, 12):
|
27
|
+
LoggingAdapter = logging.LoggerAdapter[logging.Logger]
|
28
|
+
else:
|
29
|
+
if TYPE_CHECKING:
|
30
|
+
LoggingAdapter = logging.LoggerAdapter[logging.Logger]
|
31
|
+
else:
|
32
|
+
LoggingAdapter = logging.LoggerAdapter
|
33
|
+
|
34
|
+
LoggerOrAdapter: TypeAlias = Union[Logger, LoggingAdapter]
|
27
35
|
|
28
36
|
|
29
37
|
class CredentialsBlock(Block, ABC):
|
@@ -52,7 +60,7 @@ class CredentialsBlock(Block, ABC):
|
|
52
60
|
return get_logger(self.__class__.__name__)
|
53
61
|
|
54
62
|
@abstractmethod
|
55
|
-
def get_client(self, *args, **kwargs):
|
63
|
+
def get_client(self, *args: Any, **kwargs: Any) -> Any:
|
56
64
|
"""
|
57
65
|
Returns a client for interacting with the external system.
|
58
66
|
|
@@ -94,7 +102,7 @@ class NotificationBlock(Block, ABC):
|
|
94
102
|
return get_logger(self.__class__.__name__)
|
95
103
|
|
96
104
|
@abstractmethod
|
97
|
-
async def notify(self, body: str, subject:
|
105
|
+
async def notify(self, body: str, subject: str | None = None) -> None:
|
98
106
|
"""
|
99
107
|
Send a notification.
|
100
108
|
|
@@ -153,7 +161,7 @@ class JobRun(ABC, Generic[T]): # not a block
|
|
153
161
|
"""
|
154
162
|
|
155
163
|
|
156
|
-
class JobBlock(Block, ABC):
|
164
|
+
class JobBlock(Block, ABC, Generic[T]):
|
157
165
|
"""
|
158
166
|
Block that represents an entity in an external service
|
159
167
|
that can trigger a long running execution.
|
@@ -176,7 +184,7 @@ class JobBlock(Block, ABC):
|
|
176
184
|
return get_logger(self.__class__.__name__)
|
177
185
|
|
178
186
|
@abstractmethod
|
179
|
-
async def trigger(self) -> JobRun:
|
187
|
+
async def trigger(self) -> JobRun[T]:
|
180
188
|
"""
|
181
189
|
Triggers a job run in an external service and returns a JobRun object
|
182
190
|
to track the execution of the run.
|
@@ -221,8 +229,11 @@ class DatabaseBlock(Block, ABC):
|
|
221
229
|
|
222
230
|
@abstractmethod
|
223
231
|
async def fetch_one(
|
224
|
-
self,
|
225
|
-
|
232
|
+
self,
|
233
|
+
operation: str,
|
234
|
+
parameters: dict[str, Any] | None = None,
|
235
|
+
**execution_kwargs: Any,
|
236
|
+
) -> tuple[Any, ...]:
|
226
237
|
"""
|
227
238
|
Fetch a single result from the database.
|
228
239
|
|
@@ -238,8 +249,12 @@ class DatabaseBlock(Block, ABC):
|
|
238
249
|
|
239
250
|
@abstractmethod
|
240
251
|
async def fetch_many(
|
241
|
-
self,
|
242
|
-
|
252
|
+
self,
|
253
|
+
operation: str,
|
254
|
+
parameters: dict[str, Any] | None = None,
|
255
|
+
size: int | None = None,
|
256
|
+
**execution_kwargs: Any,
|
257
|
+
) -> list[tuple[Any, ...]]:
|
243
258
|
"""
|
244
259
|
Fetch a limited number of results from the database.
|
245
260
|
|
@@ -256,8 +271,11 @@ class DatabaseBlock(Block, ABC):
|
|
256
271
|
|
257
272
|
@abstractmethod
|
258
273
|
async def fetch_all(
|
259
|
-
self,
|
260
|
-
|
274
|
+
self,
|
275
|
+
operation: str,
|
276
|
+
parameters: dict[str, Any] | None = None,
|
277
|
+
**execution_kwargs: Any,
|
278
|
+
) -> list[tuple[Any, ...]]:
|
261
279
|
"""
|
262
280
|
Fetch all results from the database.
|
263
281
|
|
@@ -272,7 +290,12 @@ class DatabaseBlock(Block, ABC):
|
|
272
290
|
"""
|
273
291
|
|
274
292
|
@abstractmethod
|
275
|
-
async def execute(
|
293
|
+
async def execute(
|
294
|
+
self,
|
295
|
+
operation: str,
|
296
|
+
parameters: dict[str, Any] | None = None,
|
297
|
+
**execution_kwargs: Any,
|
298
|
+
) -> None:
|
276
299
|
"""
|
277
300
|
Executes an operation on the database. This method is intended to be used
|
278
301
|
for operations that do not return data, such as INSERT, UPDATE, or DELETE.
|
@@ -285,7 +308,10 @@ class DatabaseBlock(Block, ABC):
|
|
285
308
|
|
286
309
|
@abstractmethod
|
287
310
|
async def execute_many(
|
288
|
-
self,
|
311
|
+
self,
|
312
|
+
operation: str,
|
313
|
+
seq_of_parameters: list[dict[str, Any]],
|
314
|
+
**execution_kwargs: Any,
|
289
315
|
) -> None:
|
290
316
|
"""
|
291
317
|
Executes multiple operations on the database. This method is intended to be used
|
@@ -307,7 +333,7 @@ class DatabaseBlock(Block, ABC):
|
|
307
333
|
f"{self.__class__.__name__} does not support async context management."
|
308
334
|
)
|
309
335
|
|
310
|
-
async def __aexit__(self, *args) -> None:
|
336
|
+
async def __aexit__(self, *args: Any) -> None:
|
311
337
|
"""
|
312
338
|
Context management method for async databases.
|
313
339
|
"""
|
@@ -323,7 +349,7 @@ class DatabaseBlock(Block, ABC):
|
|
323
349
|
f"{self.__class__.__name__} does not support context management."
|
324
350
|
)
|
325
351
|
|
326
|
-
def __exit__(self, *args) -> None:
|
352
|
+
def __exit__(self, *args: Any) -> None:
|
327
353
|
"""
|
328
354
|
Context management method for databases.
|
329
355
|
"""
|
@@ -358,8 +384,8 @@ class ObjectStorageBlock(Block, ABC):
|
|
358
384
|
async def download_object_to_path(
|
359
385
|
self,
|
360
386
|
from_path: str,
|
361
|
-
to_path:
|
362
|
-
**download_kwargs:
|
387
|
+
to_path: str | Path,
|
388
|
+
**download_kwargs: Any,
|
363
389
|
) -> Path:
|
364
390
|
"""
|
365
391
|
Downloads an object from the object storage service to a path.
|
@@ -378,7 +404,7 @@ class ObjectStorageBlock(Block, ABC):
|
|
378
404
|
self,
|
379
405
|
from_path: str,
|
380
406
|
to_file_object: BinaryIO,
|
381
|
-
**download_kwargs:
|
407
|
+
**download_kwargs: Any,
|
382
408
|
) -> BinaryIO:
|
383
409
|
"""
|
384
410
|
Downloads an object from the object storage service to a file-like object,
|
@@ -397,8 +423,8 @@ class ObjectStorageBlock(Block, ABC):
|
|
397
423
|
async def download_folder_to_path(
|
398
424
|
self,
|
399
425
|
from_folder: str,
|
400
|
-
to_folder:
|
401
|
-
**download_kwargs:
|
426
|
+
to_folder: str | Path,
|
427
|
+
**download_kwargs: Any,
|
402
428
|
) -> Path:
|
403
429
|
"""
|
404
430
|
Downloads a folder from the object storage service to a path.
|
@@ -414,7 +440,7 @@ class ObjectStorageBlock(Block, ABC):
|
|
414
440
|
|
415
441
|
@abstractmethod
|
416
442
|
async def upload_from_path(
|
417
|
-
self, from_path:
|
443
|
+
self, from_path: str | Path, to_path: str, **upload_kwargs: Any
|
418
444
|
) -> str:
|
419
445
|
"""
|
420
446
|
Uploads an object from a path to the object storage service.
|
@@ -430,7 +456,7 @@ class ObjectStorageBlock(Block, ABC):
|
|
430
456
|
|
431
457
|
@abstractmethod
|
432
458
|
async def upload_from_file_object(
|
433
|
-
self, from_file_object: BinaryIO, to_path: str, **upload_kwargs:
|
459
|
+
self, from_file_object: BinaryIO, to_path: str, **upload_kwargs: Any
|
434
460
|
) -> str:
|
435
461
|
"""
|
436
462
|
Uploads an object to the object storage service from a file-like object,
|
@@ -448,9 +474,9 @@ class ObjectStorageBlock(Block, ABC):
|
|
448
474
|
@abstractmethod
|
449
475
|
async def upload_from_folder(
|
450
476
|
self,
|
451
|
-
from_folder:
|
477
|
+
from_folder: str | Path,
|
452
478
|
to_folder: str,
|
453
|
-
**upload_kwargs:
|
479
|
+
**upload_kwargs: Any,
|
454
480
|
) -> str:
|
455
481
|
"""
|
456
482
|
Uploads a folder to the object storage service from a path.
|
@@ -496,7 +522,7 @@ class SecretBlock(Block, ABC):
|
|
496
522
|
"""
|
497
523
|
|
498
524
|
@abstractmethod
|
499
|
-
async def write_secret(self, secret_data) -> str:
|
525
|
+
async def write_secret(self, secret_data: bytes) -> str:
|
500
526
|
"""
|
501
527
|
Writes secret data to the configured secret in the secret storage service.
|
502
528
|
|