Skip to content

feat(config): accept renamed config keys and arguments under their old names - #5628

Open
ananthsub wants to merge 7 commits into
mainfrom
ananthsub/renamed-config-keys
Open

ananthsub wants to merge 7 commits into
mainfrom
ananthsub/renamed-config-keys

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Two open PRs rename config keys and need the same compatibility for them: #5533 (token ID capture to token capture) and #5553 (the head server to the registry server). An old key, field or keyword argument has to keep working until nemo_gym 0.10.0, with a warning that names the new one. Until now that code lived in #5533, so #5553 had to be stacked on it. This PR puts the shared code on its own, so both renames build on main plus this PR and either can merge first.

This PR renames nothing. Both rename lists start empty, so on its own it changes no behavior.

It has no issue of its own; it is split out of #5533 and #5553.

nemo_gym/config/renamed_keys.py

  • rename_deprecated_keys(config, renamed, where=...) moves each old key to its new name in place. It moves the value as written, so an interpolation is not resolved on the way. Each move logs a warning and emits a DeprecationWarning naming the new key.
    • A config that sets the old and the new key to different values fails with ConflictingRenamedKeyError, which says which key to remove. It is a config error, so the command line reports it in one line, without a traceback.
    • If both are set to equal values, the new key keeps its value and the config goes ahead with the warning.
    • A key left unset (???) under either name is a required value not given yet, so the other name fills it.
  • RENAMED_TOP_LEVEL_KEYS lists renamed top-level keys. RENAMED_SERVER_INSTANCE_KEYS lists, per server type such as responses_api_agents, keys renamed inside each server instance of that type. A rename PR adds its entries here.
  • with_renamed_keys is for a Pydantic mode="before" validator, so a model built directly still accepts a field under its old name. It leaves the caller's mapping unchanged.
  • renamed_attribute is a read-only property under a field's old name that warns and returns the field.
  • renamed_keyword(old, new) is a decorator that accepts a keyword argument under its old name. Passing both names is a TypeError, as passing any argument twice is. A decorated async function is still detected as async, and the warning points at the caller, for functions and methods alike.

Only keys are renamed. A reference to an old key from elsewhere, such as ${old_key.dir}, ${inherit_from:...}, _copy or _delete_key, still names the old key, and the module docstring says so.

Config parser

GlobalConfigDictParser.parse renames old keys in each source on its own before any merge: the command line, the initial config passed in by a training framework such as NeMo RL, env.yaml, and each config file. So precedence decides between an old and a new key as it does for any key. An old key on the command line overrides the new key in a shipped config, and an old key in a command-line override for a composed agent reaches that agent.

After every merge and composition, the parser renames once more, for an old key that only appears in the merged config, such as one copied in by ${copy:...} from a block that is not a server instance.

Validation

  • pre-commit run --files on the changed files: passed. guardwords-check run on its own on the whole diff: passed.
  • tests/unit_tests/config/, tests/unit_tests/cli/test_cli.py and tests/unit_tests/test_moved_paths.py: passed.
  • lint-imports: the layer contract is kept.
  • The new tests register example renames, one top-level key and one agent instance key, added to any registered ones. They check that:
    • an old key in an initial config, a YAML config or on the command line parses exactly like the new key, and is logged as well as warned;
    • an old key in a source of higher precedence overrides the new key from a config of lower precedence, and the other way round, including a key inherited with _inherit_from;
    • either name fills a key that a config marks required under the other;
    • a command-line override for a composed agent is applied whichever name the override or the agent's config uses;
    • setting the old and the new key in one config to different values is an error at the top level and inside a server instance, and the command line reports it without a traceback; setting both to equal values keeps the new value;
    • an old key whose value is an interpolation moves unresolved, and a config that refers to a key from another config is renamed without resolving it;
    • an old key copied into a server instance is renamed, and a parser step reads a renamed top-level key under its new name;
    • an instance key is renamed only for the server type it is listed under, in a parse that also renames the agent key;
    • a Pydantic model accepts and reads a field under its old name without changing the caller's data;
    • a keyword argument is accepted under its old name by a function, a classmethod and an async method, the warning points at the caller, an async function stays async, and passing both names is an error.
  • Mutation check. Each fix's new tests fail on the code before that fix. I also removed each piece in turn: the rename of each source before the merge, the pass after it, the top-level rename, the server instance rename, the conflict check, the log warning, the copy in with_renamed_keys, the both-arguments check, the async marking, and the keyword warning's stack level. Each time, at least one of the new tests failed.
  • refactor(models): rename token ID capture to token capture #5533 and refactor(server_runtime): rename the head server to the registry server #5553 rebased onto this branch in a scratch worktree: their tests pass, except one test in each that expects a conflict between an old key in one source and the new key in another. With this change the source of higher precedence wins instead, so those tests need both keys in one source.

Smoke run

