prefect-client 3.4.2.dev3__py3-none-any.whl → 3.4.2.dev5__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.4.2.dev3"
3
- __build_date__ = "2025-05-14 08:08:44.736788+00:00"
4
- __git_commit__ = "951cfc2519e6d8677c42565c3e7b24fd647f31c8"
2
+ __version__ = "3.4.2.dev5"
3
+ __build_date__ = "2025-05-16 08:08:49.856216+00:00"
4
+ __git_commit__ = "554a7b6cb42c108cc8053368259ec6988ef67f74"
5
5
  __dirty__ = False
@@ -1,11 +1,119 @@
1
- from typing import cast
2
- from uuid import UUID
1
+ from __future__ import annotations
3
2
 
4
- from uuid_extensions import uuid7 as _uuid7 # pyright: ignore[reportMissingTypeStubs]
3
+ import os
4
+ import time
5
+ import uuid
6
+ from typing import Callable, Optional
5
7
 
6
8
 
7
- def uuid7() -> UUID:
8
- return cast(UUID, _uuid7())
9
+ def _time_ms() -> int:
10
+ return time.time_ns() // 1_000_000
9
11
 
10
12
 
11
- __all__ = ["uuid7"]
13
+ def uuid7(
14
+ ms: Optional[int] = None,
15
+ time_func: Callable[[], int] = _time_ms,
16
+ ) -> uuid.UUID:
17
+ """
18
+ UUID v7, following the proposed extension to RFC4122 described in
19
+ https://www.ietf.org/id/draft-peabody-dispatch-new-uuid-format-02.html.
20
+ All representations (string, byte array, int) sort chronologically,
21
+ with a potential time resolution of 50ns (if the system clock
22
+ supports this).
23
+
24
+ Parameters
25
+ ----------
26
+
27
+ ms - Optional integer with the whole number of milliseconds
28
+ since Unix epoch, to set the "as of" timestamp.
29
+
30
+ as_type - Optional string to return the UUID in a different format.
31
+ A uuid.UUID (version 7, variant 0x10) is returned unless
32
+ this is one of 'str', 'int', 'hex' or 'bytes'.
33
+
34
+ time_func - Set the time function, which must return integer
35
+ milliseconds since the Unix epoch, midnight on 1-Jan-1970.
36
+ Defaults to time.time_ns()/1e6. This is exposed because
37
+ time.time_ns() may have a low resolution on Windows.
38
+
39
+ Returns
40
+ -------
41
+
42
+ A UUID object, or if as_type is specified, a string, int or
43
+ bytes of length 16.
44
+
45
+ Implementation notes
46
+ --------------------
47
+
48
+ The 128 bits in the UUID are allocated as follows:
49
+ - 36 bits of whole seconds
50
+ - 24 bits of fractional seconds, giving approx 50ns resolution
51
+ - 14 bits of sequential counter, if called repeatedly in same time tick
52
+ - 48 bits of randomness
53
+ plus, at locations defined by RFC4122, 4 bits for the
54
+ uuid version (0b111) and 2 bits for the uuid variant (0b10).
55
+
56
+ 0 1 2 3
57
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
58
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59
+ | unix_ts_ms |
60
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61
+ | unix_ts_ms | ver | rand_a |
62
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63
+ |var| rand_b |
64
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65
+ | rand_b |
66
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67
+
68
+ Indicative timings:
69
+ - uuid.uuid4() 2.4us
70
+ - uuid7() 3.7us
71
+ - uuid7(as_type='int') 1.6us
72
+ - uuid7(as_type='str') 2.5us
73
+
74
+ Examples
75
+ --------
76
+
77
+ >>> uuid7()
78
+ UUID('061cb26a-54b8-7a52-8000-2124e7041024')
79
+
80
+ >>> for fmt in ('bytes', 'hex', 'int', 'str', 'uuid', None):
81
+ ... print(fmt, repr(uuid7(as_type=fmt)))
82
+ bytes b'\x06\x1c\xb8\xfe\x0f\x0b|9\x80\x00\tjt\x85\xb3\xbb'
83
+ hex '061cb8fe0f0b7c3980011863b956b758'
84
+ int 8124504378724980906989670469352026642
85
+ str '061cb8fe-0f0b-7c39-8003-d44a7ee0bdf6'
86
+ uuid UUID('061cb8fe-0f0b-7c39-8004-0489578299f6')
87
+ None UUID('061cb8fe-0f0f-7df2-8000-afd57c2bf446')
88
+ """
89
+ if ms is None:
90
+ ms = time_func()
91
+ else:
92
+ ms = int(ms) # Fail fast if not an int
93
+
94
+ rand_a = int.from_bytes(bytes=os.urandom(2), byteorder="big")
95
+ rand_b = int.from_bytes(bytes=os.urandom(8), byteorder="big")
96
+ uuid_bytes = uuidfromvalues(ms, rand_a, rand_b)
97
+
98
+ uuid_int = int.from_bytes(bytes=uuid_bytes, byteorder="big")
99
+ return uuid.UUID(int=uuid_int)
100
+
101
+
102
+ def uuidfromvalues(unix_ts_ms: int, rand_a: int, rand_b: int):
103
+ version = 0x07
104
+ var = 2
105
+ rand_a &= 0xFFF
106
+ rand_b &= 0x3FFFFFFFFFFFFFFF
107
+
108
+ final_bytes = unix_ts_ms.to_bytes(length=6, byteorder="big")
109
+ final_bytes += ((version << 12) + rand_a).to_bytes(length=2, byteorder="big")
110
+ final_bytes += ((var << 62) + rand_b).to_bytes(length=8, byteorder="big")
111
+
112
+ return final_bytes
113
+
114
+
115
+ def format_byte_array_as_uuid(arr: bytes):
116
+ return f"{arr[:4].hex()}-{arr[4:6].hex()}-{arr[6:8].hex()}-{arr[8:10].hex()}-{arr[10:].hex()}"
117
+
118
+
119
+ __all__ = ("uuid7",)
@@ -1,9 +1,10 @@
1
- from typing import ClassVar, Optional, Union
1
+ from typing import ClassVar, Optional
2
2
 
