Refactor train.py and cfg to allow hydra tab completion #127
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.
Goal
Add Hydra tab completion for
train.py
to help users write commands more quickly, rather than needing to constantly check the config yaml files to remember the parameter names (eg. I kept forgetting if it wasnum_envs
ornumEnvs
)^ Example gif showing what the tab completion looks like
How To Use
To set up, run:
Then simply type
python train.py
and then the tab completion will work. You can start typing a parameter name (eg.python train.py num_
) and press tab to either autocomplete or show possible completions.Low-Level Details About Changes
train.py
imports into the function because these imports caused prints to terminal that made the tab completion setup not work correctly_self_
at the end of the default list in hydra to avoid warning messages that made the tab completion not work as nicely (https://hydra.cc/docs/upgrades/1.0_to_1.1/default_composition_order/). This matches the behavior from before.override
in config file to avoid warning (https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/defaults_list_override/)Relevant Screenshots from Hydra Documentation
^ currently using version_base 1.1, so set this explicitly
^ using version 1.1, so put
_self_
last^ add explicit override term