From 6da04747b5c482feaa2e398836ee4bc249a295aa Mon Sep 17 00:00:00 2001 From: "Robert B. Young" Date: Tue, 3 Mar 2026 15:35:11 +1030 Subject: [PATCH] Fix COREMS_DATABASE_URL env var not overriding hardcoded default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MolecularFormulaSearchSettings dataclass has a hardcoded url_database default pointing to localhost:5432. The __post_init__ method checks COREMS_DATABASE_URL only when url_database is empty, but the hardcoded default means it's never empty — so the env var from .env (which points to the 'molformdb' compose service) is silently ignored. Move the os.getenv() call to the field default so COREMS_DATABASE_URL is respected at initialization time. The localhost fallback is preserved for non-compose setups. Co-Authored-By: Claude Opus 4.6 --- corems/encapsulation/factory/processingSetting.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/corems/encapsulation/factory/processingSetting.py b/corems/encapsulation/factory/processingSetting.py index 48d5937e..7c8ec64b 100644 --- a/corems/encapsulation/factory/processingSetting.py +++ b/corems/encapsulation/factory/processingSetting.py @@ -977,8 +977,9 @@ class MolecularFormulaSearchSettings: min_peaks_per_class: int = 15 - url_database: str = ( - "postgresql+psycopg2://coremsappdb:coremsapppnnl@localhost:5432/coremsapp" + url_database: str = os.getenv( + "COREMS_DATABASE_URL", + "postgresql+psycopg2://coremsappdb:coremsapppnnl@localhost:5432/coremsapp", ) db_jobs: int = 3