refactor(logging): per-module loggers, no library-side basicConfig#31
Merged
Conversation
…loggers
Removed the five `logging.basicConfig(level=logging.INFO)` calls at the
top of config.py / data.py / model.py / nn.py / utils.py. Libraries
should not call basicConfig — it permanently overrides the user's own
logging configuration the moment scmidas is imported.
Each module now does the canonical thing:
logger = logging.getLogger(__name__)
and all `logging.info/warning/error/debug(...)` calls were rewritten as
`logger.info/...(...)`. Users who want to see scmidas's INFO messages
just configure logging themselves once at the top of their script:
import logging
logging.basicConfig(level=logging.INFO)
To keep the demo notebooks visually identical (they relied on the old
auto-config to surface "Total number of samples...", training progress
messages, etc.), demo1/2/3 now do exactly that on the first code cell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop overriding the user's logging config at import time. Libraries should not call
logging.basicConfig— replaced with module-levellogger = logging.getLogger(__name__)in all 5 affected files.Changes
logging.basicConfig(level=INFO)and add a module-scopedlogger. Alllogging.info/...calls rewritten aslogger.info/...(50 call sites).import logging; logging.basicConfig(level=logging.INFO)themselves at the top of the first code cell, so visible output is unchanged for users running the tutorials.Test plan
pytest tests/— 37/37 pass locallyimport scmidasno longer mutates root logger handlers or level