3
3
  from pydantic import AliasChoices, AliasPath, Field
4
4
  from pydantic_settings import SettingsConfigDict
5
5
 
6
6
  from prefect.settings.base import PrefectBaseSettings, build_settings_config
7
+ from prefect.types import TaskRetryDelaySeconds
7
8
 
8
9
 
9
10
  class TasksRunnerSettings(PrefectBaseSettings):
@@ -73,7 +74,7 @@ class TasksSettings(PrefectBaseSettings):
73
74
  ),
74
75
  )
75
76
 
76
- default_retry_delay_seconds: Union[int, float, list[float]] = Field(
77
+ default_retry_delay_seconds: TaskRetryDelaySeconds = Field(
77
78
  default=0,
78
79
  description="This value sets the default retry delay seconds for all tasks.",
79
80
  validation_alias=AliasChoices(
prefect/types/__init__.py CHANGED
@@ -1,8 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from functools import partial
4
- from typing import Annotated, Any, Optional, TypeVar, Union, cast
5
- from uuid import UUID
4
+ from typing import Annotated, Any, Optional, TypeVar, Union
6
5
  from typing_extensions import Literal
7
6
  import orjson
8
7
  import pydantic
@@ -132,6 +131,52 @@ ClientRetryExtraCodes = Annotated[
132
131
  BeforeValidator(partial(validate_set_T_from_delim_string, type_=StatusCode)),
133
132
  ]
134
133
 
134
+
135
+ def parse_retry_delay_input(value: Any) -> Any:
136
+ """
137
+ Parses various inputs (string, int, float, list) into a format suitable
138
+ for TaskRetryDelaySeconds (int, float, list[float], or None).
139
+ Handles comma-separated strings for lists of delays.
140
+ """
141
+ if isinstance(value, str):
142
+ stripped_value = value.strip()
143
+ if not stripped_value:
144
+ return None # Treat empty or whitespace-only string as None
145
+
146
+ delim = ","
147
+ # Split and filter empty strings that result from multiple commas (e.g., "10,,20")
148
+ parts = [s.strip() for s in stripped_value.split(delim) if s.strip()]
149
+
150
+ if not parts: # e.g., value was just "," or " , "
151
+ return None
152
+
153
+ def _parse_num_part(part_str: str) -> Union[float, int]:
154
+ try:
155
+ # Prefer float to align with list[float] in TaskRetryDelaySeconds
156
+ return TypeAdapter(float).validate_strings(part_str)
157
+ except pydantic.ValidationError:
158
+ try:
159
+ return TypeAdapter(int).validate_strings(part_str)
160
+ except pydantic.ValidationError as e_int:
161
+ raise ValueError(
162
+ f"Invalid number format '{part_str}' for retry delay."
163
+ ) from e_int
164
+
165
+ if len(parts) == 1:
166
+ return _parse_num_part(parts[0])
167
+ else:
168
+ return [_parse_num_part(p) for p in parts]
169
+
170
+ # For non-string inputs (int, float, list, None, etc.), pass them through.
171
+ # Pydantic will then validate them against Union[int, float, list[float], None].
172
+ return value
173
+
174
+
175
+ TaskRetryDelaySeconds = Annotated[
176
+ Union[str, int, float, list[float], None],
177
+ BeforeValidator(parse_retry_delay_input),
178
+ ]
179
+
135
180
  LogLevel = Annotated[
136
181
  Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
137
182
  BeforeValidator(lambda x: x.upper()),
@@ -173,4 +218,5 @@ __all__ = [
173
218
  "SecretDict",
174
219
  "StatusCode",
175
220
  "StrictVariableValue",
221
+ "TaskRetryDelaySeconds",
176
222
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prefect-client
3
- Version: 3.4.2.dev3
3
+ Version: 3.4.2.dev5
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
@@ -60,7 +60,6 @@ Requires-Dist: sniffio<2.0.0,>=1.3.0
60
60
  Requires-Dist: toml>=0.10.0
61
61
  Requires-Dist: typing-extensions<5.0.0,>=4.10.0
62
62
  Requires-Dist: ujson<6.0.0,>=5.8.0
63
- Requires-Dist: uuid7>=0.1.0
64
63
  Requires-Dist: uvicorn!=0.29.0,>=0.14.0
65
64
  Requires-Dist: websockets<16.0,>=13.0
66
65
  Requires-Dist: whenever<0.9.0,>=0.7.3; python_version >= '3.13'
@@ -1,7 +1,7 @@
1
1
  prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
2
2
  prefect/__init__.py,sha256=iCdcC5ZmeewikCdnPEP6YBAjPNV5dvfxpYCTpw30Hkw,3685
3
3
  prefect/__main__.py,sha256=WFjw3kaYJY6pOTA7WDOgqjsz8zUEUZHCcj3P5wyVa-g,66
4
- prefect/_build_info.py,sha256=XdQrk5WfZqL08ADpDNeCb9MymVHjSo9jKylGZ-rci8g,185
4
+ prefect/_build_info.py,sha256=AWVLbjCFHwKUP8q5HwClWRDz36Fc5bNwB4xEWyjMum0,185
5
5
  prefect/_result_records.py,sha256=S6QmsODkehGVSzbMm6ig022PYbI6gNKz671p_8kBYx4,7789
6
6
  prefect/_versioning.py,sha256=YqR5cxXrY4P6LM1Pmhd8iMo7v_G2KJpGNdsf4EvDFQ0,14132
7
7
  prefect/_waiters.py,sha256=Ia2ITaXdHzevtyWIgJoOg95lrEXQqNEOquHvw3T33UQ,9026
@@ -43,7 +43,7 @@ prefect/_internal/_logging.py,sha256=Igy2tCM2Hv9wNiDPcee0s5N1fTc6oRP7OffCJBqAekY
43
43
  prefect/_internal/integrations.py,sha256=U4cZMDbnilzZSKaMxvzZcSL27a1tzRMjDoTfr2ul_eY,231
44
44
  prefect/_internal/pytz.py,sha256=Sy_cD-Hkmo_Yrhx2Jucy7DgTRhvO8ZD0whW1ywbSg_U,13765
45
45
  prefect/_internal/retries.py,sha256=pMHofrTQPDSxbVWclDwXbfhFKaDC6sxe1DkUOWugV6k,3040
46
- prefect/_internal/uuid7.py,sha256=-Wl5rFozDSKRyhSfa9WT8BK1U5Rq8ehEgZB5aV5lodU,211
46
+ prefect/_internal/uuid7.py,sha256=yvndhibNDrqnYrG-qUncas4XQp8bKVbmM8XfF7JrjJI,4203
47
47
  prefect/_internal/compatibility/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  prefect/_internal/compatibility/async_dispatch.py,sha256=cUXOqSeseMUaje9oYUzasVPtNttyiHvrqfJl0zK66XI,2949
49
49
  prefect/_internal/compatibility/blocks.py,sha256=SSZXoWVuCMYu1EzjqmTa4lKjDCyxvOFK47XMj6s4hsk,984
@@ -257,7 +257,7 @@ prefect/settings/models/logging.py,sha256=Sj9GDNr5QMFaP6CN0WJyfpwhpOk4p1yhv45dyQ
257
257
  prefect/settings/models/results.py,sha256=VWFplQSSJyc0LXnziw1H5b3N_PDS32QBe_q2MWwYni0,1484
258
258
  prefect/settings/models/root.py,sha256=HpXt_I6T_kJw6QAxez4pCZl8p058etihzJbBNRylN3c,16767
259
259
  prefect/settings/models/runner.py,sha256=rD8OmNLwILmqnGe9YkM1dWKsulx3clYm4LI5N9vD5yM,1991
260
- prefect/settings/models/tasks.py,sha256=XA83-EmWv1FKvODSzvI1cvS3tGEbNs2qtdh0AbUdblQ,3640
260
+ prefect/settings/models/tasks.py,sha256=Rj3Tl8S04swCZIWgBCdn8sHct0B2IVgfPmM370Muj3E,3672
261
261
  prefect/settings/models/testing.py,sha256=j9YH_WkB14iEzOjUtTmvY978qRSbgCypFSEi_cOs8no,1820
262
262
  prefect/settings/models/worker.py,sha256=zeDU71aR4CEvEOKyH-1jgEyol8XYe29PExjIC6a8Wv0,1378
263
263
  prefect/settings/models/server/__init__.py,sha256=KJmffmlHb8GYnClaeYcerae-IaeNsNMucKKRRS_zG9Q,33
@@ -278,7 +278,7 @@ prefect/telemetry/logging.py,sha256=ktIVTXbdZ46v6fUhoHNidFrpvpNJR-Pj-hQ4V9b40W4,
278
278
  prefect/telemetry/processors.py,sha256=jw6j6LviOVxw3IBJe7cSjsxFk0zzY43jUmy6C9pcfCE,2272
279
279
  prefect/telemetry/run_telemetry.py,sha256=_FbjiPqPemu4xvZuI2YBPwXeRJ2BcKRJ6qgO4UMzKKE,8571
280
280
  prefect/telemetry/services.py,sha256=DxgNNDTeWNtHBtioX8cjua4IrCbTiJJdYecx-gugg-w,2358
281
- prefect/types/__init__.py,sha256=SwyWpbxSevAKU9lWpfauD61whUP7kksvfx-mtq3UE6E,4288
281
+ prefect/types/__init__.py,sha256=uZyu9xcaxoNg4T3_GHVyE_dlEXSetCjXpco9oKiJb80,6038
282
282
  prefect/types/_datetime.py,sha256=ZE-4YK5XJuyxnp5pqldZwtIjkxCpxDGnCSfZiTl7-TU,7566
283
283
  prefect/types/entrypoint.py,sha256=2FF03-wLPgtnqR_bKJDB2BsXXINPdu8ptY9ZYEZnXg8,328
284
284
  prefect/types/names.py,sha256=CMMZD928iiod2UvB0qrsfXEBC5jj_bO0ge1fFXcrtgM,3450
@@ -322,7 +322,7 @@ prefect/workers/cloud.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
322
322
  prefect/workers/process.py,sha256=Yi5D0U5AQ51wHT86GdwtImXSefe0gJf3LGq4r4z9zwM,11090
323
323
  prefect/workers/server.py,sha256=2pmVeJZiVbEK02SO6BEZaBIvHMsn6G8LzjW8BXyiTtk,1952
324
324
  prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
325
- prefect_client-3.4.2.dev3.dist-info/METADATA,sha256=8Prpr9Dv91MDdCLVe6wwH-XzvHtUO821oLHXJ8bEH1c,7500
326
- prefect_client-3.4.2.dev3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
327
- prefect_client-3.4.2.dev3.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
328
- prefect_client-3.4.2.dev3.dist-info/RECORD,,
325
+ prefect_client-3.4.2.dev5.dist-info/METADATA,sha256=n8zQ-Q4hRbiwFNqO9cBv4FduMfchIcQ1GNdszSDPsDY,7472
326
+ prefect_client-3.4.2.dev5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
327
+ prefect_client-3.4.2.dev5.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
328
+ prefect_client-3.4.2.dev5.dist-info/RECORD,,