#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 import json import os import yaml _config_cache = None def get(): global _config_cache if _config_cache is None: dir_name = os.path.dirname(os.path.abspath(__file__)) env = os.environ.get('RAG_ENV', 'dev') if env not in ('dev', 'pre', 'prod'): raise ValueError(f"Invalid environment: {env}. Expected one of ('dev', 'pre', 'prod').") with open(f'{dir_name}/{env}.yaml', 'r') as f: _config_cache = yaml.safe_load(f.read()) return _config_cache def get_env(): env = os.environ.get('RAG_ENV', 'dev') return env