use numba progress in threadpool#1220
Open
selmanozleyen wants to merge 11 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1220 +/- ##
==========================================
- Coverage 76.81% 76.79% -0.02%
==========================================
Files 63 63
Lines 9267 9283 +16
Branches 1565 1570 +5
==========================================
+ Hits 7118 7129 +11
- Misses 1547 1550 +3
- Partials 602 604 +2
🚀 New features to boost your workflow:
|
timtreis
reviewed
Jun 19, 2026
| from tqdm.auto import tqdm | ||
|
|
||
| if TYPE_CHECKING: | ||
| from contextlib import AbstractContextManager |
Member
Author
There was a problem hiding this comment.
to annotate the return type
Member
There was a problem hiding this comment.
I find the pattern a bit too complicated for what we're doing there? Maybe just refactor as a context manager, then we avoid that issue and have simpler typing too?
Member
There was a problem hiding this comment.
like
@contextmanager
def progress_bar(
total: int,
*,
show_progress_bar: bool = True,
unit: str = "item",
desc: str | None = None,
) -> Iterator[ProgressBar | None]:
"""Create a progress bar usable both inside and outside :mod:`numba` functions."""
if not show_progress_bar:
yield None
return
from numba_progress import ProgressBar
kwargs: dict[str, Any] = {"total": total, "unit": unit}
if desc is not None:
kwargs["desc"] = desc
with ProgressBar(**kwargs) as pbar:
yield pbar
Apply review suggestion: simplify progress_bar to a @contextmanager generator, avoiding the AbstractContextManager/nullcontext typing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract shared result-collection loop into a local helper so the sequential and pooled branches no longer duplicate the same logic. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
progress_bar was only used by thread_map, so build the progress-bar context manager inline instead of keeping a separate one-use function. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Run the mapping through a local _run(pbar) helper so the no-progress path just calls _run(None) and the progress path enters ProgressBar directly. Removes the union-typed pbar_cm variable, its AbstractContextManager annotation, and the nullcontext import. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using numba-progress for the default case. In case of custom progress bar handling custom logic can be used. But that case can be explored in future PR's