relib 1.2.3__py3-none-any.whl → 1.2.4__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 CHANGED
@@ -31,6 +31,7 @@ from .utils import (
31
31
  df_from_array,
32
32
  StrFilter,
33
33
  str_filterer,
34
+ roll_tasks,
34
35
  )
35
36
  from .system import read_json, write_json, clear_console, console_link
36
37
  from .hashing import hash, hash_obj
relib/utils.py CHANGED
@@ -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
@@ -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))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relib
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Project-URL: Repository, https://github.com/Reddan/relib.git
5
5
  Author: Hampus Hallman
6
6
  License: Copyright 2018-2025 Hampus Hallman
@@ -0,0 +1,9 @@
1
+ relib/__init__.py,sha256=eEycDD38L7RxEYrMyPvcJ-vWozI_x-mUxvqfbllnAPs,641
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=H-SJccCVLNTDhWTT5jo1NFUiQJzHv2Z1xvq0OVrnJcM,431
5
+ relib/utils.py,sha256=kJ8P8zCbp2EhFTu4lpOUe8y8VEvwA7VWUQMkPRmdEIc,7212
6
+ relib-1.2.4.dist-info/METADATA,sha256=XwynajdyZ2ta3_1LdJqpHwkVmj4AreRiStQ-Us-0Msc,1295
7
+ relib-1.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ relib-1.2.4.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
9
+ relib-1.2.4.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- relib/__init__.py,sha256=dLFft8umAfLeZfTiecZ2Cx_-C-nKoBepUk-aWivI5ZE,627
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=H-SJccCVLNTDhWTT5jo1NFUiQJzHv2Z1xvq0OVrnJcM,431
5
- relib/utils.py,sha256=6Y_77KeejooPa54Z57EwPbNVvnFncmGay-VBbv4gAQQ,6905
6
- relib-1.2.3.dist-info/METADATA,sha256=SrcjKfhYBKtDMGjdZqmwLsgm5I3hln8Q4ZW2FtFHz80,1295
7
- relib-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- relib-1.2.3.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
9
- relib-1.2.3.dist-info/RECORD,,
File without changes