Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/badges/coverage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"schemaVersion":1,"label":"Coverage","message":"84.67%","color":"green"}
{"schemaVersion":1,"label":"Coverage","message":"84.65%","color":"green"}
11 changes: 6 additions & 5 deletions app/schemas/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,16 @@ def config_file_exists(cls, config_file):

@model_validator(mode="after")
def setup_config(cls, values) -> Any:
with open(file=values.config_file, mode="r") as f:
file_content = f.read()
f.close()
with open(file=values.config_file, mode="r") as file:
file_content = file.read()
file.close()

# replace environment variables (pattern: ${VARIABLE_NAME})
for match in set(re.findall(pattern=r"\${[A-Z_]+}", string=file_content)):
variable = match.replace("${", "").replace("}", "")
assert os.getenv(variable), f"Environment variable {variable} not found or empty to replace {match}."
file_content = file_content.replace(match, os.environ[variable])
if not os.getenv(variable):
logging.warning(f"Environment variable {variable} not found or empty to replace {match}.")
file_content = file_content.replace(match, os.getenv(variable, match))

config = Config(**yaml.safe_load(file_content))

Expand Down
1 change: 0 additions & 1 deletion compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ services:
postgres:
condition: service_healthy


postgres:
extends:
file: compose.yml
Expand Down
12 changes: 7 additions & 5 deletions ui/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from functools import lru_cache
import logging
import os
import re
from typing import Any, Optional
Expand Down Expand Up @@ -43,15 +44,16 @@ def config_file_exists(cls, config_file):

@model_validator(mode="after")
def setup_config(cls, values) -> Any:
with open(file=values.config_file, mode="r") as f:
file_content = f.read()
f.close()
with open(file=values.config_file, mode="r") as file:
file_content = file.read()
file.close()

# replace environment variables (pattern: ${VARIABLE_NAME})
for match in set(re.findall(pattern=r"\${[A-Z_]+}", string=file_content)):
variable = match.replace("${", "").replace("}", "")
assert os.getenv(variable), f"Environment variable {variable} not found or empty to replace {match}."
file_content = file_content.replace(match, os.environ[variable])
if not os.getenv(variable):
logging.warning(f"Environment variable {variable} not found or empty to replace {match}.")
file_content = file_content.replace(match, os.getenv(variable, match))

config = Config(**yaml.safe_load(file_content))

Expand Down