Repository navigation
Conversation
|
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
left a comment
There was a problem hiding this comment.
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.
7f1cdc1 to
2b971d4
Compare
…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]>
2b971d4 to
8db168e
Compare
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
mainplus 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.pyrename_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 aDeprecationWarningnaming the new key.ConflictingRenamedKeyError, which says which key to remove. It is a config error, so the command line reports it in one line, without a traceback.???) under either name is a required value not given yet, so the other name fills it.RENAMED_TOP_LEVEL_KEYSlists renamed top-level keys.RENAMED_SERVER_INSTANCE_KEYSlists, per server type such asresponses_api_agents, keys renamed inside each server instance of that type. A rename PR adds its entries here.with_renamed_keysis for a Pydanticmode="before"validator, so a model built directly still accepts a field under its old name. It leaves the caller's mapping unchanged.renamed_attributeis 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 aTypeError, 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:...},_copyor_delete_key, still names the old key, and the module docstring says so.Config parser
GlobalConfigDictParser.parserenames 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 --fileson the changed files: passed.guardwords-checkrun on its own on the whole diff: passed.tests/unit_tests/config/,tests/unit_tests/cli/test_cli.pyandtests/unit_tests/test_moved_paths.py: passed.lint-imports: the layer contract is kept._inherit_from;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.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.