config.py 693 B

123456789101112131415161718192021222324252627
  1. # This file serves as a singleton for the configuration settings of the project
  2. import tomllib
  3. import os
  4. import pathlib as pl
  5. from typing import Any
  6. def get_config() -> dict[str, Any]:
  7. """
  8. Load the configuration file and return the settings as a dictionary.
  9. """
  10. match os.getenv("ANN_CONFIG_PATH"):
  11. case None:
  12. config_path = pl.Path(__file__).parent.parent / "config.toml"
  13. case str(path):
  14. config_path = pl.Path(path)
  15. if not config_path.exists():
  16. config_path = pl.Path(__file__).parent.parent / "config.toml"
  17. with open(config_path, "rb") as f:
  18. config = tomllib.load(f)
  19. return config
  20. config = get_config()