prefect-client 3.7.4.dev4__py3-none-any.whl → 3.7.5.dev2__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/_build_info.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # Generated by versioningit
2
- __version__ = "3.7.4.dev4"
3
- __build_date__ = "2026-06-05 09:16:11.920641+00:00"
4
- __git_commit__ = "0bad21f4ce99db95716f64cc2eab836eb274b52c"
2
+ __version__ = "3.7.5.dev2"
3
+ __build_date__ = "2026-06-09 09:16:08.541278+00:00"
4
+ __git_commit__ = "d858cb6725864c9a993be6a6633009b03b5e6f5e"
5
5
  __dirty__ = False
@@ -26,6 +26,26 @@ MAX_ITERATIONS = 1000
26
26
  MAX_RRULE_LENGTH = 6500
27
27
 
28
28
 
29
+ def _iana_timezone_name(tzinfo: datetime.tzinfo) -> str:
30
+ """Return a valid IANA timezone name for *tzinfo*, or `"UTC"`."""
31
+ for attr in ("key", "name"):
32
+ value: Optional[str] = getattr(tzinfo, attr, None)
33
+ if value and is_valid_timezone(value):
34
+ return value
35
+
36
+ filename: Optional[str] = getattr(tzinfo, "_filename", None)
37
+ if filename:
38
+ normalized = filename.replace("\\", "/")
39
+ marker = "/zoneinfo/"
40
+ idx = normalized.find(marker)
41
+ if idx != -1:
42
+ candidate = normalized[idx + len(marker) :]
43
+ if candidate and is_valid_timezone(candidate):
44
+ return candidate
45
+
46
+ return "UTC"
47
+
48
+
29
49
  def is_valid_timezone(v: str) -> bool:
