Skip to content

Run each notebook in its own process - #1663

Merged
jph00 merged 2 commits into
mainfrom
fresh-workers
Nov 5, 2026
Merged

jph00 merged 2 commits into
mainfrom
fresh-workers

Conversation

@jackhogan

Copy link
Copy Markdown
Contributor

Make nbdev-test and nbdev-docs run each notebook in a fresh process.

They map notebooks over a ProcessPoolExecutor, which reuses workers, and a worker keeps sys.modules between notebooks. So any module-level state one notebook changes is still there for the next notebook that lands in the same worker. Which notebooks share a worker depends on scheduling, so tests can pass or fail by chance, and nbdev-test --save can write outputs that include another notebook's state.

Both call sites now pass max_tasks_per_child=1 to fastcore's parallel (fastcore#961) which retires a worker after one notebook.

Requires fastcore>=2.2.39 and Python 3.11, so the tomli fallback is gone too.

@jackhogan jackhogan self-assigned this Nov 5, 2026
@jackhogan jackhogan added the bug Something isn't working label Nov 5, 2026
@jackhogan
jackhogan requested a review from jph00 November 5, 2026 16:18
Comment thread tests/test_test.py
@@ -0,0 +1,9 @@
from fastcore.nbio import new_nb, write_nb, mk_cell

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Careful not to add tests like this. It's a whole new test file just to test a fact that python already makes true by definition. AI is more than happy to let complexity in test suites blow up. It thinks of that as a good thing, because RLHF feedback rewards adding more tests!

@jph00
jph00 merged commit ee62000 into main Nov 5, 2026
0 of 12 checks passed
@jph00
jph00 deleted the fresh-workers branch November 5, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants