Skip to content

use numba progress in threadpool#1220

Open
selmanozleyen wants to merge 11 commits into
scverse:mainfrom
selmanozleyen:chore/numba-progressbar
Open

use numba progress in threadpool#1220
selmanozleyen wants to merge 11 commits into
scverse:mainfrom
selmanozleyen:chore/numba-progressbar

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

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

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.79%. Comparing base (ae5ceb4) to head (a51cc30).

Files with missing lines Patch % Lines
src/squidpy/_utils.py 78.57% 3 Missing and 3 partials ⚠️
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     
Files with missing lines Coverage Δ
src/squidpy/_utils.py 62.16% <78.57%> (+0.51%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@selmanozleyen selmanozleyen changed the title use numba progress for in threadpool use numba progress in threadpool Jun 19, 2026
Comment thread src/squidpy/_utils.py Outdated
from tqdm.auto import tqdm

if TYPE_CHECKING:
from contextlib import AbstractContextManager

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to annotate the return type

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@selmanozleyen selmanozleyen self-assigned this Jun 25, 2026
selmanozleyen and others added 5 commits June 26, 2026 09:22
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>
@selmanozleyen selmanozleyen requested a review from timtreis June 26, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants