Skip to content

fix: 🐛 stop configuring global logging; replace structlog with stdlib logging - #52

Merged
Panadestein merged 1 commit into
mainfrom
fix/stdlib-logging
Oct 6, 2026
Merged

Panadestein merged 1 commit into
mainfrom
fix/stdlib-logging

Conversation

@Panadestein

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Fixes #11.

What

Importing src_method used to call logging.basicConfig() (root at INFO, a stdout StreamHandler) and a global structlog.configure(). These now sit in stack.py, since apply/compress delegate to src. This PR switches to the usual library logging pattern:

  • structlog is removed from [project.dependencies] (and uv.lock).
  • src_method/utils/logging_config.py, setup_logging() and the LOG_LEVEL_SRC env var are removed.
  • Every module uses logger = logging.getLogger(__name__) with lazy %-style arguments. src_method/__init__.py adds a NullHandler to the package logger.
  • The per-call "Starting SRC" / "SRC complete" messages go from INFO to DEBUG. The sweep timings were already DEBUG, and the expensive "largest environment" size is computed only when DEBUG is on.
  • The small-network fallback still logs at WARNING. Thanks to the NullHandler it no longer reaches stderr unless the application configures logging.

Tests

New tests/test_logging.py:

  • Imports the package in a fresh interpreter and checks that the root logger's level and handlers don't change.
  • Checks that apply/compress print nothing to stdout or stderr by default, including on the fallback path.
  • Checks that progress records reach the src_method logger at DEBUG when it is enabled.

Docs and tooling

  • README.md and docs/index.md have a new Logging section on how to turn logging on.
  • AGENTS.md now describes the stdlib logging rule.
  • The benchmark scripts (benches/stack/bench_depth.py, benches/primitives/leonardo/bench_mpo_mpo.py) use stdlib logging and configure it themselves in __main__. LOG_LEVEL_SRC is gone from run.sh and the stack bench README.

uv run prek run --all-files is clean, and uv run pytest -m "not slow" gives 123 passed, 1 skipped (no CuPy).

… logging

Importing src_method no longer calls logging.basicConfig() or
structlog.configure(), so the root logger level and handlers of the host
application are left untouched. The package now uses
logging.getLogger(__name__) per module with a NullHandler on the top-level
logger, emits progress messages at DEBUG with lazy %-style arguments, and
drops the structlog runtime dependency and the LOG_LEVEL_SRC variable.

Fixes #11

Assisted-by: pi:claude-opus-5.5
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Test Results

  4 files  ± 0    4 suites  ±0   2m 6s ⏱️ -7s
135 tests + 4  134 ✅ + 4  1 💤 ±0  0 ❌ ±0 
516 runs  +16  514 ✅ +16  2 💤 ±0  0 ❌ ±0 

Results for commit b53e07d. ± Comparison against base commit fe38d6d.

@Panadestein
Panadestein merged commit daa6520 into main Oct 6, 2026
14 checks passed
@Panadestein
Panadestein deleted the fix/stdlib-logging branch October 6, 2026 12:59
Panadestein added a commit that referenced this pull request Oct 7, 2026
Resolve the conflicts with stdlib logging (#52), input-precision
sketches (#36), validation (#38), ty enforcement (#37, #55) and the
Fumadocs site (#56):

- the sweep draws its sketches with gaussian_sketch and logs its plan,
  pass times and stalls at DEBUG with %-style arguments;
- the working dtype is promoted over every site, not just the first;
- docs/large-problems.md moves to features/large-problems.mdx and the
  out-of-core testing notes to contributing/testing.mdx;
- bench_large.py logs through the stdlib and gains --debug.

Type lazily read sites: the entry points accept any array-like with
shape, dtype, ndim and np.asarray support but were typed
Sequence[NDArray]. Add the SiteLike protocol and the Site alias, use
them from src/apply/compress down to the site source, and export
SiteLike. Also fix the other ty findings: the Tier list in the planner,
known_kind() for validated trains, padded_shape without a type: ignore,
cupyx as an allowed unresolved import, and typed fakes in the tests.

Assisted-by: pi:claude-opus-5.5
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.

Stop configuring global logging at import; replace structlog with stdlib logging

1 participant