AnswerDotAI / AnswerDotAI/nbdev

nbdev_test having issues because of Python caching modules

Open
#1,370 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Jupyter Notebook
Stars
5.3k
Forks
513
Avg merge
2d 30m
Merged PRs (30d)
8

Description

No need to add example as the explanation of the issue is simple.
nbdev_test uses up to 8 workers (threads) to run the tests, if we have a library called new_lib for example that its `__init__` file has some global variables in it, if we have more than 8 tests, there will be a worker that will run more than one test, and because all the tests do import new_lib, that worker that runs more than one test won't import new_lib again and give the new test a fresh new environment as new_lib is already in sys.modules so because of Python caching modules it won't be imported again.
you should do something that refreshes workers before assigning them new tests

Contributor guide

Open the contributing guide

Research direction

Start at the nbdev_test entry point and trace how its up-to-8-worker test assignments are managed. Reproduce the issue with more than eight tests that import a module with global state; done means a worker refreshes its imported module state before receiving another test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.