import logging import sys from pathlib import Path import pydantic import yaml from . import models logger = logging.getLogger(__name__) config: models.Config | None = None def load(path: Path) -> None: global config try: config_yaml = yaml.safe_load(open(path)) except FileNotFoundError: logger.error( "No config.yaml file found. Make sure to copy the " "config.example.yaml file to config.yaml" ) sys.exit(1) try: config = models.Config(**config_yaml) except pydantic.ValidationError as e: logger.error(f"Invalid config.yaml file: {e}") sys.exit(1)