-
Notifications
You must be signed in to change notification settings - Fork 107
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
Allow "default" in interpolation when target config node does not exist #541
Comments
Hi @ppwwyyxx. This is something I can consider if there is more interest in this feature by additional users. In the mean time, Can you motivate this more? I have never felt the need for something like this so far. |
To give an example, consider a config organization that looks like this: output_dir: "./output"
train_job:
# other settings
tensorboard_output_dir: "${output_dir}"
eval_jobs:
- evaluator: Evaluator1
#other settings
predictions_output_dir: "${output_dir}"
- evaluator: Evaluator2
predictions_output_dir: "${output_dir}" where a task is composed of multiple jobs that should share To be able to reuse this config independently, without the presence of the top-level |
This is solved by Hydra using config composition. config.yaml: defaults:
- base
- trainer base.yaml: output_dir: "./output" trainer.yaml: train_job:
# other settings
tensorboard_output_dir: "${output_dir}"
eval_jobs:
- evaluator: Evaluator1
#other settings
predictions_output_dir: "${output_dir}"
- evaluator: Evaluator2
predictions_output_dir: "${output_dir}" You can also merge base.yaml into config.yaml in this case: config.yaml: defaults:
- trainer
output_dir: "./output" This way, you can override the output_dir in a single place that will effect all the different nodes that are interpolating to it. |
Currently, when the key in interpolation doesn't exist, e.g. in:
it throws exception about "str interpolation key 'a' not found".
I hope there is a way to specify default values.
Describe the solution you'd like
the
env:
resolver already supports defaults: https://omegaconf.readthedocs.io/en/latest/usage.html#environment-variable-interpolationand the syntax seems nice.
The above can be written as:
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: