Skip to content

Commit 7d97d90

Browse files
edenoclaude
andcommitted
Fix test_mode propagation by checking dj.config directly
Root cause: When settings.py is first imported, module-level variables like test_mode are set from sg_config at import time (line 725). Later, when test fixtures call load_config(test_mode=True), it updates sg_config._test_mode and dj.config['custom']['test_mode'], but the module-level variable stays stale. The _test_mode property in BaseMixin was doing: from spyglass.settings import test_mode return test_mode # Returns stale module-level variable! This caused electrode validation to run during tests even though test_mode should be True, because it was checking the stale module variable that was set to False at initial import. Fix: Changed _test_mode to check dj.config['custom']['test_mode'] directly instead of importing the module-level variable. This avoids global variables and ensures we always get the current config state. This is why PR #1454's electrode validation worked on master but failed when merged with our branch - subtle import order differences meant our branch triggered settings import earlier, before fixtures could update test_mode. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent d99d873 commit 7d97d90

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/spyglass/utils/mixins/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ def _test_mode(self) -> bool:
4646
- BaseMixin._spyglass_version
4747
- HelpersMixin
4848
"""
49-
from spyglass.settings import test_mode
49+
import datajoint as dj
5050

51-
return test_mode
51+
# Check dj.config directly instead of importing module-level variable
52+
# which gets stale if load_config() is called after initial import
53+
return dj.config.get("custom", {}).get("test_mode", False)
5254

5355
@cached_property
5456
def _spyglass_version(self):

0 commit comments

Comments
 (0)