Skip to content

Commit

Permalink
chore: bump to 1.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Sep 19, 2023
1 parent a2bae7d commit 210c3d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
56 changes: 26 additions & 30 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import yaml
from pydantic import BaseSettings, root_validator, validator

settings = None

class ExecutionMode(enum.Enum):
DEV = "dev"
REGISTRY = "registry"
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"Chia Network Inc <[email protected]>"]
Expand Down

0 comments on commit 210c3d1

Please sign in to comment.