Skip to content

Commit

Permalink
don't throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Jan 19, 2025
1 parent d6a0d64 commit e95543b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions kscale/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# This is the public API endpoint for the K-Scale WWW API.
DEFAULT_API_ROOT = "https://api.kscale.dev"

SETTINGS_FILE_NAME = "settings.yaml"


def get_path() -> Path:
if "KSCALE_CONFIG_DIR" in os.environ:
Expand Down Expand Up @@ -41,9 +43,12 @@ def load() -> "Settings":
if not (dir_path := get_path()).exists():
warnings.warn(f"Settings directory does not exist: {dir_path}. Creating it now.")
dir_path.mkdir(parents=True)
OmegaConf.save(config, dir_path / "settings.yaml")
OmegaConf.save(config, dir_path / SETTINGS_FILE_NAME)
else:
with open(dir_path / "settings.yaml", "r") as f:
raw_settings = OmegaConf.load(f)
config = OmegaConf.merge(config, raw_settings)
try:
with open(dir_path / SETTINGS_FILE_NAME, "r") as f:
raw_settings = OmegaConf.load(f)
config = OmegaConf.merge(config, raw_settings)
except Exception as e:
warnings.warn(f"Failed to load settings: {e}")
return config

0 comments on commit e95543b

Please sign in to comment.