From b1cafb93ac8a7949c25aedf2fb5a164b08240c2b Mon Sep 17 00:00:00 2001 From: tazlin Date: Wed, 4 Oct 2023 10:09:48 -0400 Subject: [PATCH] fix: don't overwrite env vars from config if set --- horde_worker_regen/bridge_data/data_model.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/horde_worker_regen/bridge_data/data_model.py b/horde_worker_regen/bridge_data/data_model.py index 463de8c3..b8ef8597 100644 --- a/horde_worker_regen/bridge_data/data_model.py +++ b/horde_worker_regen/bridge_data/data_model.py @@ -21,7 +21,7 @@ class reGenBridgeData(CombinedHordeBridgeData): def load_env_vars(self) -> None: """Load the environment variables into the config model.""" - if self.models_folder_parent: + if self.models_folder_parent and os.getenv("AIWORKER_CACHE_HOME") is None: os.environ["AIWORKER_CACHE_HOME"] = self.models_folder_parent if self.horde_url: if os.environ.get("AI_HORDE_URL"): @@ -35,10 +35,15 @@ def load_env_vars(self) -> None: "AI_HORDE_DEV_URL environment variable already set. This will override the value for " "`horde_url` in the config file.", ) - else: + if os.environ.get("AI_HORDE_URL") is None: os.environ["AI_HORDE_URL"] = self.horde_url + else: + logger.warning( + "AI_HORDE_URL environment variable already set. This will override the value for `horde_url` " + "in the config file.", + ) - if self.max_lora_cache_size: + if self.max_lora_cache_size and os.getenv("AIWORKER_LORA_CACHE_SIZE") is None: os.environ["AIWORKER_LORA_CACHE_SIZE"] = str(self.max_lora_cache_size * 1024) def save(self, file_path: str) -> None: