relib 1.2.7__py3-none-any.whl → 1.2.8__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.
- relib/__init__.py +1 -0
- relib/system.py +6 -3
- {relib-1.2.7.dist-info → relib-1.2.8.dist-info}/METADATA +1 -1
- relib-1.2.8.dist-info/RECORD +9 -0
- relib-1.2.7.dist-info/RECORD +0 -9
- {relib-1.2.7.dist-info → relib-1.2.8.dist-info}/WHEEL +0 -0
- {relib-1.2.7.dist-info → relib-1.2.8.dist-info}/licenses/LICENSE +0 -0
relib/__init__.py
CHANGED
relib/system.py
CHANGED
@@ -11,8 +11,11 @@ from .utils import noop
|
|
11
11
|
P = ParamSpec("P")
|
12
12
|
R = TypeVar("R")
|
13
13
|
default_num_workers = min(32, (os.cpu_count() or 1) + 4)
|
14
|
+
_default_json: Any = {}
|
14
15
|
|
15
|
-
def read_json(path: Path) -> Any:
|
16
|
+
def read_json(path: Path, default=_default_json) -> Any:
|
17
|
+
if default is not _default_json and not path.exists():
|
18
|
+
return default
|
16
19
|
with path.open("r") as f:
|
17
20
|
return json.load(f)
|
18
21
|
|
@@ -35,13 +38,13 @@ async def worker[T](task: Awaitable[T], semaphore: asyncio.Semaphore, update=noo
|
|
35
38
|
async def roll_tasks[T](tasks: Iterable[Awaitable[T]], workers=default_num_workers, progress=False) -> list[T]:
|
36
39
|
semaphore = asyncio.Semaphore(workers)
|
37
40
|
if not progress:
|
38
|
-
return await asyncio.gather(*
|
41
|
+
return await asyncio.gather(*[worker(task, semaphore) for task in tasks])
|
39
42
|
|
40
43
|
from tqdm import tqdm
|
41
44
|
tasks = tasks if isinstance(tasks, list) else list(tasks)
|
42
45
|
with tqdm(total=len(tasks)) as pbar:
|
43
46
|
update = functools.partial(pbar.update, 1)
|
44
|
-
return await asyncio.gather(*
|
47
|
+
return await asyncio.gather(*[worker(task, semaphore, update) for task in tasks])
|
45
48
|
|
46
49
|
def as_async(workers=default_num_workers) -> Callable[[Callable[P, R]], Callable[P, Awaitable[R]]]:
|
47
50
|
executor = ThreadPoolExecutor(max_workers=workers)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
relib/__init__.py,sha256=pypVcr0ctaSdFZmwMnZvtioTbms3MlWfAcrnPVdZxog,689
|
2
|
+
relib/hashing.py,sha256=DB_fnkj0ls01FgZbf4nPFHl4EBU8X_0OrmDvty4HlRE,6020
|
3
|
+
relib/measure_duration.py,sha256=LCTo_D_qReNprD3fhtJ0daeWycS6xQE_cwxeg2_h0xo,456
|
4
|
+
relib/system.py,sha256=RO8pd5eUmucbAxgfFi7UWHH5Cdp0aM6O1oe5cylrc4k,2527
|
5
|
+
relib/utils.py,sha256=4fM0zsAdfrM2w9Q1YKcTfFG5kDzoNgD2amkgfTG39OY,6933
|
6
|
+
relib-1.2.8.dist-info/METADATA,sha256=b8RvpgbcT7Y9zq6r-kwnnCZgql_eAdG41Y83-q2YIXg,1295
|
7
|
+
relib-1.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
+
relib-1.2.8.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
|
9
|
+
relib-1.2.8.dist-info/RECORD,,
|
relib-1.2.7.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
relib/__init__.py,sha256=E_ye3ZsGqW3xCibphEWtXhXjIJI58zVxX53VajgvG2Q,674
|
2
|
-
relib/hashing.py,sha256=DB_fnkj0ls01FgZbf4nPFHl4EBU8X_0OrmDvty4HlRE,6020
|
3
|
-
relib/measure_duration.py,sha256=LCTo_D_qReNprD3fhtJ0daeWycS6xQE_cwxeg2_h0xo,456
|
4
|
-
relib/system.py,sha256=PdYsMqiC72VGEFrDfRAQkT49o4iisDu8fJcRhk5xjlA,2404
|
5
|
-
relib/utils.py,sha256=4fM0zsAdfrM2w9Q1YKcTfFG5kDzoNgD2amkgfTG39OY,6933
|
6
|
-
relib-1.2.7.dist-info/METADATA,sha256=YtBWrvOv4SbU6WoC4CXYCRAx3NnQMw5ymk91ICqlXO0,1295
|
7
|
-
relib-1.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
relib-1.2.7.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
|
9
|
-
relib-1.2.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|