-
-
Notifications
You must be signed in to change notification settings - Fork 813
Closed
Labels
enhancementEnhanvement requestEnhanvement request
Milestone
Description
🚀 Feature Request
Now _target_ has to be the full name of the callable object, supporting _target_ to be a callable object itself in recursive construction would be very helpful.
Motivation
In some situation there are some advantages using the callable directly:
- the name is often too long, such as
library.module_name.submodule_name.class - user writing a new class/function in code, and want to swap this class/function with the existing one in config.
Pitch
In https://github.com/facebookresearch/hydra/blob/6ac5a6270530ff4acf76248a01e11c3cc4278847/examples/instantiate/object_recursive/my_app.py, be able to use the following instead:
class MyNewDriver()
...
@hydra.main(config_name="config")
def my_app(cfg: DictConfig) -> None:
cfg = OmegaConf.to_container(cfg)
cfg['car']['driver']['_target_'] = MyNewDriver
car: Car = instantiate(cfg['car'])
car.drive()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementEnhanvement requestEnhanvement request