facebookresearch / hydra

Hydra is a framework for elegantly configuring complex applications
https://hydra.cc
MIT License
8.8k stars 632 forks source link

[Feature Request] Add an additional node to the defaults tree #2782

Open stwerner97 opened 1 year ago

stwerner97 commented 1 year ago

🚀 Feature Request

I would like to add a node to the defaults tree without having configurations include them explicitly, similar to how hydra's defaults are always available in the config tree. As far as I am aware, Hydra's defaults are discovered using a combination of a search path plugin, the configstore API & adding the defaults to the tree's root node upon its creation. The last step is, I believe, not doable without modifying Hydra itself. Is there some other way to make a defaults node available in this manner?

Are you willing to open a pull request? (See CONTRIBUTING) Yes, if I get some pointers.

odelalleau commented 1 year ago

The first (and only) solution I can think of would be using structured configs. There might be a way to make it work in a transparent manner by inheriting from a common base config class (not sure exactly how, maybe with some fancy metaclass stuff) -- otherwise could be explicit with something like:

defaults: List[Any] = make_defaults_field(defaults)

where make_defaults_field() is a custom function that in particular injects your extra node into defaults, and that all your structured configs should use.

stwerner97 commented 1 year ago

Hi @odelalleau, thanks for the response! 😊 I think I'll attempt a solution using inheritance based on your suggestion.