diff --git a/pyrelacs/config/config_loader.py b/pyrelacs/config/config_loader.py index b1a226d..ae76d90 100644 --- a/pyrelacs/config/config_loader.py +++ b/pyrelacs/config/config_loader.py @@ -102,17 +102,22 @@ class Config: metadata: Metadata pyrelacs: PyRelacs - @classmethod - def load_config(cls): - pyrelacs_config_path = pathlib.Path(__file__).parent / "config.yaml" - log.debug(pyrelacs_config_path) - if not pyrelacs_config_path.is_file(): - log.error("Config File was not found") - with open(pyrelacs_config_path, "r") as config_file: + +def load_config(): + pyrelacs_config_path = pathlib.Path(__file__).parent.parent / "config.yaml" + log.debug(pyrelacs_config_path) + if not pyrelacs_config_path.is_file(): + log.error("Config File was not found") + with open(pyrelacs_config_path, "r") as config_file: + try: + data = yaml.full_load(config_file) try: - return yaml.full_load(config_file) - except yaml.YAMLError as e: - raise yaml.YAMLError(f"Error parsing YAML file: {e}") + config = from_dict(data_class=Config, data=data) + return config + except dacite.DaciteError as e: + log.error(f"Invalid Config, {e}") + except yaml.YAMLError as e: + raise yaml.YAMLError(f"Error parsing YAML file: {e}") if __name__ == "__main__":