From 210c3d14b7cf4a88fd395715cbfc8b8fec62ef0c Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 19 Sep 2023 10:46:50 -0400 Subject: [PATCH] chore: bump to 1.0.24 --- app/config.py | 56 +++++++++++++++++++++++--------------------------- pyproject.toml | 2 +- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/app/config.py b/app/config.py index ecbc701..b4ecedc 100644 --- a/app/config.py +++ b/app/config.py @@ -7,8 +7,6 @@ import yaml from pydantic import BaseSettings, root_validator, validator -settings = None - class ExecutionMode(enum.Enum): DEV = "dev" REGISTRY = "registry" @@ -25,7 +23,6 @@ class ServerPort(enum.Enum): class Settings(BaseSettings): - _instance = None _HIDDEN_FIELDS = ["MODE", "CHIA_ROOT", "CONFIG_PATH", "SERVER_PORT"] # Hidden configs: not exposed in config.yaml @@ -92,33 +89,32 @@ def prepend_root(cls, v, values): def get_settings() -> Settings: - if Settings._instance is None: - in_pyinstaller: bool = getattr(sys, "frozen", False) - - default_env_file: Path - default_config_file: Path - if in_pyinstaller: - default_env_file = Path(sys._MEIPASS) / ".env" - default_config_file = Path(sys._MEIPASS) / "config.yaml" - else: - default_env_file = Path(".env") - default_config_file = Path("config.yaml") - - default_settings = Settings(_env_file=default_env_file) - config_file: Path = default_settings.CONFIG_PATH - - settings: Settings - settings_dict: Dict - if not config_file.is_file(): - config_file.parent.mkdir(parents=True, exist_ok=True) - shutil.copy(default_config_file, config_file) - - with open(config_file, "r") as f: - settings_dict = yaml.safe_load(f) - - settings_dict = default_settings.dict() | (settings_dict or {}) - settings = Settings(**settings_dict) - Settings._instance = Settings(**settings_dict) + in_pyinstaller: bool = getattr(sys, "frozen", False) + + default_env_file: Path + default_config_file: Path + if in_pyinstaller: + default_env_file = Path(sys._MEIPASS) / ".env" + default_config_file = Path(sys._MEIPASS) / "config.yaml" + else: + default_env_file = Path(".env") + default_config_file = Path("config.yaml") + + default_settings = Settings(_env_file=default_env_file) + config_file: Path = default_settings.CONFIG_PATH + + settings: Settings + settings_dict: Dict + if not config_file.is_file(): + config_file.parent.mkdir(parents=True, exist_ok=True) + shutil.copy(default_config_file, config_file) + + with open(config_file, "r") as f: + settings_dict = yaml.safe_load(f) + + settings_dict = default_settings.dict() | (settings_dict or {}) + settings = Settings(**settings_dict) + Settings._instance = Settings(**settings_dict) return Settings._instance diff --git a/pyproject.toml b/pyproject.toml index ade567a..4d96ce7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "Chia Climate Token Driver" -version = "1.0.23" +version = "1.0.24" description = "https://github.com/Chia-Network/climate-token-driver" authors = ["Harry Hsu ", "Chia Network Inc "]