diff --git a/oocana/oocana/context.py b/oocana/oocana/context.py index 40f4cac..2820b10 100644 --- a/oocana/oocana/context.py +++ b/oocana/oocana/context.py @@ -185,6 +185,7 @@ class Context: __package_name: str | None = None _logger: Optional[logging.Logger] = None __pkg_data_dir: str + __oomol_llm_env_warned: bool = False # TODO: remove the pkg_dir parameter, use pkg_data_dir instead. def __init__( @@ -310,11 +311,14 @@ def oomol_llm_env(self) -> OOMOL_LLM_ENV: "models": os.getenv("OOMOL_LLM_MODELS", "").split(","), } - for key, value in oomol_llm_env.items(): - if value == "" or value == []: - self.send_warning( - f"OOMOL_LLM_ENV variable {key} is ({value}), this may cause some features not working properly." - ) + # Only warn once on first access to avoid repeated side effects + if not self.__oomol_llm_env_warned: + self.__oomol_llm_env_warned = True + for key, value in oomol_llm_env.items(): + if value == "" or value == []: + self.send_warning( + f"OOMOL_LLM_ENV variable {key} is ({value}), this may cause some features not working properly." + ) return oomol_llm_env