Skip to content

refactor(logging): per-module loggers, no library-side basicConfig#31

Merged
zhen-he merged 1 commit into
mainfrom
refactor/library-logging
May 3, 2026
Merged

refactor(logging): per-module loggers, no library-side basicConfig#31
zhen-he merged 1 commit into
mainfrom
refactor/library-logging

Conversation

@zhen-he

@zhen-he zhen-he commented May 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stop overriding the user's logging config at import time. Libraries should not call logging.basicConfig — replaced with module-level logger = logging.getLogger(__name__) in all 5 affected files.

Changes

  • 5 modules (config / data / model / nn / utils) drop logging.basicConfig(level=INFO) and add a module-scoped logger. All logging.info/... calls rewritten as logger.info/... (50 call sites).
  • Demo notebooks (demo1/2/3) now do 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 locally
  • Verified that import scmidas no longer mutates root logger handlers or level
  • CI matrix green (torch 2.5 × py3.10/3.11/3.12, torch 2.8 × py3.12, torch 2.10 × py3.12)

…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.
@zhen-he zhen-he merged commit b552e76 into main May 3, 2026
5 checks passed
@zhen-he zhen-he deleted the refactor/library-logging branch May 3, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant