dycw-utilities 0.166.27__py3-none-any.whl → 0.166.29__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.
Potentially problematic release.
This version of dycw-utilities might be problematic. Click here for more details.
- {dycw_utilities-0.166.27.dist-info → dycw_utilities-0.166.29.dist-info}/METADATA +3 -3
- {dycw_utilities-0.166.27.dist-info → dycw_utilities-0.166.29.dist-info}/RECORD +8 -8
- utilities/__init__.py +1 -1
- utilities/os.py +1 -1
- utilities/pytest.py +44 -2
- {dycw_utilities-0.166.27.dist-info → dycw_utilities-0.166.29.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.166.27.dist-info → dycw_utilities-0.166.29.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.166.27.dist-info → dycw_utilities-0.166.29.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dycw-utilities
|
|
3
|
-
Version: 0.166.
|
|
3
|
+
Version: 0.166.29
|
|
4
4
|
Author-email: Derek Wan <d.wan@icloud.com>
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Requires-Python: >=3.12
|
|
@@ -12,8 +12,8 @@ Provides-Extra: logging
|
|
|
12
12
|
Requires-Dist: coloredlogs<15.1,>=15.0.1; extra == 'logging'
|
|
13
13
|
Provides-Extra: test
|
|
14
14
|
Requires-Dist: dycw-pytest-only<2.2,>=2.1.1; extra == 'test'
|
|
15
|
-
Requires-Dist: hypothesis<6.139,>=6.138.
|
|
16
|
-
Requires-Dist: pytest-asyncio<1.
|
|
15
|
+
Requires-Dist: hypothesis<6.139,>=6.138.16; extra == 'test'
|
|
16
|
+
Requires-Dist: pytest-asyncio<1.3,>=1.2.0; extra == 'test'
|
|
17
17
|
Requires-Dist: pytest-cov<7.1,>=7.0.0; extra == 'test'
|
|
18
18
|
Requires-Dist: pytest-instafail<0.6,>=0.5.0; extra == 'test'
|
|
19
19
|
Requires-Dist: pytest-lazy-fixtures<1.4,>=1.3.4; extra == 'test'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
utilities/__init__.py,sha256=
|
|
1
|
+
utilities/__init__.py,sha256=ykhEqK5jGq8CZixk5jWUzsXv0OSPtB7rnq3h3-_XblA,61
|
|
2
2
|
utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
|
|
3
3
|
utilities/altair.py,sha256=nHdpWt8ZwdUwRQN970MvHd5bRWokNqzHcZQEdSHKRuE,9033
|
|
4
4
|
utilities/asyncio.py,sha256=60l1IwjnRGeaVphAFiwDIHyfKoZYKY-XGpptUxGiU-M,17034
|
|
@@ -41,7 +41,7 @@ utilities/numpy.py,sha256=Xn23sA2ZbVNqwUYEgNJD3XBYH6IbCri_WkHSNhg3NkY,26122
|
|
|
41
41
|
utilities/operator.py,sha256=C3NylZWGTVWRpwYHOPVhaLgRhw0DfpS4_XQ8KfPhBLQ,3613
|
|
42
42
|
utilities/optuna.py,sha256=C-fhWYiXHVPo1l8QctYkFJ4DyhbSrGorzP1dJb_qvd8,1933
|
|
43
43
|
utilities/orjson.py,sha256=rII_rINPcH9X0CfL_WeFjwHgKNkKAF-TVS5rnpLHjzc,41998
|
|
44
|
-
utilities/os.py,sha256=
|
|
44
|
+
utilities/os.py,sha256=MQxP4yVsV0sg8nPQyC8rctnimJdys_PvzxqDZfVzMMs,3935
|
|
45
45
|
utilities/parse.py,sha256=JcJn5yXKhIWXBCwgBdPsyu7Hvcuw6kyEdqvaebCaI9k,17951
|
|
46
46
|
utilities/pathlib.py,sha256=X6pHmfT3hnBGysdTr73uHsNaBEgKviZhk7aGWvEXDXo,8912
|
|
47
47
|
utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
|
@@ -56,7 +56,7 @@ utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
56
56
|
utilities/pydantic_settings.py,sha256=bFr9UDrVhdqTl7O_TPutCLdsQ5rUp--nO76-_F8z0bs,5102
|
|
57
57
|
utilities/pydantic_settings_sops.py,sha256=m2uB9wDw1PU2CiSL7KwxulDXT0STjOZTu3Ctc2q7jc0,1943
|
|
58
58
|
utilities/pyinstrument.py,sha256=hnXaL-4HE7wWBI5JKaPfYTpsrXe68YiuZKahHV0VJn8,841
|
|
59
|
-
utilities/pytest.py,sha256=
|
|
59
|
+
utilities/pytest.py,sha256=wulDgPzABPJq6ArOiE96oWRf18cSCMj7arRtXJ8LbgU,9649
|
|
60
60
|
utilities/pytest_regressions.py,sha256=ocjHTtfOeiGfQAKIei8pKNd61sxN9dawrJJ9gPt2wzA,4097
|
|
61
61
|
utilities/random.py,sha256=hZlH4gnAtoaofWswuJYjcygejrY8db4CzP-z_adO2Mo,4165
|
|
62
62
|
utilities/re.py,sha256=S4h-DLL6ScMPqjboZ_uQ1BVTJajrqV06r_81D--_HCE,4573
|
|
@@ -91,8 +91,8 @@ utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
|
|
|
91
91
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
92
92
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
|
93
93
|
utilities/pytest_plugins/pytest_regressions.py,sha256=mnHYBfdprz50UGVkVzV1bZERZN5CFfoF8YbokGxdFwU,1639
|
|
94
|
-
dycw_utilities-0.166.
|
|
95
|
-
dycw_utilities-0.166.
|
|
96
|
-
dycw_utilities-0.166.
|
|
97
|
-
dycw_utilities-0.166.
|
|
98
|
-
dycw_utilities-0.166.
|
|
94
|
+
dycw_utilities-0.166.29.dist-info/METADATA,sha256=WjWEiFbbj5kEsjpaNFZrF-_GwYdhVIoUQqO5-ddjM3g,1700
|
|
95
|
+
dycw_utilities-0.166.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
96
|
+
dycw_utilities-0.166.29.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
|
97
|
+
dycw_utilities-0.166.29.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
|
98
|
+
dycw_utilities-0.166.29.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/os.py
CHANGED
utilities/pytest.py
CHANGED
|
@@ -28,7 +28,8 @@ from utilities.platform import (
|
|
|
28
28
|
IS_NOT_WINDOWS,
|
|
29
29
|
IS_WINDOWS,
|
|
30
30
|
)
|
|
31
|
-
from utilities.
|
|
31
|
+
from utilities.random import bernoulli
|
|
32
|
+
from utilities.types import MaybeCoro, Seed
|
|
32
33
|
from utilities.whenever import SECOND, get_now_local
|
|
33
34
|
|
|
34
35
|
if TYPE_CHECKING:
|
|
@@ -166,6 +167,47 @@ class _NodeIdToPathNotGetTailError(NodeIdToPathError):
|
|
|
166
167
|
##
|
|
167
168
|
|
|
168
169
|
|
|
170
|
+
def run_frac[F: Callable[..., MaybeCoro[None]]](
|
|
171
|
+
*, frac: float = 0.5, seed: Seed | None = None
|
|
172
|
+
) -> Callable[[F], F]:
|
|
173
|
+
"""Run a test only a fraction of the time.."""
|
|
174
|
+
return cast("Any", partial(_run_frac_inner, frac=frac, seed=seed))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _run_frac_inner[F: Callable[..., MaybeCoro[None]]](
|
|
178
|
+
func: F, /, *, frac: float = 0.5, seed: Seed | None = None
|
|
179
|
+
) -> F:
|
|
180
|
+
match bool(iscoroutinefunction(func)):
|
|
181
|
+
case False:
|
|
182
|
+
|
|
183
|
+
@wraps(func)
|
|
184
|
+
def run_frac_sync(*args: Any, **kwargs: Any) -> None:
|
|
185
|
+
_skipif_frac(frac=frac, seed=seed)
|
|
186
|
+
cast("Callable[..., None]", func)(*args, **kwargs)
|
|
187
|
+
|
|
188
|
+
return cast("Any", run_frac_sync)
|
|
189
|
+
|
|
190
|
+
case True:
|
|
191
|
+
|
|
192
|
+
@wraps(func)
|
|
193
|
+
async def run_frac_async(*args: Any, **kwargs: Any) -> None:
|
|
194
|
+
_skipif_frac(frac=frac, seed=seed)
|
|
195
|
+
await cast("Callable[..., Coro[None]]", func)(*args, **kwargs)
|
|
196
|
+
|
|
197
|
+
return cast("Any", run_frac_async)
|
|
198
|
+
|
|
199
|
+
case never:
|
|
200
|
+
assert_never(never)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _skipif_frac(*, frac: float = 0.5, seed: Seed | None = None) -> None:
|
|
204
|
+
if (skip is not None) and bernoulli(true=1 - frac, seed=seed):
|
|
205
|
+
_ = skip(reason=f"{_get_name()} skipped (run {frac:.0%})")
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
##
|
|
209
|
+
|
|
210
|
+
|
|
169
211
|
def throttle[F: Callable[..., MaybeCoro[None]]](
|
|
170
212
|
*, root: PathLike | None = None, delta: Delta = SECOND, on_try: bool = False
|
|
171
213
|
) -> Callable[[F], F]:
|
|
@@ -181,7 +223,6 @@ def _throttle_inner[F: Callable[..., MaybeCoro[None]]](
|
|
|
181
223
|
delta: Delta = SECOND,
|
|
182
224
|
on_try: bool = False,
|
|
183
225
|
) -> F:
|
|
184
|
-
"""Throttle a test function/method."""
|
|
185
226
|
if get_env_var("THROTTLE", nullable=True) is not None:
|
|
186
227
|
return func
|
|
187
228
|
match bool(iscoroutinefunction(func)), on_try:
|
|
@@ -276,6 +317,7 @@ __all__ = [
|
|
|
276
317
|
"add_pytest_collection_modifyitems",
|
|
277
318
|
"add_pytest_configure",
|
|
278
319
|
"node_id_path",
|
|
320
|
+
"run_frac",
|
|
279
321
|
"skipif_linux",
|
|
280
322
|
"skipif_mac",
|
|
281
323
|
"skipif_not_linux",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|