thds.core 1.45.20251002190135__py3-none-any.whl → 1.45.20251006172702__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 thds.core might be problematic. Click here for more details.
- thds/core/parallel.py +14 -3
- {thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/METADATA +1 -1
- {thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/RECORD +6 -6
- {thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/WHEEL +0 -0
- {thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/entry_points.txt +0 -0
- {thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/top_level.txt +0 -0
thds/core/parallel.py
CHANGED
|
@@ -73,6 +73,9 @@ def yield_all(
|
|
|
73
73
|
thunks: ty.Iterable[ty.Tuple[H, ty.Callable[[], R]]],
|
|
74
74
|
*,
|
|
75
75
|
executor_cm: ty.Optional[ty.ContextManager[concurrent.futures.Executor]] = None,
|
|
76
|
+
fmt: ty.Callable[[str], str] = lambda x: x,
|
|
77
|
+
named: str = "",
|
|
78
|
+
progress_logger: ty.Callable[[str], ty.Any] = logger.info,
|
|
76
79
|
) -> ty.Iterator[ty.Tuple[H, ty.Union[R, Error]]]:
|
|
77
80
|
"""Stream your results so that you don't have to load them all into memory at the same
|
|
78
81
|
time (necessarily). Also, yield (rather than raise) Exceptions, wrapped as Errors.
|
|
@@ -86,6 +89,9 @@ def yield_all(
|
|
|
86
89
|
files.bump_limits()
|
|
87
90
|
len_or_none = try_len(thunks)
|
|
88
91
|
|
|
92
|
+
num_tasks_log = "" if not len_or_none else f" of {len_or_none}"
|
|
93
|
+
named = f" {named} " if named else " result "
|
|
94
|
+
|
|
89
95
|
if PARALLEL_OFF() or (len_or_none == 1 and not executor_cm):
|
|
90
96
|
# don't actually transfer this to an executor we only have one task.
|
|
91
97
|
for key, thunk in thunks:
|
|
@@ -101,12 +107,16 @@ def yield_all(
|
|
|
101
107
|
with executor_cm as executor:
|
|
102
108
|
keys_onto_futures = {key: executor.submit(thunk) for key, thunk in thunks}
|
|
103
109
|
future_ids_onto_keys = {id(future): key for key, future in keys_onto_futures.items()}
|
|
104
|
-
for future in concurrent.futures.as_completed(keys_onto_futures.values()):
|
|
110
|
+
for i, future in enumerate(concurrent.futures.as_completed(keys_onto_futures.values()), start=1):
|
|
105
111
|
thunk_key = future_ids_onto_keys[id(future)]
|
|
106
112
|
try:
|
|
107
|
-
|
|
113
|
+
result = future.result()
|
|
114
|
+
yielder: tuple[H, ty.Union[R, Error]] = thunk_key, ty.cast(R, result)
|
|
108
115
|
except Exception as e:
|
|
109
|
-
|
|
116
|
+
yielder = thunk_key, Error(e)
|
|
117
|
+
finally:
|
|
118
|
+
progress_logger(fmt(f"Yielding{named}{i}{num_tasks_log}"))
|
|
119
|
+
yield yielder
|
|
110
120
|
|
|
111
121
|
|
|
112
122
|
def failfast(results: ty.Iterable[ty.Tuple[H, ty.Union[R, Error]]]) -> ty.Iterator[ty.Tuple[H, R]]:
|
|
@@ -183,6 +193,7 @@ def yield_results(
|
|
|
183
193
|
)
|
|
184
194
|
|
|
185
195
|
summarize_exceptions(error_fmt, exceptions)
|
|
196
|
+
# TODO - when `core` moves to 3.11 start using an ExceptionGroup here
|
|
186
197
|
|
|
187
198
|
|
|
188
199
|
def summarize_exceptions(
|
|
@@ -29,7 +29,7 @@ thds/core/link.py,sha256=4-9d22l_oSkKoSzlYEO-rwxO1hvvj6VETY7LwvGcX6M,5534
|
|
|
29
29
|
thds/core/logical_root.py,sha256=gWkIYRv9kNQfzbpxJaYiwNXVz1neZ2NvnvProtOn9d8,1399
|
|
30
30
|
thds/core/merge_args.py,sha256=7oj7dtO1-XVkfTM3aBlq3QlZbo8tb6X7E3EVIR-60t8,5781
|
|
31
31
|
thds/core/meta.py,sha256=Df0DxV5UzHcEsu5UCYaE1BWipMPTEXycn9Ug4cdquMk,12114
|
|
32
|
-
thds/core/parallel.py,sha256=
|
|
32
|
+
thds/core/parallel.py,sha256=uYVmdYvD0v3RrQq6YY1o7qPY3KQIPPdzyxZMnFr2DzU,8139
|
|
33
33
|
thds/core/pickle_visit.py,sha256=QNMWIi5buvk2zsvx1-D-FKL7tkrFUFDs387vxgGebgU,833
|
|
34
34
|
thds/core/prof.py,sha256=5ViolfPsAPwUTHuhAe-bon7IArPGXydpGoB5uZmObDk,8264
|
|
35
35
|
thds/core/progress.py,sha256=tY8tc_6CMnu_O8DVisnsRoDpFJOw5vqyYzLhQDxsLn8,4361
|
|
@@ -74,8 +74,8 @@ thds/core/sqlite/structured.py,sha256=8t1B6XbM5NnudKEeBLsdjRVbSXXSr6iHOW0HwEAqtX
|
|
|
74
74
|
thds/core/sqlite/types.py,sha256=Zb1FtSAmC1L7QPPCV1eRnWpJuF74t9R293ai1SHtdS4,1292
|
|
75
75
|
thds/core/sqlite/upsert.py,sha256=BmKK6fsGVedt43iY-Lp7dnAu8aJ1e9CYlPVEQR2pMj4,5827
|
|
76
76
|
thds/core/sqlite/write.py,sha256=z0219vDkQDCnsV0WLvsj94keItr7H4j7Y_evbcoBrWU,3458
|
|
77
|
-
thds_core-1.45.
|
|
78
|
-
thds_core-1.45.
|
|
79
|
-
thds_core-1.45.
|
|
80
|
-
thds_core-1.45.
|
|
81
|
-
thds_core-1.45.
|
|
77
|
+
thds_core-1.45.20251006172702.dist-info/METADATA,sha256=qFm2dPu7qUFAr2ei5gt2wHG4UHil9xOOIn1IZzbq104,2216
|
|
78
|
+
thds_core-1.45.20251006172702.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
79
|
+
thds_core-1.45.20251006172702.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
|
|
80
|
+
thds_core-1.45.20251006172702.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
|
|
81
|
+
thds_core-1.45.20251006172702.dist-info/RECORD,,
|
|
File without changes
|
{thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{thds_core-1.45.20251002190135.dist-info → thds_core-1.45.20251006172702.dist-info}/top_level.txt
RENAMED
|
File without changes
|