feat(config): warn on unrecognized brain.config keys at load time - #253
Conversation
Unknown keys under brain.config are silently dropped when the YAML is parsed into the brain config model (Pydantic ignores extras), so a typo'd or dead hyperparameter no-ops without any signal â e.g. the T7 mlpppo C3 config set entropy_coef_end / entropy_decay_episodes, but mlpppo does not implement an entropy schedule, so it ran flat the whole time and nobody noticed. load_simulation_config now compares the raw YAML brain.config keys against the resolved brain config class's fields and logs a warning listing any dropped keys. Surfaces the dead param at load instead of letting it silently no-op. (A repo scan via this check finds ~71 configs with dropped keys â notably `normalize_advantages` on 60+ mlpppo configs, which mlpppo never implemented. Those are pre-existing and cleaned separately; this change only adds the signal.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. âđïļ Recent review infoâïļ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ð Files selected for processing (1)
ð WalkthroughWalkthrough
ChangesUnknown brain config key warnings
Estimated code review effortðŊ 2 (Simple) | âąïļ ~10 minutes Possibly related issues
Poem
ðĨ Pre-merge checks | â 5â Passed checks (5 passed)
âïļ Tip: You can configure your own custom pre-merge checks in the settings. âĻ Finishing Touchesð Generate docstrings
ð§Š Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ðĪ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/quantum-nematode/quantumnematode/utils/config_loader.py`:
- Around line 2536-2542: The docstring for the function starting with "Warn
about ``brain.config`` keys..." does not follow the required NumPy-style format.
Reformat the docstring to include the required structured sections: add a
Parameters section that documents all function arguments with their types and
descriptions, and add a Returns section that documents what the function
returns. Preserve the existing summary and extended description content, but
structure them according to NumPy docstring conventions which require these
standard sections for complete documentation.
ðŠ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
âđïļ Review info
âïļ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 234055e8-6080-4a74-b209-0f7a511d1d3d
ð Files selected for processing (2)
packages/quantum-nematode/quantumnematode/utils/config_loader.pypackages/quantum-nematode/tests/quantumnematode_tests/utils/test_config_loader.py
| """Warn about ``brain.config`` keys the brain's config class does not declare. | ||
|
|
||
| Unknown keys are silently dropped when the YAML is parsed into the brain config | ||
| model (Pydantic ignores extras), so a typo'd or dead hyperparameter â e.g. an | ||
| entropy-schedule key on a brain that does not implement the schedule â passes | ||
| without effect. Comparing the raw YAML keys against the resolved brain config | ||
| class's fields here surfaces them at load time, before they silently no-op. |
There was a problem hiding this comment.
ð Maintainability & Code Quality | ðĄ Minor | ⥠Quick win
Docstring does not follow required NumPy-style format.
The coding guidelines require NumPy-style docstrings for functions. The current docstring provides a summary and extended description but is missing the structured Parameters and Returns sections.
ð Proposed NumPy-style docstring
-def _warn_unknown_brain_config_keys(data: object, config_path: str) -> None:
- """Warn about ``brain.config`` keys the brain's config class does not declare.
-
- Unknown keys are silently dropped when the YAML is parsed into the brain config
- model (Pydantic ignores extras), so a typo'd or dead hyperparameter â e.g. an
- entropy-schedule key on a brain that does not implement the schedule â passes
- without effect. Comparing the raw YAML keys against the resolved brain config
- class's fields here surfaces them at load time, before they silently no-op.
- """
+def _warn_unknown_brain_config_keys(data: object, config_path: str) -> None:
+ """
+ Warn about ``brain.config`` keys the brain's config class does not declare.
+
+ Unknown keys are silently dropped when the YAML is parsed into the brain config
+ model (Pydantic ignores extras), so a typo'd or dead hyperparameter â e.g. an
+ entropy-schedule key on a brain that does not implement the schedule â passes
+ without effect. Comparing the raw YAML keys against the resolved brain config
+ class's fields here surfaces them at load time, before they silently no-op.
+
+ Parameters
+ ----------
+ data : object
+ Raw YAML-loaded data, expected to contain a ``brain.config`` dict.
+ config_path : str
+ Path to the configuration file, used in the warning message.
+
+ Returns
+ -------
+ None
+ """ðĪ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/quantum-nematode/quantumnematode/utils/config_loader.py` around
lines 2536 - 2542, The docstring for the function starting with "Warn about
``brain.config`` keys..." does not follow the required NumPy-style format.
Reformat the docstring to include the required structured sections: add a
Parameters section that documents all function arguments with their types and
descriptions, and add a Returns section that documents what the function
returns. Preserve the existing summary and extended description content, but
structure them according to NumPy docstring conventions which require these
standard sections for complete documentation.
Source: Coding guidelines
Codecov Reportâ All modified and coverable lines are covered by tests. ðĒ Thoughts on this report? Let us know! |
Why
Unknown keys under
brain.configare silently dropped when the YAML is parsed into the brain config model (Pydantic ignores extras), so a typo'd or dead hyperparameter no-ops with no signal. This surfaced during T7: themlpppocontinuous-C3 config setentropy_coef_end/entropy_decay_episodes, butmlpppodoesn't implement an entropy schedule â so it ran flat the whole time and nobody noticed until a manual dig-in.What changed
load_simulation_confignow compares the raw YAMLbrain.configkeys against the resolved brain config class's fields and logs a warning naming any dropped keys, before they silently no-op. (The existing_resolve_brain_configwarning couldn't catch these â the keys are dropped at the first YAMLâmodel parse, before it runs.)Validation
mlpppo'sentropy_coef_end/entropy_decay_episodes; silent on clean configs.What it surfaces (follow-ups, out of scope here)
Scanning all configs through the new check finds ~71 configs with dropped keys. The notable one:
normalize_advantageson 60+mlpppoconfigs â andmlpppohas no advantage normalization at all (computes GAE, never normalizes), so that knob has been silently ignored project-wide. Tracked separately (see linked issue) â decide whether to implement advantage normalization or strip the dead key. The T7mlpppoC3 config's dead entropy-schedule keys are cleaned in the T7 ranking PR.ðĪ Generated with Claude Code
Summary by CodeRabbit
New Features
brain.configand warns about unrecognized keys, helping surface typos or unsupported settings earlier.brain.configblocks, and are gracefully skipped when the brain name is unknown or the configuration is missing/malformed.Tests
brain.configkeys, no warnings for recognized keys, and safe behavior when thebrainsection is absent, incomplete, unknown, or not a dictionary.