hydra-torch icon indicating copy to clipboard operation
hydra-torch copied to clipboard

[dev] Auto register Configs upon import of hydra_configs.module.name

Open romesco opened this issue 5 years ago • 5 comments

Write functions of the form: hydra_configs.torch.register(), hydra_configs.torch.optim.register(), etc.

Within these functions, call config store API:

cs = ConfigStore.instance()
cs.store(name="adamconf", node=AdamConf)

Call these in __init__.py for the module.

romesco avatar Dec 26 '20 01:12 romesco

I don't think we need to call them automatically.

  1. we should let users control what they register.
  2. registering is not free, the configs needs to be created. as the number of installed configs grow it can become expensive to blindly register all of them.

omry avatar Dec 26 '20 08:12 omry

Don't the users have control by determining which 'module' they import?

What was your alternative proposition?

romesco avatar Dec 26 '20 18:12 romesco

Users may import the packages to use the config objects directly as well.

import hydra_configs.pytrorch

#register everything under pytorch
hydra_configs.pytrorch.register()

#register everything under pytorch.optim
hydra_configs.pytrorch.optim.register()

omry avatar Dec 26 '20 22:12 omry

Ok, I think this is probably a better option. The automatic strategy would likely leave users confused about what is and what isnt currently registered. Better to be explicit and convenient.

romesco avatar Dec 27 '20 02:12 romesco

we can make register at the top level mean recursive to make things convenient.

omry avatar Dec 27 '20 02:12 omry