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
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 = "https://cdn.sanity.io/images/3ugk85nk/production/4fcef2294b6eeb423b1332d1ece5156bf296ff96-48x48.png"
47
- _documentation_url = "https://docs.prefect.io/latest/develop/blocks"
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 = "https://cdn.sanity.io/images/3ugk85nk/production/c262ea2c80a2c043564e8763f3370c3db5a6b3e6-48x48.png"
74
- _documentation_url = "https://docs.prefect.io/latest/develop/blocks"
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 = "https://cdn.sanity.io/images/3ugk85nk/production/8b3da9a6621e92108b8e6a75b82e15374e170ff7-48x48.png"
102
- _documentation_url = "https://docs.prefect.io/latest/develop/blocks"
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 = "https://cdn.sanity.io/images/3ugk85nk/production/c6f20e556dd16effda9df16551feecfb5822092b-48x48.png"
132
- _documentation_url = "https://docs.prefect.io/latest/develop/blocks"
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 = self.value.get_secret_value()
157
- return json.loads(value)
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 typing import Optional
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: Optional[dict] = None) -> Response:
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, List, Literal, Optional, Union
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: Dict[str, Any],
77
- flow_parameters: Dict[str, Any],
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", Dict[str, Any]], Optional[str]]
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: Dict[str, Any],
142
- flow_parameters: Dict[str, Any],
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: List[CachePolicy] = field(default_factory=list)
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: Dict[str, Any],
164
- flow_parameters: Dict[str, Any],
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: Dict[str, Any],
193
- flow_parameters: Dict[str, Any],
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[Dict[str, Any]],
213
- flow_parameters: Optional[Dict[str, Any]],
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: Dict[str, Any],
240
- flow_parameters: Dict[str, Any],
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: Dict[str, Any],
259
- flow_parameters: Dict[str, Any],
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: List[str] = field(default_factory=list)
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: Dict[str, Any],
282
- flow_parameters: Dict[str, Any],
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=NONE`\n"
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()