Skip to content

fix: n_jobs in cluster.cluster() not working#22

Open
wuwenrui555 wants to merge 2 commits intodpeerlab:masterfrom
wuwenrui555:fix_n_jobs
Open

fix: n_jobs in cluster.cluster() not working#22
wuwenrui555 wants to merge 2 commits intodpeerlab:masterfrom
wuwenrui555:fix_n_jobs

Conversation

@wuwenrui555
Copy link

Fix bug that there are more processes than expected after setting n_jobs in phenograph.cluster() function.

row indices, column indices, and nonzero values for a sparse adjacency matrix
"""
if n_jobs == -1:
n_jobs = cpu_count()
Copy link

@jpintar jpintar Sep 23, 2025

Choose a reason for hiding this comment

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

I would not use multiprocessing.cpu_count() here – in HPC contexts it won't always correctly pick up how many cores your job has been allocated, but the total core count of the node. It's safer to use len(os.sched_getaffinity(0)) instead (there's also os.process_cpu_count() introduced in Python 3.13).

Hopefully this pull request gets incorporated... Not sure how actively Phenograph is being maintained...

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! You're absolutely right about the HPC context issue.
I've updated the code to use len(os.sched_getaffinity(0)) instead.

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