🐛 Bug
Description
I would like Hydra to instantiate a nested target which comes from interpolation with schema validation (following the example from #1420). Example:
config_test.yaml
defaults:
- config_test_schema
- _self_
child:
_target_: config_test.Child
parent:
_target_: config_test.Parent
child: ${child}
config_test.py
import hydra
from hydra.utils import instantiate
from dataclasses import dataclass
from hydra.core.config_store import ConfigStore
@dataclass
class ConfigChild:
_target_: str = "Child"
@dataclass
class ConfigParent:
_target_: str = "Parent"
child: ConfigChild = ConfigChild()
@dataclass
class TestConfig:
child: ConfigChild = ConfigChild()
parent: ConfigParent = ConfigParent()
cs = ConfigStore.instance()
cs.store(name="config_test_schema", node=TestConfig)
class Child:
pass
class Parent:
def __init__(self, child):
self.child = child
@hydra.main(config_path=".", version_base=None, config_name="config_test")
def run(cfg):
parent = instantiate(cfg.parent)
print(parent.child)
if __name__ == "__main__":
run()
This runs successfully if I remove the line - config_test_schema from the defaults in config_test.yaml. However, once the line is there running fails with
In 'config_test': ValidationError raised while composing config:
Merge error: str is not a subclass of ConfigChild. value: ${child}
full_key:
object_type=TestConfig
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Checklist
Expected Behavior
Instantiation of parent and child successful.
System information
- Hydra Version : 1.3.1
- Python version : 3.8.1
- Virtual environment type and version : venv 2.3.12
- Operating system : Linux
🐛 Bug
Description
I would like Hydra to instantiate a nested target which comes from interpolation with schema validation (following the example from #1420). Example:
config_test.yaml
config_test.py
This runs successfully if I remove the line
- config_test_schemafrom thedefaultsinconfig_test.yaml. However, once the line is there running fails withChecklist
Expected Behavior
Instantiation of parent and child successful.
System information