refactor(server): extract /api/tunings into routers/tunings.py + lib/appconfig.py (R3) - #858
Merged
Merged
Conversation
…appconfig.py (R3) The merged-tuning-catalog route moves to lib/routers/tunings.py, verbatim except @app->@router, CONFIG_DIR->appstate.config_dir, and the two seam substrates it needed: - lib/appconfig.py — the pure config.json reader `_load_config` (used by ~11 server sites + future config-reading routers). server.py re-imports it, so those call sites and any `server._load_config` test reference are unchanged. - appstate.tuning_providers — the TuningProviderRegistry instance injected by reference (a stable object mutated in place via register()/unregister()), so the router reads the same registry plugins populate through plugin_context. The instance stays defined in server.py, so `server.tuning_providers` still resolves — zero test retargets. The tuning constants (DEFAULT_REFERENCE_PITCH, TUNING_PRESET_MIDIS, freqs_to_midis) already live in lib/tunings.py and are imported directly. server.py: 6,960 -> 6,917. Verified: pyflakes clean (bar the pre-existing unused `tuning_name` import); route table IDENTICAL (143); full pytest 2400 passed (110 tuning/config cases); eslint 0. Boot smoke: /api/tunings serves referencePitch + tunings + tuningMidis. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe tuning API implementation moves from ChangesTuning API extraction
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant get_tunings
participant _load_config
participant tuning_providers
Client->>get_tunings: GET /api/tunings
get_tunings->>_load_config: Read config.json
get_tunings->>tuning_providers: get_merged(referencePitch)
tuning_providers-->>get_tunings: Merged tunings
get_tunings-->>Client: referencePitch, tunings, tuningMidis
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
The merged-tuning-catalog route →
lib/routers/tunings.py, verbatim except@app→@router,CONFIG_DIR→appstate.config_dir, and two reusable seam substrates:lib/appconfig.py— the pureconfig.jsonreader_load_config(used by ~11 server sites + future config-reading routers).server.pyre-imports it, so those call sites and anyserver._load_configtest reference are unchanged.appstate.tuning_providers— theTuningProviderRegistryinstance injected by reference (a stable object mutated in place viaregister()/unregister()), so the router reads the same registry plugins populate viaplugin_context. The instance stays defined inserver.py, soserver.tuning_providersstill resolves — zero test retargets.Tuning constants (
DEFAULT_REFERENCE_PITCH,TUNING_PRESET_MIDIS,freqs_to_midis) already live inlib/tunings.pyand import directly.server.py: 6,960 → 6,917.Verification
pyflakesclean bar the pre-existing unusedtuning_nameimport.pytest2400 passed (110 tuning/config cases);npm run lint0; Codex 0 findings./api/tuningsservesreferencePitch+tunings+tuningMidis.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation