Reputation: 3
I have a folder structure looking like this:
In the main.py, I can set the config_path of the hydra decorator to "../hydra_configs". In the config.yaml I have
datasets: dataset_config
In the dataset_config.yaml I have
_target_: src.KIBA_gluonts_dataset.py
In the main file I want to instatiate my Dataset with
dataset = hydra.utils.instatiate(cfg.datasets)
but when I run it I get the error
Error locating target 'src.KIBA_gluonts_dataset.py'. ModuleNotFoundError: No module named 'src'
How can I instantiate an object from a different folder than the one the main file is located in?
I tried to use a relative path for _target_
, but that is not allowed. I also searched for a HydraConf parameter similar to run dir or sweep dir, but to no avail.
Upvotes: 0
Views: 3743
Reputation: 33696
Hydra is using Python import logic to find the referenced modules. If you can import your module, you should be able to use the same import string in the config file to reference it.
Upvotes: 0