relib 1.2.2__tar.gz → 1.2.4__tar.gz
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-1.2.2 → relib-1.2.4}/PKG-INFO +1 -1
- {relib-1.2.2 → relib-1.2.4}/pyproject.toml +1 -1
- {relib-1.2.2 → relib-1.2.4}/relib/__init__.py +1 -0
- {relib-1.2.2 → relib-1.2.4}/relib/utils.py +12 -3
- {relib-1.2.2 → relib-1.2.4}/uv.lock +1 -1
- {relib-1.2.2 → relib-1.2.4}/.gitignore +0 -0
- {relib-1.2.2 → relib-1.2.4}/LICENSE +0 -0
- {relib-1.2.2 → relib-1.2.4}/README.md +0 -0
- {relib-1.2.2 → relib-1.2.4}/relib/hashing.py +0 -0
- {relib-1.2.2 → relib-1.2.4}/relib/measure_duration.py +0 -0
- {relib-1.2.2 → relib-1.2.4}/relib/system.py +0 -0
@@ -1,6 +1,7 @@
|
|
1
|
+
import asyncio
|
1
2
|
import re
|
2
|
-
from typing import Iterable, Callable, Any, overload
|
3
3
|
from itertools import chain
|
4
|
+
from typing import Any, Awaitable, Callable, Iterable, overload
|
4
5
|
|
5
6
|
def non_none[T](obj: T | None) -> T:
|
6
7
|
assert obj is not None
|
@@ -156,7 +157,7 @@ def get_at[T](d: dict, keys: Iterable[Any], default: T) -> T:
|
|
156
157
|
return default
|
157
158
|
return as_any(d)
|
158
159
|
|
159
|
-
def for_each[T](func: Callable[[T]], iterable: Iterable[T]) -> None:
|
160
|
+
def for_each[T](func: Callable[[T], Any], iterable: Iterable[T]) -> None:
|
160
161
|
for item in iterable:
|
161
162
|
func(item)
|
162
163
|
|
@@ -182,8 +183,8 @@ def df_from_array(
|
|
182
183
|
dim_labels: list[tuple[str, list[str | int | float]]],
|
183
184
|
indexed=False,
|
184
185
|
):
|
185
|
-
import pandas as pd
|
186
186
|
import numpy as np
|
187
|
+
import pandas as pd
|
187
188
|
dim_sizes = np.array([len(labels) for _, labels in dim_labels])
|
188
189
|
assert all(array.shape == tuple(dim_sizes) for array in value_cols.values())
|
189
190
|
array_offsets = [
|
@@ -214,3 +215,11 @@ def str_filterer(
|
|
214
215
|
return any(pattern.search(string) for pattern in include_patterns)
|
215
216
|
|
216
217
|
return str_filter
|
218
|
+
|
219
|
+
async def worker(task, semaphore):
|
220
|
+
async with semaphore:
|
221
|
+
return await task
|
222
|
+
|
223
|
+
async def roll_tasks[T](tasks: Iterable[Awaitable[T]], workers: int) -> list[T]:
|
224
|
+
semaphore = asyncio.Semaphore(workers)
|
225
|
+
return await asyncio.gather(*(worker(task, semaphore) for task in tasks))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|