N/A. Both rename lists are empty, so no config, server or rollout behaves differently. #5533 and #5553 each smoke-test their renames through this code.

User-facing impact

None on its own. Once a rename registers its keys here, configs that use the old keys keep working until 0.10.0 and log a deprecation warning naming the new key.

@copy-pr-bot

copy-pr-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE

Three RISK findings affect registered renames: required-value validation and strict held-override merging can reject valid old names, and rename conflicts bypass the CLI's configuration-error handling. The registries are empty, so these failures don't affect an existing rename yet.

I inspected all three changed files and traced the affected parser, model, call, and CLI contracts. Two delegated reports weren't returned; I covered those helper and decorator topics directly. I couldn't execute tests in this read-only review; the acceptance checks below are proposed.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/config/global_config.py Resolved
Comment thread nemo_gym/config/global_config.py Resolved
Comment thread nemo_gym/config/renamed_keys.py Resolved
…d names

Renames of config keys, Pydantic fields and keyword arguments each need
the same compatibility: the old name keeps working until nemo_gym 0.10.0,
with a warning that names the new one. Add that once, so each rename only
lists what it renamed.

- rename_deprecated_keys moves old keys to their new names in place. It
  logs a warning and emits a DeprecationWarning, and it fails when a
  config sets the old and the new key to different values.
- The config parser runs it after every merge on the keys listed in
  RENAMED_TOP_LEVEL_KEYS and, inside each server instance of a server
  type, in RENAMED_SERVER_INSTANCE_KEYS. An old key from a config file,
  the command line or a framework's initial config is moved the same way.
  Both lists start empty.
- with_renamed_keys and renamed_attribute let a Pydantic model accept a
  field under its old name and still read it there.
- renamed_keyword lets a function accept a keyword argument under its old
  name. Passing both names is a TypeError, and async functions stay async.

Signed-off-by: Ananth Subramaniam <[email protected]>
Reading the old key resolved its value, so an interpolation such as
${oc.env:...} was frozen under the new key, and a child server that
resolves the config in its own environment got the parent's value. The
rename now moves the value as written, and the parser walks the config
by node, so neither resolves an interpolation.

When the old and the new key are both set to equal values, the new key
now keeps its own value. Before, the old value replaced it, so `1`
could replace `true`.

Signed-off-by: Ananth Subramaniam <[email protected]>
The parser renamed old keys once, after every source was merged. An old
key from the command line, the initial config or env.yaml then sat next
to the new key from a shipped config, and the parse failed with a
conflict, though the command line should simply win. For the same
reason, an old key could not fill a new key a config left as `???`, and
a command-line override held back for a composed agent failed in struct
mode when either side used the old key.

The parser now renames the command line, the initial config, env.yaml
and each config file on its own, before any merge, so precedence decides
between an old and a new key as it does for any key. Setting both in
one source to different values is still an error. The pass over the
merged config stays, for an old key that only appears there, such as one
copied in by `${copy:...}`.

Signed-off-by: Ananth Subramaniam <[email protected]>
ConflictingRenamedKeyError was only a ValueError, so the command line
printed a traceback for it instead of the one-line error it prints for
every other config mistake. It is now a ConfigError as well. It stays a
ValueError, so a Pydantic validator that raises it still reports a
validation error.

Signed-off-by: Ananth Subramaniam <[email protected]>
…does not

The comments said the parser renames keys after every merge and that an
old key behaves exactly as the new one. The parser now renames each
source before merging, and only keys are renamed: a reference to an old
key, through an interpolation, `_copy`, `_inherit_from` or
`_delete_key`, still names the old key. Say that, say what happens when
a config sets both names, and name the removal release once, through
RENAMED_KEYS_REMOVED_IN.

Signed-off-by: Ananth Subramaniam <[email protected]>
- Check that each renamed key is logged. Python hides DeprecationWarning
  outside __main__, so the log is what a config author sees.
- Check the server type scope in a parse that also renames the agent
  key, so the test fails when nothing is renamed.
- Check that an old key copied into a server instance is renamed, and
  that a parser step reads a renamed top-level key under its new name.
- Check that a classmethod and an async method accept an old keyword
  argument and warn at the caller.
- Add the example agent rename to the registered ones instead of
  replacing them.

Signed-off-by: Ananth Subramaniam <[email protected]>
An OmegaConf key left unset (`???`) is not `in` a DictConfig, so an old
key that a config marked required was skipped and stayed behind. The
missing-value check then reported it whichever name the user set. An
unset old key now moves to the new name, and an unset key under either
name never counts as a conflict, so the other name fills it.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/renamed-config-keys branch from 2b971d4 to 8db168e Compare November 5, 2026 06:15
@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:config Hydra configuration, schemas, composition, and compatibility needs-review PR is ready for code review and waiting on a reviewer labels Nov 7, 2026

This branch was previously deployed

1 inactive deployment
public — 8db168ed Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:config Hydra configuration, schemas, composition, and compatibility feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants