-
Notifications
You must be signed in to change notification settings - Fork 116
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 idea: metadata option to omit field #984
Comments
Hi @bottler, |
I generally call the constructor directly. |
The reason we avoid to_object is because of considerations about what should happen when a notebook user redefines a class. |
Adding a check for One detail to iron out: how would cfg = OmegaConf.structured(A)
assert cfg == {'a': 3, 'b': 3} # information regarding 'c' is discarded
OmegaConf.to_object(cfg) # What happens here? What value for 'c' is passed to `A.__init__`? My instinct is that, in my example above, Details for potential implementationIf you make a PR, here is some information that will be useful:
|
Closed by PR #988. |
I make extensive use of structured config with dataclasses, where the classes have a lot of their own logic. Their fields are generally their configuration, but I'd like to have some fields which are linked to program logic but not to configuration, and some of these I want to allow passing to
__init__
.Proposed solution
My current idea is to change OmegaConf.structured so that it looks for some indication in a field's metadata that it should ignore that field. For example, we could decide to check for a value "omegaconf_ignore". Then the following would print
{"a": 3, "b": 3}
.(If an ignored field was undefaulted, then you would not be able to call
to_object()
on the config.)Would this be a good idea? Could I make a PR?
The text was updated successfully, but these errors were encountered: