fix(train): drop selection_metric from --model-config before model construction - #326
Merged
Merged
Conversation
…nstruction leech model optimize writes selection_metric into best_params.json for provenance, but handle_train had no consumer for that key -- it fell through extra_kwargs into get_model()'s constructor kwargs and raised TypeError, breaking the documented optimize -> train --model-config workflow. Add it to _explicit_keys alongside checkpoint_metric, the existing precedent for exactly this kind of bookkeeping-only key. Refs #324
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
leech model optimizewritesselection_metricintobest_params.jsonfor provenance, buthandle_trainhad no consumer for that key — it fell throughextra_kwargsintoget_model()'s constructor kwargs and raisedTypeError: model got unexpected keyword argument(s): selection_metric, breaking the documentedoptimize->train --model-config best_params.jsonworkflow."selection_metric"to the_explicit_keysset insrc/leech/commands/train.py::handle_train, matching the existingcheckpoint_metricprecedent — a metric-selection value that is pure bookkeeping/provenance, not an architecture param.best_params.jsonstill recordsselection_metricafter this change; only--model-configconsumption strips it beforeget_model()is called.Closes #324
Test plan
uv run pytest tests/test_gridsearch.py -v— 35 passed, including two new regression tests (TestBestParamsJsonRoundTrip):test_best_params_json_records_selection_metric— confirmsbest_params.jsonstill containsselection_metric(provenance not regressed)test_best_params_json_does_not_crash_train— confirmshandle_train(..., model_config=best_params.json)no longer raisesTypeErroruv run pytest tests/test_config_propagation.py -v— 31 passed (existing_explicit_keys/handle_traincoverage, no regression)uv run ruff format --check src/leech/commands/train.py tests/test_gridsearch.py— cleanuv run ruff check src/leech/commands/train.py tests/test_gridsearch.py— cleanuv run ty check src/leech/— clean🤖 Generated with Claude Code