30
50
  """
31
51
  Validate that the provided timezone is a valid IANA timezone.
@@ -204,26 +224,27 @@ class RRuleSchedule(PrefectBaseModel):
204
224
  if isinstance(rrule, dateutil.rrule.rrule):
205
225
  dtstart = _rrule_dt(rrule)
206
226
  if dtstart and dtstart.tzinfo is not None:
207
- timezone = dtstart.tzinfo.tzname(dtstart)
227
+ timezone = _iana_timezone_name(dtstart.tzinfo)
208
228
  else:
209
229
  timezone = "UTC"
210
230
  return RRuleSchedule(rrule=str(rrule), timezone=timezone)
211
231
  rrules = _rrule(rrule)
212
232
  dtstarts = [dts for rr in rrules if (dts := _rrule_dt(rr)) is not None]
213
233
  unique_dstarts = set(d.astimezone(ZoneInfo("UTC")) for d in dtstarts)
214
- unique_timezones = set(d.tzinfo for d in dtstarts if d.tzinfo is not None)
234
+ unique_tz_names = set(
235
+ _iana_timezone_name(d.tzinfo) for d in dtstarts if d.tzinfo is not None
236
+ )
215
237
 
216
- if len(unique_timezones) > 1:
238
+ if len(unique_tz_names) > 1:
217
239
  raise ValueError(
218
- f"rruleset has too many dtstart timezones: {unique_timezones}"
240
+ f"rruleset has too many dtstart timezones: {unique_tz_names}"
219
241
  )
220
242
 
221
243
  if len(unique_dstarts) > 1:
222
244
  raise ValueError(f"rruleset has too many dtstarts: {unique_dstarts}")
223
245
 
224
- if unique_dstarts and unique_timezones:
225
- [unique_tz] = unique_timezones
226
- timezone = unique_tz.tzname(dtstarts[0])
246
+ if unique_dstarts and unique_tz_names:
247
+ [timezone] = unique_tz_names
227
248
  else:
228
249
  timezone = "UTC"
229
250
 
@@ -278,6 +278,33 @@ def _interval_schedule_to_dict(schedule: IntervalSchedule) -> dict[str, Any]:
278
278
  return schedule_config
279
279
 
280
280
 
281
+ def _deployment_already_saved_to_prefect_file(
282
+ deployment: dict[str, Any],
283
+ prefect_file: Path = Path("prefect.yaml"),
284
+ ) -> bool:
285
+ """
286
+ Return True if `prefect.yaml` already contains a deployment entry matching the
287
+ given deployment's name and entrypoint.
288
+
289
+ Used to decide whether the interactive `prefect deploy` flow should offer to
290
+ persist a newly-created deployment: a deployment that is already declared in
291
+ the file does not need to be saved again, but a brand-new one (even when the
292
+ file otherwise exists) should still be offered up for saving.
293
+ """
294
+ if not prefect_file.exists():
295
+ return False
296
+
297
+ with prefect_file.open(mode="r") as f:
298
+ contents = yaml.safe_load(f) or {}
299
+
300
+ for existing in contents.get("deployments") or []:
301
+ if existing.get("name") == deployment.get("name") and existing.get(
302
+ "entrypoint"
303
+ ) == deployment.get("entrypoint"):
304
+ return True
305
+ return False
306
+
307
+
281
308
  def _save_deployment_to_prefect_file(
282
309
  deployment: dict[str, Any],
283
310
  build_steps: list[dict[str, Any]] | None = None,
prefect/flows.py CHANGED
@@ -706,7 +706,11 @@ class Flow(Generic[P, R]):
706
706
  from fastapi.encoders import jsonable_encoder
707
707
 
708
708
  serialized_parameters[key] = jsonable_encoder(value)
709
- except (TypeError, ValueError):
709
+ except (TypeError, ValueError, RecursionError):
710
+ # `jsonable_encoder` recurses into unknown objects with no cycle
711
+ # or depth limit, so a deeply-nested or self-referential value
712
+ # raises `RecursionError`. Treat it like any other unserializable
713
+ # value and fall back to the placeholder below.
710
714
  logger.debug(
711
715
  f"Parameter {key!r} for flow {self.name!r} is unserializable. "
712
716
  f"Type {type(value).__name__!r} and will not be stored "
@@ -25,8 +25,10 @@ import prefect.server.models as models
25
25
  import prefect.server.schemas as schemas
26
26
  from prefect._internal.uuid7 import uuid7
27
27
  from prefect.client.schemas.worker_channel import (
28
+ CLEANUP_DELIVERY_CAPABILITY,
28
29
  WORK_POOL_SNAPSHOT_CAPABILITY,
29
30
  WORKER_HEARTBEAT_CAPABILITY,
31
+ WorkerChannelCapability,
30
32
  WorkerChannelCloseReason,
31
33
  WorkerChannelProtocolError,
32
34
  WorkerHelloFrame,
@@ -48,6 +50,10 @@ from prefect.server.schemas.statuses import WorkQueueStatus
48
50
  from prefect.server.utilities import subscriptions
49
51
  from prefect.server.utilities import worker_channel as worker_channel_utils
50
52
  from prefect.server.utilities.server import PrefectRouter
53
+ from prefect.server.worker_communication.cleanup_queue import (
54
+ WorkerCleanupQueue,
55
+ get_worker_cleanup_queue,
56
+ )
51
57
  from prefect.types import DateTime
52
58
  from prefect.types._datetime import now
53
59
 
@@ -61,7 +67,7 @@ router: PrefectRouter = PrefectRouter(
61
67
  )
62
68
  logger: Logger = get_logger("prefect.server.api.workers")
63
69
 
64
- _OSS_WORKER_CHANNEL_ACCEPTED_CAPABILITIES = [
70
+ _OSS_WORKER_CHANNEL_REQUIRED_CAPABILITIES: list[WorkerChannelCapability] = [
65
71
  WORKER_HEARTBEAT_CAPABILITY,
66
72
  WORK_POOL_SNAPSHOT_CAPABILITY,
67
73
  ]
@@ -183,6 +189,26 @@ class WorkerChannelWorkPoolUpdateEvent:
183
189
  changed_fields: dict[str, dict[str, Any]]
184
190
 
185
191
 
192
+ def _worker_requested_cleanup_delivery(hello: WorkerHelloFrame) -> bool:
193
+ return (
194
+ CLEANUP_DELIVERY_CAPABILITY in hello.payload.requested_capabilities
195
+ and bool(hello.payload.handled_cleanup_kinds)
196
+ and hello.payload.max_cleanup_concurrency > 0
197
+ )
198
+
199
+
200
+ def _accepted_worker_channel_capabilities(
201
+ hello: WorkerHelloFrame,
202
+ *,
203
+ cleanup_queue_available: bool,
204
+ ) -> list[WorkerChannelCapability]:
205
+ accepted = list(_OSS_WORKER_CHANNEL_REQUIRED_CAPABILITIES)
206
+ if cleanup_queue_available and _worker_requested_cleanup_delivery(hello):
207
+ accepted.append(CLEANUP_DELIVERY_CAPABILITY)
208
+
209
+ return accepted
210
+
211
+
186
212
  async def _receive_worker_hello(websocket: WebSocket) -> WorkerHelloFrame:
187
213
  try:
188
214
  message = await websocket.receive_json()
@@ -290,6 +316,7 @@ async def _build_worker_ready_frame(
290
316
  session: AsyncSession,
291
317
  work_pool_name: str,
292
318
  hello: WorkerHelloFrame,
319
+ cleanup_queue_available: bool,
293
320
  ) -> tuple[WorkerReadyFrame, WorkerChannelWorkPoolUpdateEvent | None]:
294
321
  try:
295
322
  selected_channel_version = select_worker_channel_version(
@@ -371,7 +398,10 @@ async def _build_worker_ready_frame(
371
398
  )
372
399
 
373
400
  requested_capabilities = list(dict.fromkeys(hello.payload.requested_capabilities))
374
- accepted = _OSS_WORKER_CHANNEL_ACCEPTED_CAPABILITIES
401
+ accepted = _accepted_worker_channel_capabilities(
402
+ hello,
403
+ cleanup_queue_available=cleanup_queue_available,
404
+ )
375
405
  accepted_set = set(accepted)
376
406
  rejected = [
377
407
  capability
@@ -393,7 +423,11 @@ async def _build_worker_ready_frame(
393
423
  ),
394
424
  "accepted_capabilities": accepted,
395
425
  "rejected_capabilities": rejected,
396
- "effective_max_cleanup_concurrency": 0,
426
+ "effective_max_cleanup_concurrency": (
427
+ hello.payload.max_cleanup_concurrency
428
+ if CLEANUP_DELIVERY_CAPABILITY in accepted_set
429
+ else 0
430
+ ),
397
431
  "resolved_work_queues": [
398
432
  {"id": work_queue.id, "name": work_queue.name}
399
433
  for work_queue in work_queues
@@ -1058,6 +1092,16 @@ async def worker_channel_connect(
1058
1092
 
1059
1093
  try:
1060
1094
  hello = await _receive_worker_hello(websocket)
1095
+ cleanup_queue: WorkerCleanupQueue | None = None
1096
+ if _worker_requested_cleanup_delivery(hello):
1097
+ try:
1098
+ cleanup_queue = get_worker_cleanup_queue()
1099
+ except Exception:
1100
+ logger.exception(
1101
+ "Worker cleanup delivery queue initialization failed; "
1102
+ "rejecting cleanup delivery capability"
1103
+ )
1104
+
1061
1105
  async with worker_channel_utils.messaging.ephemeral_subscription(
1062
1106
  worker_channel_utils.WORKER_CHANNEL_SNAPSHOT_TOPIC,
1063
1107
  ) as consumer_kwargs:
@@ -1066,6 +1110,7 @@ async def worker_channel_connect(
1066
1110
  session=session,
1067
1111
  work_pool_name=work_pool_name,
1068
1112
  hello=hello,
1113
+ cleanup_queue_available=cleanup_queue is not None,
1069
1114
  )
1070
1115
 
1071
1116
  if work_pool_update_event is not None:
@@ -1094,6 +1139,17 @@ async def worker_channel_connect(
1094
1139
  work_pool_id=ready.payload.initial_snapshot.work_pool.id,
1095
1140
  consumer_id=hello.payload.consumer_id,
1096
1141
  worker_name=hello.payload.worker_name,
1142
+ cleanup_queue=(
1143
+ cleanup_queue
1144
+ if CLEANUP_DELIVERY_CAPABILITY
1145
+ in ready.payload.accepted_capabilities
1146
+ else None
1147
+ ),
1148
+ cleanup_kinds=tuple(hello.payload.handled_cleanup_kinds),
1149
+ cleanup_work_queue_ids=tuple(
1150
+ work_queue.id for work_queue in ready.payload.resolved_work_queues
1151
+ ),
1152
+ max_cleanup_concurrency=ready.payload.effective_max_cleanup_concurrency,
1097
1153
  )
1098
1154
  await connection.run(ready, consumer_kwargs)
1099
1155
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prefect-client
3
- Version: 3.7.4.dev4
3
+ Version: 3.7.5.dev2
4
4
  Summary: Workflow orchestration and management.
5
5
  Project-URL: Changelog, https://github.com/PrefectHQ/prefect/releases
6
6
  Project-URL: Documentation, https://docs.prefect.io
@@ -2,7 +2,7 @@ prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
2
2
  prefect/AGENTS.md,sha256=SNF9LRWtYJ2pIHUVswgtMaWlloKszhNTL6dhPreh5kc,10484
3
3
  prefect/__init__.py,sha256=Z8rwfLbEOLh-5WcznTZP3FG2-9UgGZxY-prj8sL0-Qk,6828
4
4
  prefect/__main__.py,sha256=WFjw3kaYJY6pOTA7WDOgqjsz8zUEUZHCcj3P5wyVa-g,66
5
- prefect/_build_info.py,sha256=WU2mNlfcFQA8kDMsDtikipEG6vTO45zBeh_8fxO-rg0,185
5
+ prefect/_build_info.py,sha256=MI6U3f99m0YbYm29YRaf-ZheYXnRNX5o_CuzpKn0Fq0,185
6
6
  prefect/_flow_run_suspension.py,sha256=5zTTB7ZIBHzoS0pVrhNn23-9hK51qZ3CQA6C-azluC0,4144
7
7
  prefect/agent.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
8
8
  prefect/artifacts.py,sha256=ZdMLJeJGK82hibtRzbsVa-g95dMa0D2UP1LiESoXmf4,23951
@@ -14,7 +14,7 @@ prefect/exceptions.py,sha256=S7H01rpzGz-2Z6NcZVPdwy-3cZnvx51XCBRp7Nsp5xI,12599
14
14
  prefect/filesystems.py,sha256=O3zvpFWTDRyrpJ0UJXSsRdLjy2dkch2_7ZBc9ncD8cQ,26884
15
15
  prefect/flow_engine.py,sha256=v4-olTdSucuxYpfbkvjeUalODFfG0t96nQ0qkDn8FUg,87580
16
16
  prefect/flow_runs.py,sha256=0LiTnz9B24kD5wGc-EiKmlg8GJb90ua6kMHv3ZH-YfA,29595
17
- prefect/flows.py,sha256=74dswq5Tvaf0sNRFwq-g0WEUE8xaBi9ra4GpxVb8KJY,146276
17
+ prefect/flows.py,sha256=zrLb-BYwlDznvKrVRGqbUgRNOKUvMuFA1o6ewWbkHzw,146598
18
18
  prefect/futures.py,sha256=XOxNAjlW-hMfSRZvm3ecCNdpKIUzM283832Uq92h8pI,31276
19
19
  prefect/main.py,sha256=di4yjyllPls3P421pBPhDlkmpSn2KvJZVM9sIQo8qzo,2648
20
20
  prefect/plugins.py,sha256=ZeTd95NHo8IKCTena5g7buaHGG9Bb2NDd_t-ljbzLFg,2558
@@ -193,7 +193,7 @@ prefect/client/schemas/events.py,sha256=yTbuFSM1AgAs66mS-ex-FqQqPMOXB6X5FUsL11sB
193
193
  prefect/client/schemas/filters.py,sha256=g_YFDQUfNpiZv0sPlnlzPeUXpFHHuP2AiHIi52syoTY,38687
194
194
  prefect/client/schemas/objects.py,sha256=iqxt5IRIRrcwNnYha90G_1j74tBzkrhbTAYmohaSHuc,61024
195
195
  prefect/client/schemas/responses.py,sha256=8Ibsy3s3K2jm2gm15N-DiMh5_bOVUdRPSagkUNTBv84,19297
196
- prefect/client/schemas/schedules.py,sha256=wwi48rYK7Id4sR8V4PfdB-2O_lhIl2R6KNGS634fEOI,14856
196
+ prefect/client/schemas/schedules.py,sha256=dhynyu2ua9M0Bd8MhVuDssjXNOxfdVHXOgxx2lLjZtg,15526
197
197
  prefect/client/schemas/sorting.py,sha256=L-2Mx-igZPtsUoRUguTcG3nIEstMEMPD97NwPM2Ox5s,2579
198
198
  prefect/client/schemas/worker_channel.py,sha256=RVta43ctg5NmIP-4vpwMv602vIAn-lSMp6RwJ8CPTsw,19594
199
199
  prefect/client/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -217,7 +217,7 @@ prefect/concurrency/v1/services.py,sha256=ppVCllzb2qeKc-xntobFu45dEh3J-ZTtLDPuHr
217
217
  prefect/concurrency/v1/sync.py,sha256=N_CHNkbV_eNQvDsJoJaehQo8H68MFlX6B1ObDZuYlTM,2112
218
218
  prefect/deployments/AGENTS.md,sha256=jiYmO4WaKYNvvUXojVaNgQJcuMrz-ik-XemVP19LdjY,3979
219
219
  prefect/deployments/__init__.py,sha256=_j4kxNjtKNSsI3C8d0skqpu3fR_rnLslw774b1iflzM,1094
220
- prefect/deployments/base.py,sha256=RBvEKwNyLbmLTWhZZwr6-MNQMZ8egG6oPILebdFpg4g,12132
220
+ prefect/deployments/base.py,sha256=ue8T0AqVHU0un2efsrNatJIkHEGc-1SIqF2PVg7F1kQ,13107
221
221
  prefect/deployments/deployments.py,sha256=K3Rgnpjxo_T8I8LMwlq24OKqZiZBTE8-YnPg-YGUStM,171
222
222
  prefect/deployments/flow_runs.py,sha256=RYnAfQb95KczY2Du6DesRn3HwVpw2iAyLAzCKxBGoW0,17065
223
223
  prefect/deployments/runner.py,sha256=nane16WsAQ9e1OOozRWiUtIZAEY2nuYK-XIdw32DOWc,77543
@@ -329,7 +329,7 @@ prefect/server/api/templates.py,sha256=EW5aJOuvSXBeShd5VIygI1f9W0uTUpGb32ADrL9LG
329
329
  prefect/server/api/validation.py,sha256=DPofXjLFejs_qusUQgzRkG89X2EFoviAy9J08pnNvyM,14543
330
330
  prefect/server/api/variables.py,sha256=8Ursuf20R5zXUS015ZexCH72K7R6Yv76ehkr_l3Xt0k,6186
331
331
  prefect/server/api/work_queues.py,sha256=wEb_Hx1MlTrg5juOguk5nvGKwLmTGSIHEUyt_-2GJiE,11957
332
- prefect/server/api/workers.py,sha256=NS6aAZn0EPjbJDZJg6-t4vjFytdQGBO64sAi6NWeS08,42909
332
+ prefect/server/api/workers.py,sha256=Z_K6h1uIuJ7IwRGGL0brpcZbVsxbMa1PFRdV8okyYhY,45063
333
333
  prefect/server/api/collections_data/views/aggregate-worker-metadata.json,sha256=otKGMKJUh_ySkQyNBFCe84E6VRbuR-Z7_676D21YKsw,81525
334
334
  prefect/server/api/static/prefect-logo-mark-gradient.png,sha256=ylRjJkI_JHCw8VbQasNnXQHwZW-sH-IQiUGSD3aWP1E,73430
335
335
  prefect/server/api/ui/__init__.py,sha256=TCXO4ZUZCqCbm2QoNvWNTErkzWiX2nSACuO-0Tiomvg,93
@@ -441,7 +441,7 @@ prefect/workers/_worker_channel/_protocol.py,sha256=GpCNh1o3qmmqHA_UOOTge1QVC6IR
441
441
  prefect/workers/_worker_channel/_state.py,sha256=eQTFZtAVDZH1vVWps3SdeY6aW3qu2wx1UKYQXK3AyuE,5369
442
442
  prefect/workers/_worker_channel/_sync.py,sha256=G5G8_UaQYbeLebi5Mb1Z_KgGfXfyjXo5uT9la5_zwqY,14984
443
443
  prefect/workers/_worker_channel/_transport.py,sha256=_8aWX16tdbZcpqBg4HCX_vCzl2FX47jsYPKMPLAANRA,9181
444
- prefect_client-3.7.4.dev4.dist-info/METADATA,sha256=EYFFmUZzlJxZSMymnKmFW8N7gLOFm1BsIQbCF2aPx1Y,7527
445
- prefect_client-3.7.4.dev4.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
446
- prefect_client-3.7.4.dev4.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
447
- prefect_client-3.7.4.dev4.dist-info/RECORD,,
444
+ prefect_client-3.7.5.dev2.dist-info/METADATA,sha256=1xTQB5z_FyMNprGwjWQlf7TqNgU3mhzkqc3haWiEGs0,7527
445
+ prefect_client-3.7.5.dev2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
446
+ prefect_client-3.7.5.dev2.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
447
+ prefect_client-3.7.5.dev2.dist-info/RECORD,,