-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Support YAML anchors in configs for CLI
#536
Comments
Than you for proposing! Note that yaml anchors are supported. What isn't possible is to add keys with arbitrary names, like instances:
- class_path: __main__.MyClass
init_args: &init_args
name: instance_1
a: 1
b: 2
c: 3
- class_path: __main__.MyClass
init_args:
<<: *init_args
name: instance_2 |
Oh, cool, thank you! Would it be possible to make |
Ignoring extra content in configs is dangerous because other mistakes wouldn't be noticed. The same reason why But you could handle this yourself by implementing a custom loader. That is: import yaml
from jsonargparse import set_loader
def custom_yaml_load(stream):
data = yaml.safe_load(stream)
if isinstance(data, dict):
data.pop("x-common-args")
return data
set_loader("yaml", custom_yaml_load) Some notes about this:
|
With #543 now it is possible to get the default yaml loader. |
🚀 Feature request
Support YAML anchors in configs for
CLI
.Motivation
Anchors reduce duplication of configuration values. For example (not necessarily like this):
Pitch
YAML anchors are supported by
CLI
.Alternatives
The text was updated successfully, but these errors were encountered: