How to get the path of the config that was given? #2750
-
In this small example, how to get the path of the config that was passed? from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(version_base=None, config_path=".", config_name="config")
def my_app(cfg):
print(OmegaConf.to_yaml(cfg))
# how to get the config_name and config_path here???
if __name__ == "__main__":
my_app() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Not sure if there's a better way but I think you can do (not fully tested): from hydra.core.hydra_config import HydraConfig
cfg = HydraConfig.get()
config_name = cfg.job.config_name
config_path = [path["path"] for path in cfg.runtime.config_sources if path["schema"] == "file"][0] |
Beta Was this translation helpful? Give feedback.
-
This would be a really good attribute to have access to. Sometimes we just want to make a direct copy of all the files in a config dir for future reference. If the code does not know this location, the files cannot be access.
when |
Beta Was this translation helpful? Give feedback.
Not sure if there's a better way but I think you can do (not fully tested):