prefect-client 3.1.11__py3-none-any.whl → 3.1.12__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 +66 -0
- prefect/_experimental/sla/objects.py +53 -0
- prefect/_version.py +3 -3
- prefect/automations.py +236 -30
- prefect/blocks/__init__.py +3 -3
- prefect/blocks/abstract.py +53 -30
- prefect/blocks/core.py +181 -82
- prefect/blocks/notifications.py +133 -73
- prefect/blocks/redis.py +13 -9
- prefect/blocks/system.py +24 -11
- prefect/blocks/webhook.py +7 -5
- prefect/cache_policies.py +3 -2
- 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/context.py +15 -1
- prefect/deployments/base.py +6 -0
- prefect/deployments/runner.py +42 -1
- prefect/engine.py +17 -4
- prefect/filesystems.py +6 -2
- prefect/flow_engine.py +47 -38
- prefect/flows.py +10 -1
- prefect/logging/logging.yml +1 -1
- prefect/runner/runner.py +4 -2
- prefect/settings/models/cloud.py +5 -0
- prefect/settings/models/experiments.py +0 -5
- prefect/states.py +57 -38
- prefect/task_runners.py +56 -55
- prefect/task_worker.py +2 -2
- prefect/tasks.py +6 -4
- prefect/telemetry/bootstrap.py +10 -9
- prefect/telemetry/services.py +4 -0
- prefect/utilities/templating.py +25 -1
- prefect/workers/base.py +6 -3
- prefect/workers/process.py +1 -1
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.12.dist-info}/METADATA +2 -2
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.12.dist-info}/RECORD +56 -39
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.12.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.12.dist-info}/WHEEL +0 -0
- {prefect_client-3.1.11.dist-info → prefect_client-3.1.12.dist-info}/top_level.txt +0 -0
prefect/blocks/abstract.py
CHANGED
@@ -1,16 +1,16 @@
|
|
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
|
)
|
@@ -23,7 +23,12 @@ 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
|
+
LoggingAdapter = logging.LoggerAdapter
|
30
|
+
|
31
|
+
LoggerOrAdapter: TypeAlias = Union[Logger, LoggingAdapter]
|
27
32
|
|
28
33
|
|
29
34
|
class CredentialsBlock(Block, ABC):
|
@@ -52,7 +57,7 @@ class CredentialsBlock(Block, ABC):
|
|
52
57
|
return get_logger(self.__class__.__name__)
|
53
58
|
|
54
59
|
@abstractmethod
|
55
|
-
def get_client(self, *args, **kwargs):
|
60
|
+
def get_client(self, *args: Any, **kwargs: Any) -> Any:
|
56
61
|
"""
|
57
62
|
Returns a client for interacting with the external system.
|
58
63
|
|
@@ -94,7 +99,7 @@ class NotificationBlock(Block, ABC):
|
|
94
99
|
return get_logger(self.__class__.__name__)
|
95
100
|
|
96
101
|
@abstractmethod
|
97
|
-
async def notify(self, body: str, subject:
|
102
|
+
async def notify(self, body: str, subject: str | None = None) -> None:
|
98
103
|
"""
|
99
104
|
Send a notification.
|
100
105
|
|
@@ -153,7 +158,7 @@ class JobRun(ABC, Generic[T]): # not a block
|
|
153
158
|
"""
|
154
159
|
|
155
160
|
|
156
|
-
class JobBlock(Block, ABC):
|
161
|
+
class JobBlock(Block, ABC, Generic[T]):
|
157
162
|
"""
|
158
163
|
Block that represents an entity in an external service
|
159
164
|
that can trigger a long running execution.
|
@@ -176,7 +181,7 @@ class JobBlock(Block, ABC):
|
|
176
181
|
return get_logger(self.__class__.__name__)
|
177
182
|
|
178
183
|
@abstractmethod
|
179
|
-
async def trigger(self) -> JobRun:
|
184
|
+
async def trigger(self) -> JobRun[T]:
|
180
185
|
"""
|
181
186
|
Triggers a job run in an external service and returns a JobRun object
|
182
187
|
to track the execution of the run.
|
@@ -221,8 +226,11 @@ class DatabaseBlock(Block, ABC):
|
|
221
226
|
|
222
227
|
@abstractmethod
|
223
228
|
async def fetch_one(
|
224
|
-
self,
|
225
|
-
|
229
|
+
self,
|
230
|
+
operation: str,
|
231
|
+
parameters: dict[str, Any] | None = None,
|
232
|
+
**execution_kwargs: Any,
|
233
|
+
) -> tuple[Any, ...]:
|
226
234
|
"""
|
227
235
|
Fetch a single result from the database.
|
228
236
|
|
@@ -238,8 +246,12 @@ class DatabaseBlock(Block, ABC):
|
|
238
246
|
|
239
247
|
@abstractmethod
|
240
248
|
async def fetch_many(
|
241
|
-
self,
|
242
|
-
|
249
|
+
self,
|
250
|
+
operation: str,
|
251
|
+
parameters: dict[str, Any] | None = None,
|
252
|
+
size: int | None = None,
|
253
|
+
**execution_kwargs: Any,
|
254
|
+
) -> list[tuple[Any, ...]]:
|
243
255
|
"""
|
244
256
|
Fetch a limited number of results from the database.
|
245
257
|
|
@@ -256,8 +268,11 @@ class DatabaseBlock(Block, ABC):
|
|
256
268
|
|
257
269
|
@abstractmethod
|
258
270
|
async def fetch_all(
|
259
|
-
self,
|
260
|
-
|
271
|
+
self,
|
272
|
+
operation: str,
|
273
|
+
parameters: dict[str, Any] | None = None,
|
274
|
+
**execution_kwargs: Any,
|
275
|
+
) -> list[tuple[Any, ...]]:
|
261
276
|
"""
|
262
277
|
Fetch all results from the database.
|
263
278
|
|
@@ -272,7 +287,12 @@ class DatabaseBlock(Block, ABC):
|
|
272
287
|
"""
|
273
288
|
|
274
289
|
@abstractmethod
|
275
|
-
async def execute(
|
290
|
+
async def execute(
|
291
|
+
self,
|
292
|
+
operation: str,
|
293
|
+
parameters: dict[str, Any] | None = None,
|
294
|
+
**execution_kwargs: Any,
|
295
|
+
) -> None:
|
276
296
|
"""
|
277
297
|
Executes an operation on the database. This method is intended to be used
|
278
298
|
for operations that do not return data, such as INSERT, UPDATE, or DELETE.
|
@@ -285,7 +305,10 @@ class DatabaseBlock(Block, ABC):
|
|
285
305
|
|
286
306
|
@abstractmethod
|
287
307
|
async def execute_many(
|
288
|
-
self,
|
308
|
+
self,
|
309
|
+
operation: str,
|
310
|
+
seq_of_parameters: list[dict[str, Any]],
|
311
|
+
**execution_kwargs: Any,
|
289
312
|
) -> None:
|
290
313
|
"""
|
291
314
|
Executes multiple operations on the database. This method is intended to be used
|
@@ -307,7 +330,7 @@ class DatabaseBlock(Block, ABC):
|
|
307
330
|
f"{self.__class__.__name__} does not support async context management."
|
308
331
|
)
|
309
332
|
|
310
|
-
async def __aexit__(self, *args) -> None:
|
333
|
+
async def __aexit__(self, *args: Any) -> None:
|
311
334
|
"""
|
312
335
|
Context management method for async databases.
|
313
336
|
"""
|
@@ -323,7 +346,7 @@ class DatabaseBlock(Block, ABC):
|
|
323
346
|
f"{self.__class__.__name__} does not support context management."
|
324
347
|
)
|
325
348
|
|
326
|
-
def __exit__(self, *args) -> None:
|
349
|
+
def __exit__(self, *args: Any) -> None:
|
327
350
|
"""
|
328
351
|
Context management method for databases.
|
329
352
|
"""
|
@@ -358,8 +381,8 @@ class ObjectStorageBlock(Block, ABC):
|
|
358
381
|
async def download_object_to_path(
|
359
382
|
self,
|
360
383
|
from_path: str,
|
361
|
-
to_path:
|
362
|
-
**download_kwargs:
|
384
|
+
to_path: str | Path,
|
385
|
+
**download_kwargs: Any,
|
363
386
|
) -> Path:
|
364
387
|
"""
|
365
388
|
Downloads an object from the object storage service to a path.
|
@@ -378,7 +401,7 @@ class ObjectStorageBlock(Block, ABC):
|
|
378
401
|
self,
|
379
402
|
from_path: str,
|
380
403
|
to_file_object: BinaryIO,
|
381
|
-
**download_kwargs:
|
404
|
+
**download_kwargs: Any,
|
382
405
|
) -> BinaryIO:
|
383
406
|
"""
|
384
407
|
Downloads an object from the object storage service to a file-like object,
|
@@ -397,8 +420,8 @@ class ObjectStorageBlock(Block, ABC):
|
|
397
420
|
async def download_folder_to_path(
|
398
421
|
self,
|
399
422
|
from_folder: str,
|
400
|
-
to_folder:
|
401
|
-
**download_kwargs:
|
423
|
+
to_folder: str | Path,
|
424
|
+
**download_kwargs: Any,
|
402
425
|
) -> Path:
|
403
426
|
"""
|
404
427
|
Downloads a folder from the object storage service to a path.
|
@@ -414,7 +437,7 @@ class ObjectStorageBlock(Block, ABC):
|
|
414
437
|
|
415
438
|
@abstractmethod
|
416
439
|
async def upload_from_path(
|
417
|
-
self, from_path:
|
440
|
+
self, from_path: str | Path, to_path: str, **upload_kwargs: Any
|
418
441
|
) -> str:
|
419
442
|
"""
|
420
443
|
Uploads an object from a path to the object storage service.
|
@@ -430,7 +453,7 @@ class ObjectStorageBlock(Block, ABC):
|
|
430
453
|
|
431
454
|
@abstractmethod
|
432
455
|
async def upload_from_file_object(
|
433
|
-
self, from_file_object: BinaryIO, to_path: str, **upload_kwargs:
|
456
|
+
self, from_file_object: BinaryIO, to_path: str, **upload_kwargs: Any
|
434
457
|
) -> str:
|
435
458
|
"""
|
436
459
|
Uploads an object to the object storage service from a file-like object,
|
@@ -448,9 +471,9 @@ class ObjectStorageBlock(Block, ABC):
|
|
448
471
|
@abstractmethod
|
449
472
|
async def upload_from_folder(
|
450
473
|
self,
|
451
|
-
from_folder:
|
474
|
+
from_folder: str | Path,
|
452
475
|
to_folder: str,
|
453
|
-
**upload_kwargs:
|
476
|
+
**upload_kwargs: Any,
|
454
477
|
) -> str:
|
455
478
|
"""
|
456
479
|
Uploads a folder to the object storage service from a path.
|
@@ -496,7 +519,7 @@ class SecretBlock(Block, ABC):
|
|
496
519
|
"""
|
497
520
|
|
498
521
|
@abstractmethod
|
499
|
-
async def write_secret(self, secret_data) -> str:
|
522
|
+
async def write_secret(self, secret_data: bytes) -> str:
|
500
523
|
"""
|
501
524
|
Writes secret data to the configured secret in the secret storage service.
|
502
525
|
|