thds.core 1.31.20250127214246__py3-none-any.whl → 1.31.20250128233053__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/meta.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "git_commit": "5cc4eb34e4c8c668ebd2734dcdda84ca26519c08",
2
+ "git_commit": "7f3310b958fceeb2a3b25bd3ac33c42cc3f70672",
3
3
  "git_branch": "main",
4
4
  "git_is_clean": true,
5
- "pyproject_version": "1.31.20250127214246",
5
+ "pyproject_version": "1.31.20250128233053",
6
6
  "thds_user": "runner",
7
7
  "misc": {}
8
8
  }
thds/core/parallel.py CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import concurrent.futures
5
5
  import itertools
6
+ import traceback
6
7
  import typing as ty
7
8
  from collections import defaultdict
8
9
  from dataclasses import dataclass
@@ -112,6 +113,9 @@ def yield_all(
112
113
 
113
114
 
114
115
  def failfast(results: ty.Iterable[ty.Tuple[H, ty.Union[R, Error]]]) -> ty.Iterator[ty.Tuple[H, R]]:
116
+ """Use in conjunction with `yield_all` to run things in parallel but to exit at the first sign
117
+ of failure. More appropriate for small pipeline stages.
118
+ """
115
119
  for key, res in results:
116
120
  if isinstance(res, Error):
117
121
  raise res.error
@@ -172,7 +176,14 @@ def yield_results(
172
176
  yield res
173
177
  else:
174
178
  exceptions.append(res.error)
175
- logger.exception(error_fmt(f"Task {i}{num_tasks_log} errored with {str(res.error)}"))
179
+ # print tracebacks as we go, so as not to defer potentially-helpful
180
+ # debugging information while a long run is ongoing.
181
+ traceback.print_exception(type(res.error), res.error, res.error.__traceback__)
182
+ logger.error( # should only use logger.exception from an except block
183
+ error_fmt(
184
+ f"Task {i}{num_tasks_log} errored with {type(res.error).__name__}({res.error})"
185
+ )
186
+ )
176
187
 
177
188
  summarize_exceptions(error_fmt, exceptions)
178
189
 
@@ -182,16 +193,16 @@ def summarize_exceptions(
182
193
  exceptions: ty.List[Exception],
183
194
  ) -> None:
184
195
  if exceptions:
185
- # summarize them and raise a final exception
196
+ # group by type
186
197
  by_type = defaultdict(list)
187
198
  for exc in exceptions:
188
199
  by_type[type(exc)].append(exc)
189
- logger.error(error_fmt("EXCEPTION"), exc_info=(type(exc), exc, exc.__traceback__))
190
200
 
201
+ # log the count for each Exception type
191
202
  most_common_type = None
192
203
  max_count = 0
193
204
  for _type, excs in by_type.items():
194
- logger.error(error_fmt(f"{len(excs)} tasks failed with exception: " + str(_type)))
205
+ logger.error(error_fmt(f"{len(excs)} tasks failed with exception: " + _type.__name__))
195
206
  if len(excs) > max_count:
196
207
  max_count = len(excs)
197
208
  most_common_type = _type
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: thds.core
3
- Version: 1.31.20250127214246
3
+ Version: 1.31.20250128233053
4
4
  Summary: Core utilities.
5
5
  Author: Trilliant Health
6
6
  Description-Content-Type: text/markdown
@@ -22,9 +22,9 @@ thds/core/iterators.py,sha256=d3iTQDR0gCW1nMRmknQeodR_4THzR9Ajmp8F8KCCFgg,208
22
22
  thds/core/lazy.py,sha256=e1WvG4LsbEydV0igEr_Vl1cq05zlQNIE8MFYT90yglE,3289
23
23
  thds/core/link.py,sha256=kmFJIFvEZc16-7S7IGvtTpzwl3VuvFl3yPlE6WJJ03w,5404
24
24
  thds/core/merge_args.py,sha256=7oj7dtO1-XVkfTM3aBlq3QlZbo8tb6X7E3EVIR-60t8,5781
25
- thds/core/meta.json,sha256=9XulISJdzvYUNkfK0XigSu9RbMvSml0XLyNO5oduoqQ,196
25
+ thds/core/meta.json,sha256=gkLuXVLcI2acVfgpF2lYUzENQZKleKvTJeb-8VDp3Lo,196
26
26
  thds/core/meta.py,sha256=IPLAKrH06HooPMNf5FeqJvUcM-JljTGXddrAQ5oAX8E,16896
27
- thds/core/parallel.py,sha256=lUzM0CRXsfzZgMMOHcwP-Th7bbXAqfl7FEGwdwAoBiM,7098
27
+ thds/core/parallel.py,sha256=HXAn9aIYqNE5rnRN5ypxR6CUucdfzE5T5rJ_MUv-pFk,7590
28
28
  thds/core/pickle_visit.py,sha256=QNMWIi5buvk2zsvx1-D-FKL7tkrFUFDs387vxgGebgU,833
29
29
  thds/core/prof.py,sha256=atDz7rDxzMzbKwgM48tics2tB5sBijKb_L5heAT6Pk8,8246
30
30
  thds/core/progress.py,sha256=4YGbxliDl1i-k-88w4s86uy1E69eQ6xJySGPSkpH1QM,3358
@@ -60,8 +60,8 @@ thds/core/sqlite/structured.py,sha256=swCbDoyVT6cE7Kl79Wh_rg5Z1-yrUDJbiVJF4bjset
60
60
  thds/core/sqlite/types.py,sha256=oUkfoKRYNGDPZRk29s09rc9ha3SCk2SKr_K6WKebBFs,1308
61
61
  thds/core/sqlite/upsert.py,sha256=BmKK6fsGVedt43iY-Lp7dnAu8aJ1e9CYlPVEQR2pMj4,5827
62
62
  thds/core/sqlite/write.py,sha256=h-tld6sC1alkaF92KRdrjyrEOwCt3bZ804muOcV4MEw,3141
63
- thds.core-1.31.20250127214246.dist-info/METADATA,sha256=B4x41JmMXI1p7T__6daXdDFnlk3EsLCkRNKxRc7P8pA,2123
64
- thds.core-1.31.20250127214246.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
65
- thds.core-1.31.20250127214246.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
66
- thds.core-1.31.20250127214246.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
67
- thds.core-1.31.20250127214246.dist-info/RECORD,,
63
+ thds.core-1.31.20250128233053.dist-info/METADATA,sha256=1uqpGMht5pzq7Pi3lqhZ9wqSjX-AXGn-cTKYYFcHELY,2123
64
+ thds.core-1.31.20250128233053.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
65
+ thds.core-1.31.20250128233053.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
66
+ thds.core-1.31.20250128233053.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
67
+ thds.core-1.31.20250128233053.dist-info/RECORD,,