-
-
Notifications
You must be signed in to change notification settings - Fork 663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Allow selecting config group in another config group #1091
Comments
Hi @lordofluck, Those two are high priority, and in fact recursive instantiation is already implemented in master, and recursive defaults list is in advanced stages in #1044. Please experiment with the existing recursive defaults from master. You can learn about it in the updated docs for instantiation here. Closing as duplicate. |
Hi @omry, thanks for your answer. I am aware of the state of recursive instantiation that you described. There might be a misunderstanding. I would like to be able to use recursive configuration without having to specify the config for the nested object inside the container object if the nested object has its configuration in a separate file (is part of defined config group). Right now, I have to do eg.:
even if there is _target_: model.ResNet
num_layers: 50 I want to be able to do the following:
Then, I should be able to do something like |
You can already do in 1.0 by having two items in your defaults list in the primary config: defaults:
- trainer # will use trainer.yaml
- model: resnet # will use model/trainer.yaml You can use package overrides to place the model inside the trainer: defaults:
- trainer
- model@trainer: resnet # the content of model/trainer.yaml will be rooted at trainer You can also place your config groups hierarchically from the start (in such a cause I strongly recommend using
|
Ok thank you very much. I will try the mentioned approaches. |
🚀 Feature Request
I would like to be able to select an option for a given config group in another config group. I would also like to be able to instantiate all necessary nested objects recursively with a single command.
Motivation
I want to use as many classes in my projects as possible as config groups inside hydra configs. Moreover, I want to be able to automatically compose most of the objects with a single
instantiate
command. Right now I have list of defaults in the root config file and then instantiate and compose all the objects one by one in my main script. This allows me to select each Class from a config group easily (python my_app.py optionA=ClassX optionB=ClassY
), but does not help with recursive instantiation. As the project grows, I add more and more configs to the defaults list and more instantiate statements tomy_app.py
, but most of the instantiated objects are simply passed to several container objects and could be instantiated recursively. But by nesting configs for the contained objects inside the container objects, I lose the ability to treat the contained objects as config groups, which is frustrating.Pitch
Describe the solution you'd like
For example, I have Tokenizer classes and Normalizer classes. I would like to be able to do the following:
Then I would simply call
python my_app.py tokenizer.normalizer=GermanTextNormalizer
to change the group config option for normalizer to german normalizer instead of the english one.Describe alternatives you've considered
Right now, if I want to use both Tokenizer and Normalizer classes as config groups, I have to instantiate the objects separately and pass the normalizer to the tokenizer as an argument inside my python code. This becomes cumbersome as the project grows.
Would this be considered a useful feature in the future?
The text was updated successfully, but these errors were encountered: