pytorch / hydra-torch

Configuration classes enabling type-safe PyTorch configuration for Hydra apps
MIT License
199 stars 16 forks source link

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

Open romesco opened 3 years ago

romesco commented 3 years ago

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.

omry commented 3 years ago

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.
romesco commented 3 years ago

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

What was your alternative proposition?

omry commented 3 years ago

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()
romesco commented 3 years ago

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.

omry commented 3 years ago

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