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.
Files changed (133) hide show
  1. prefect/_experimental/sla/__init__.py +0 -0
  2. prefect/_experimental/sla/client.py +92 -0
  3. prefect/_experimental/sla/objects.py +61 -0
  4. prefect/_internal/concurrency/services.py +2 -2
  5. prefect/_internal/concurrency/threads.py +6 -0
  6. prefect/_internal/retries.py +6 -3
  7. prefect/_internal/schemas/validators.py +6 -4
  8. prefect/_version.py +3 -3
  9. prefect/artifacts.py +4 -1
  10. prefect/automations.py +236 -30
  11. prefect/blocks/__init__.py +3 -3
  12. prefect/blocks/abstract.py +57 -31
  13. prefect/blocks/core.py +181 -82
  14. prefect/blocks/notifications.py +134 -73
  15. prefect/blocks/redis.py +13 -9
  16. prefect/blocks/system.py +24 -11
  17. prefect/blocks/webhook.py +7 -5
  18. prefect/cache_policies.py +23 -22
  19. prefect/client/orchestration/__init__.py +103 -2006
  20. prefect/client/orchestration/_automations/__init__.py +0 -0
  21. prefect/client/orchestration/_automations/client.py +329 -0
  22. prefect/client/orchestration/_blocks_documents/__init__.py +0 -0
  23. prefect/client/orchestration/_blocks_documents/client.py +334 -0
  24. prefect/client/orchestration/_blocks_schemas/__init__.py +0 -0
  25. prefect/client/orchestration/_blocks_schemas/client.py +200 -0
  26. prefect/client/orchestration/_blocks_types/__init__.py +0 -0
  27. prefect/client/orchestration/_blocks_types/client.py +380 -0
  28. prefect/client/orchestration/_deployments/__init__.py +0 -0
  29. prefect/client/orchestration/_deployments/client.py +1128 -0
  30. prefect/client/orchestration/_flow_runs/__init__.py +0 -0
  31. prefect/client/orchestration/_flow_runs/client.py +903 -0
  32. prefect/client/orchestration/_flows/__init__.py +0 -0
  33. prefect/client/orchestration/_flows/client.py +343 -0
  34. prefect/client/orchestration/_logs/client.py +16 -14
  35. prefect/client/schemas/__init__.py +68 -28
  36. prefect/client/schemas/objects.py +5 -5
  37. prefect/client/utilities.py +3 -3
  38. prefect/context.py +15 -1
  39. prefect/deployments/base.py +13 -4
  40. prefect/deployments/flow_runs.py +5 -1
  41. prefect/deployments/runner.py +37 -1
  42. prefect/deployments/steps/core.py +1 -1
  43. prefect/deployments/steps/pull.py +8 -3
  44. prefect/deployments/steps/utility.py +2 -2
  45. prefect/docker/docker_image.py +13 -9
  46. prefect/engine.py +33 -11
  47. prefect/events/cli/automations.py +4 -4
  48. prefect/events/clients.py +17 -14
  49. prefect/events/schemas/automations.py +12 -8
  50. prefect/events/schemas/events.py +5 -1
  51. prefect/events/worker.py +1 -1
  52. prefect/filesystems.py +7 -3
  53. prefect/flow_engine.py +64 -47
  54. prefect/flows.py +128 -74
  55. prefect/futures.py +14 -7
  56. prefect/infrastructure/provisioners/__init__.py +2 -0
  57. prefect/infrastructure/provisioners/cloud_run.py +4 -4
  58. prefect/infrastructure/provisioners/coiled.py +249 -0
  59. prefect/infrastructure/provisioners/container_instance.py +4 -3
  60. prefect/infrastructure/provisioners/ecs.py +55 -43
  61. prefect/infrastructure/provisioners/modal.py +5 -4
  62. prefect/input/actions.py +5 -1
  63. prefect/input/run_input.py +157 -43
  64. prefect/logging/configuration.py +3 -3
  65. prefect/logging/filters.py +2 -2
  66. prefect/logging/formatters.py +15 -11
  67. prefect/logging/handlers.py +24 -14
  68. prefect/logging/highlighters.py +5 -5
  69. prefect/logging/loggers.py +28 -18
  70. prefect/logging/logging.yml +1 -1
  71. prefect/main.py +3 -1
  72. prefect/results.py +166 -86
  73. prefect/runner/runner.py +38 -29
  74. prefect/runner/server.py +3 -1
  75. prefect/runner/storage.py +18 -18
  76. prefect/runner/submit.py +19 -12
  77. prefect/runtime/deployment.py +15 -8
  78. prefect/runtime/flow_run.py +19 -6
  79. prefect/runtime/task_run.py +7 -3
  80. prefect/settings/base.py +17 -7
  81. prefect/settings/legacy.py +4 -4
  82. prefect/settings/models/api.py +4 -3
  83. prefect/settings/models/cli.py +4 -3
  84. prefect/settings/models/client.py +7 -4
  85. prefect/settings/models/cloud.py +9 -3
  86. prefect/settings/models/deployments.py +4 -3
  87. prefect/settings/models/experiments.py +4 -8
  88. prefect/settings/models/flows.py +4 -3
  89. prefect/settings/models/internal.py +4 -3
  90. prefect/settings/models/logging.py +8 -6
  91. prefect/settings/models/results.py +4 -3
  92. prefect/settings/models/root.py +11 -16
  93. prefect/settings/models/runner.py +8 -5
  94. prefect/settings/models/server/api.py +6 -3
  95. prefect/settings/models/server/database.py +120 -25
  96. prefect/settings/models/server/deployments.py +4 -3
  97. prefect/settings/models/server/ephemeral.py +7 -4
  98. prefect/settings/models/server/events.py +6 -3
  99. prefect/settings/models/server/flow_run_graph.py +4 -3
  100. prefect/settings/models/server/root.py +4 -3
  101. prefect/settings/models/server/services.py +15 -12
  102. prefect/settings/models/server/tasks.py +7 -4
  103. prefect/settings/models/server/ui.py +4 -3
  104. prefect/settings/models/tasks.py +10 -5
  105. prefect/settings/models/testing.py +4 -3
  106. prefect/settings/models/worker.py +7 -4
  107. prefect/settings/profiles.py +13 -12
  108. prefect/settings/sources.py +20 -19
  109. prefect/states.py +74 -51
  110. prefect/task_engine.py +43 -33
  111. prefect/task_runners.py +85 -72
  112. prefect/task_runs.py +20 -11
  113. prefect/task_worker.py +14 -9
  114. prefect/tasks.py +36 -28
  115. prefect/telemetry/bootstrap.py +13 -9
  116. prefect/telemetry/run_telemetry.py +15 -13
  117. prefect/telemetry/services.py +4 -0
  118. prefect/transactions.py +3 -3
  119. prefect/types/__init__.py +3 -1
  120. prefect/utilities/_deprecated.py +38 -0
  121. prefect/utilities/engine.py +11 -4
  122. prefect/utilities/filesystem.py +2 -2
  123. prefect/utilities/generics.py +1 -1
  124. prefect/utilities/pydantic.py +21 -36
  125. prefect/utilities/templating.py +25 -1
  126. prefect/workers/base.py +58 -33
  127. prefect/workers/process.py +20 -15
  128. prefect/workers/server.py +4 -5
  129. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/METADATA +3 -3
  130. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/RECORD +133 -114
  131. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/LICENSE +0 -0
  132. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/WHEEL +0 -0
  133. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/top_level.txt +0 -0
@@ -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, LoggerAdapter
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
- LoggerOrAdapter: TypeAlias = Union[Logger, LoggerAdapter]
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: Optional[str] = None) -> None:
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, operation, parameters=None, **execution_kwargs
225
- ) -> Tuple[Any]:
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, operation, parameters=None, size=None, **execution_kwargs
242
- ) -> List[Tuple[Any]]:
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, operation, parameters=None, **execution_kwargs
260
- ) -> List[Tuple[Any]]:
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(self, operation, parameters=None, **execution_kwargs) -> None:
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, operation, seq_of_parameters, **execution_kwargs
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: Union[str, Path],
362
- **download_kwargs: Dict[str, Any],
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: Dict[str, Any],
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: Union[str, Path],
401
- **download_kwargs: Dict[str, Any],
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: Union[str, Path], to_path: str, **upload_kwargs: Dict[str, Any]
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: Dict[str, Any]
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: Union[str, Path],
477
+ from_folder: str | Path,
452
478
  to_folder: str,
453
- **upload_kwargs: Dict[str, Any],
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