feat(training): add --config-path to config validate and unify config composition#1216
Open
frazane wants to merge 2 commits into
Open
feat(training): add --config-path to config validate and unify config composition#1216frazane wants to merge 2 commits into
frazane wants to merge 2 commits into
Conversation
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.
Description
Add
--config-path/-itoanemoi-training config validateso a config living in any directory can be validated without firstcd-ing into it, and route bothconfig validateandconfig dumpthrough a single Hydra-composition helper. This bringsvalidatein line withtrain(which honours Hydra's--config-path) anddump(which already exposes--config-path/-i). Closes #1184.What problem does this change solve?
A new, backward-compatible feature plus an internal cleanup.
validatewas the only config-consuming subcommand with no way to say where the config lives: it exposed only--config-name,--overwriteand--mask_env_vars, and composed with an empty primary path (initialize(version_base=None, config_path="")), so a config was reachable only throughAnemoiSearchPathPlugin— the current working directory and the packaged defaults. Validating a config anywhere else meant changing directory first.When
--config-pathis given, the config is now composed from that directory via Hydra'sinitialize_config_dir, which installs it as the primary (main) search-path entry — the same precedence@hydra.maingivestrain's--config-path:--config-path> current working directory > packaged defaults (the model #1181 established). When it is omitted, behaviour is unchanged, and the misleadingconfig_path=""(which did no useful work) is dropped.What issue or task does this change relate to?
Closes #1184. Follows #1181, which made the user-specified
--config-pathtake precedence and simplified the search-path hierarchy fortrain.Additional notes
validateanddumpnow share one composition helper —initialize_config_dir(dir)when a--config-pathis given, plaininitialize()otherwise. This replacesdump's previous approach of copying the directory's files into a temporary directory andchdir-ing into it, a workaround that existed only because Hydra'sinitializeresolvesconfig_pathrelative to the calling module and so cannot take an arbitrary user directory.dump's observable behaviour is unchanged — it still composes the named config from the given directory, or from the working directory and packaged defaults when none is given — but it no longer copies files or mutates the process working directory.Tests:
tests/unit/commands/test_config.pycoversvalidatecomposing a config discovered only via--config-path, anddumpcomposing from a--config-pathdirectory. Docs: a note and example were added todocs/user-guide/configuring.rst.This change was developed in tandem with AI coding agents.
As a contributor to the Anemoi framework, please ensure that your changes include unit tests, updates to any affected dependencies and documentation, and have been tested in a parallel setting (i.e., with multiple GPUs). As a reviewer, you are also responsible for verifying these aspects and requesting changes if they are not adequately addressed. For guidelines about those please refer to https://anemoi.readthedocs.io/en/latest/
By opening this pull request, I affirm that all authors agree to the Contributor License Agreement.
📚 Documentation preview 📚: https://anemoi-training--1216.org.readthedocs.build/en/1216/
📚 Documentation preview 📚: https://anemoi-graphs--1216.org.readthedocs.build/en/1216/
📚 Documentation preview 📚: https://anemoi-models--1216.org.readthedocs.build/en/1216/