Skip to content

FIX: Respect Joblib context in config sync (Issue #76)#154

Closed
ANJAN672 wants to merge 3 commits into
networkx:mainfrom
ANJAN672:fix-config-synchronization
Closed

FIX: Respect Joblib context in config sync (Issue #76)#154
ANJAN672 wants to merge 3 commits into
networkx:mainfrom
ANJAN672:fix-config-synchronization

Conversation

@ANJAN672
Copy link
Copy Markdown
Contributor

@ANJAN672 ANJAN672 commented Jan 2, 2026

Fixes #76 (partial)

Problem

When using joblib.parallel_config(n_jobs=X), nx-parallel was ignoring the value and always using nx.config.backends.parallel.n_jobs.

Solution

  • Modified decorators.py to peek at Joblib's active context before overriding
  • Modified chunk.py to prioritize Joblib's active value over NX config

Known Limitation

When NX context is nested inside Joblib context, Joblib still wins. Full sync requires upstream changes to both libraries.

Tests

All 89 existing tests pass.

Copy link
Copy Markdown
Member

@Schefflera-Arboricola Schefflera-Arboricola left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @ANJAN672 !

When using joblib.parallel_config(n_jobs=X), nx-parallel was ignoring the value and always using nx.config.backends.parallel.n_jobs

you can change that by setting active=False in nx.config , read - https://github.com/networkx/nx-parallel/blob/main/Config.md

Also read - #76 (comment) -- And please consider closing this PR if you agree with it. Thx!

Comment thread nx_parallel/utils/decorators.py
@ANJAN672 ANJAN672 closed this Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Synchronizing NetworkX and Joblib configurations in nx-parallel

2 participants