Skip to content
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

Providing first class support for user-specified dataclasses.field instances #187

Open
rsokl opened this issue Jan 6, 2022 · 0 comments
Labels
enhancement New feature or request hydra/omegaconf Tied to behavior of hydra/omegaconf

Comments

@rsokl
Copy link
Contributor

rsokl commented Jan 6, 2022

There is a sizeable demand for Hydra to support custom help messages through the CLI: facebookresearch/hydra#633

It appears that the leading candidate for supporting this, at least for structured configs, is via dataclasses.field(..., metadata=<...>): facebookresearch/hydra#633 (comment) and omry/omegaconf#131 (comment).

Presently, we provide limited (and primarily undocumented) support for users to directly pass field objects to builds and make_config and do not make any assurances that we preserve any of the associated metadata. It also appears that we do not perform any value-validation on fields.

Thus I plan for us to:

  • Provide explicit support for passing field instances directly to our config-creation functions
    • ensuring metadata is preserved
    • ensuring parity with all validation that we perform
    • adding test cases that explicitly exercise fields-as-config-values

An edge case that I anticipate is that we might not permit fields as positional arguments.

Additionally ZenField should expose a metadata field. Ultimately ZenField is the same as dataclasses.field, except it can specify name and type as well; so perhaps we should expose all of the field options here, other than default_factory, which we handle automatically.

Lastly, if OmegaConf/Hydra does end up going this metadata route for supporting help messages, then we could potentially add a new feature to builds, where we can parse different styles of docstrings and auto-populate docs fields in metadata. This way, users need not duplicate any docs - the help messages will be derived directly from the source documentation!

@rsokl rsokl added enhancement New feature or request hydra/omegaconf Tied to behavior of hydra/omegaconf labels Jan 6, 2022
@rsokl rsokl added this to the hydra-zen 0.5.0 milestone Jan 13, 2022
@rsokl rsokl self-assigned this Jan 13, 2022
@rsokl rsokl removed this from the hydra-zen 0.5.0 milestone Jan 13, 2022
@rsokl rsokl removed their assignment Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hydra/omegaconf Tied to behavior of hydra/omegaconf
Projects
None yet
Development

No branches or pull requests

1 participant