-
-
Notifications
You must be signed in to change notification settings - Fork 656
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] Override loaded config file through a command line flag #386
Comments
Can this file be inside the search path (in the same directory as the config file you specify in @hydra.main() )? If so, try:
and from the command line:
This will override your config file with exp1. |
No. |
The reason why I use hydra is that the configuration of my cli is a little bit complexed and hydra is suitable for my cli. |
Yes it would be definitly helpful to be able to change the config_name from the CLI interface. Hydra sounds super helpful to simplify the architecture of some of my modules but the user should be able to redefine the config from scratch... |
This is more involved than it sounds. This is also a user facing interface. which means it's not very forgiving to many changes. I want to get this right from the first time. There are other higher priority issues I am working on. I will get to it. |
This is a clean workaround that addresses most of the use cases: In conf, create a directory called experiment:
Each one can specialize the generated config, for example exp1.yaml can be: exp1.yaml: learning_rate: 0.1
batch_size: 32 Now from the command line: There are some use cases where an external config file can be useful, but this should cover a large number of the use cases. |
Hi there, I just wanted to +1 for this feature request. My use case is as follows. I have a complex configuration file with lots of details the user will not need to interact with, e.g. optimizers. There are elements, particularly regarding the data and augmentations, that all users will have to customize. Default
What I want is to be able to use the following syntax and have Hydra load the default configuration file first, and optionally override with the user's supplied config file: Ideally, the user could also supply command line arguments which would take precedence over all. I'm not sure if this is too unique to my use case. I want the priority to be Is there a way to do this currently with hydra? |
Please reach out on the chat. |
I'm currently using a workaround for a similar case. Default conf/config.yaml: user_config: # path to config file to update.
train:
lr: 0.0001
optimizer: adam
dataset:
name: imagenet
classes:
- tench
... Then, in the if config.user_config is not None:
user_config = OmegaConf.load(config.user_config)
config = OmegaConf.merge(config, user_config) Now, you can use |
This comment goes in the direction of @jbohnslav, I think @tamuhey 's question can, but does not have to be connected with it because in this case I assume you can have a userconfig inside the search path.
And the output is:
For
Then start via:
I do not know what happens here exactly but as long as it works.. |
I just found that it is sufficient to have the following main config file
Then generally, its base and you can overwrite it on the commandline. Still, I do not know if there are unwanted side effects. |
@gunthergl, I mentioned this approach in multiple comments above. |
Hi, By the way, I suggest this workaround:
This way you can specify your config file by adding |
This requested feature is also a will-have. |
This is coming, and by "this", I mean what I am ready to support at this stage: This feature is opening up the door for overriding the config name and the config path individually through a simple command line flag. Limitations
I am not planning on doing more than this for 1.0. |
#874 is coming in Hydra 1.0.0rc3 and will probably address most uncovered use cases. |
Wow, |
Hydra 1.0.0 already has rc2 released which you can try today ( |
@omry I think a use case is to reload the configs in .hydra if overriding happened during previous runs.
Then I get the overrided configs in .hydra:
Now, I can reproduce my training with the following command line:
That's great. However, how can I explicitly combine the overrides.yaml with the primary configs in config directory? For example, here I want to reload my model for inference. What I want is:
Maybe it's ad-hoc to split the config into train.yaml and eval.yaml. Here's another use case. If I want the user to save their own overrides configs in their workspace, the combination with the primary config is needed.
Here, the user may only want to override the num_classes of model
Of course, the workaround is to use command-line arguments directly, but I'm seeking for a more elegant way.
|
@npuichigo, please open a separate feature request. |
Another workaround option for anyone who needs it: I'm invoking a plugin that adds the user's current working directory to hydra's search path. Depending on how you integrate this into your application, it probably won't override defaults. At least in my use case, it's still preferable to requiring the users to provide the
|
🚀 Feature Request
I want to pass yaml file instead of parameters like
foo.bar=1 ...
to override default configuration:The text was updated successfully, but these errors were encountered: