Skip to content

chore: unify thread and process helpers - #1251

Open
selmanozleyen wants to merge 4 commits into
mainfrom
feat/n-jobs-unification
Open

chore: unify thread and process helpers#1251
selmanozleyen wants to merge 4 commits into
mainfrom
feat/n-jobs-unification

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

This pull request refactors how the number of parallel workers is determined throughout the codebase. It deprecates the old _get_n_cores utility in favor of a new get_n_processes function for process-based parallelization and introduces get_n_threads for numba-based threading. All relevant imports and function calls are updated to use the new functions, ensuring more consistent and descriptive handling of parallelism.

Parallelization utilities refactor:

  • Added get_n_threads to src/squidpy/_utils.py for resolving numba thread counts, and replaced _get_n_cores with get_n_processes, which is now used for process-based parallelization and is marked as deprecated in favor of numba threading where appropriate.
  • Updated all imports and usages of _get_n_cores to get_n_processes in the following modules: src/squidpy/experimental/im/_tiling.py, src/squidpy/gr/_ligrec.py, src/squidpy/gr/_nhood.py, src/squidpy/gr/_ppatterns.py, src/squidpy/gr/_sepal.py, and src/squidpy/im/_feature.py. [1] [2] [3] [4] [5] [6]
  • Replaced all internal calls to _get_n_cores with get_n_processes for determining the number of worker processes or threads in parallel computations. [1] [2] [3] [4] [5] [6] [7]
  • Updated documentation and comments to reference the new get_n_processes convention and clarify its intended usage and deprecation plan.

These changes standardize parallelization configuration, improve code clarity, and prepare the codebase for future migration to numba threading.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.36%. Comparing base (ca07e64) to head (717c692).

Files with missing lines Patch % Lines
src/squidpy/_utils.py 95.45% 1 Missing ⚠️
src/squidpy/experimental/im/_tiling.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1251      +/-   ##
==========================================
+ Coverage   77.24%   77.36%   +0.11%     
==========================================
  Files          63       63              
  Lines        9378     9392      +14     
  Branches     1579     1580       +1     
==========================================
+ Hits         7244     7266      +22     
+ Misses       1532     1528       -4     
+ Partials      602      598       -4     
Files with missing lines Coverage Δ
src/squidpy/_docs.py 95.00% <100.00%> (+0.19%) ⬆️
...uidpy/experimental/im/_calculate_image_features.py 89.42% <ø> (ø)
src/squidpy/experimental/tl/_tiling_qc.py 70.56% <ø> (ø)
src/squidpy/gr/_build.py 88.44% <100.00%> (ø)
src/squidpy/gr/_ligrec.py 78.40% <100.00%> (+0.07%) ⬆️
src/squidpy/gr/_nhood.py 81.70% <100.00%> (ø)
src/squidpy/gr/_ppatterns.py 80.00% <100.00%> (ø)
src/squidpy/gr/_sepal.py 55.07% <100.00%> (ø)
src/squidpy/im/_feature.py 88.88% <100.00%> (ø)
src/squidpy/_utils.py 68.28% <95.45%> (+5.14%) ⬆️
... and 1 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant