fix: honor explicit name: field in override_* sections - #204
Conversation
Previously, generate_override_configs always overwrote the merged name
with an auto-generated "{base_name}_{suffix}", even when the override
dict supplied an explicit name: field. Now the auto-generated name is
only used as a fallback when no name is provided, consistent with how
zip_override_* already handles named variants.
Adds test coverage for the new behavior.
📝 WalkthroughWalkthroughModified the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/srtctl/core/config.py (1)
316-321: Consider extracting shared override-merge naming logic into a helper.The same block appears twice; a helper reduces drift risk and keeps behavior changes centralized.
♻️ Proposed refactor
+def _merge_override_variant(base: dict[str, Any], override_dict: dict[str, Any], suffix: str) -> dict[str, Any]: + merged = deep_merge(base, override_dict) + if "name" not in override_dict: + base_name = base.get("name", "unnamed") + merged["name"] = f"{base_name}_{suffix}" + return merged + def generate_override_configs( raw_config: dict[str, Any], selector: str | None = None, ) -> list[tuple[str, dict[str, Any]]]: @@ suffix = selector[len("override_") :] override_dict = raw_config[selector] - merged = deep_merge(base, override_dict) - if "name" not in override_dict: - base_name = base.get("name", "unnamed") - merged["name"] = f"{base_name}_{suffix}" + merged = _merge_override_variant(base, override_dict, suffix) return [(suffix, merged)] @@ for key in override_keys: suffix = key[len("override_") :] override_dict = raw_config[key] - merged = deep_merge(base, override_dict) - if "name" not in override_dict: - base_name = base.get("name", "unnamed") - merged["name"] = f"{base_name}_{suffix}" + merged = _merge_override_variant(base, override_dict, suffix) configs.append((suffix, merged))Also applies to: 327-331
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/srtctl/core/config.py` around lines 316 - 321, There are two identical blocks that merge an override into a base and set a default name if missing; extract this into a small helper (e.g., _merge_override_with_name(base, override_dict, suffix)) that calls deep_merge(base, override_dict), ensures merged["name"] is set to f"{base.get('name','unnamed')}_{suffix}" when "name" not in override_dict, and returns (suffix, merged); then replace the duplicated blocks in the functions that currently use the inline logic with a call to this helper to centralize behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/srtctl/core/config.py`:
- Around line 316-321: There are two identical blocks that merge an override
into a base and set a default name if missing; extract this into a small helper
(e.g., _merge_override_with_name(base, override_dict, suffix)) that calls
deep_merge(base, override_dict), ensures merged["name"] is set to
f"{base.get('name','unnamed')}_{suffix}" when "name" not in override_dict, and
returns (suffix, merged); then replace the duplicated blocks in the functions
that currently use the inline logic with a call to this helper to centralize
behavior.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f0eef751-7810-415d-9e5b-a27ee75128f0
📒 Files selected for processing (2)
src/srtctl/core/config.pytests/test_override.py
Summary
generate_override_configspreviously ignored anyname:field inside anoverride_*dict, always overwriting it with an auto-generated{base_name}_{suffix}. Now the auto-generated name is only used as a fallback when noname:is provided — consistent with howzip_override_*already handles named variants.Example
Before: dry-run showed
b200-fp4-mtp-8k1k_maxtpt_4p1dAfter: dry-run shows
b200-fp4-max-tpt-dep4-4p-dep8-1dTest plan
make checkpasses (335 tests)Summary by CodeRabbit
Bug Fixes
Tests