From 31dba43e732257ae7a4cfc9ce2a35ad27b6f07d3 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 4 Aug 2023 08:34:25 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(settings.py):=20convert=20BA?= =?UTF-8?q?SE=5FCOMPONENTS=5FPATH=20to=20string=20to=20ensure=20compatibil?= =?UTF-8?q?ity=20with=20other=20parts=20of=20the=20codebase=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(settings.py):=20update=20COMPONENTS=5FPATH=20to=20accept?= =?UTF-8?q?=20a=20list=20of=20strings=20instead=20of=20a=20list=20of=20Pat?= =?UTF-8?q?hs=20to=20improve=20flexibility=20and=20compatibility=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(settings.py):=20update=20set=5Fcomponents=5F?= =?UTF-8?q?path=20method=20to=20handle=20LANGFLOW=5FCOMPONENTS=5FPATH=20as?= =?UTF-8?q?=20a=20list=20of=20paths=20or=20a=20single=20path=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/settings.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/settings.py b/src/backend/langflow/settings.py index 6b878dc42..18c4a01de 100644 --- a/src/backend/langflow/settings.py +++ b/src/backend/langflow/settings.py @@ -6,7 +6,7 @@ import yaml from pydantic import BaseSettings, root_validator, validator from langflow.utils.logger import logger -BASE_COMPONENTS_PATH = Path(__file__).parent / "components" +BASE_COMPONENTS_PATH = str(Path(__file__).parent / "components") class Settings(BaseSettings): @@ -31,7 +31,7 @@ class Settings(BaseSettings): DATABASE_URL: Optional[str] = None CACHE: str = "InMemoryCache" REMOVE_API_KEYS: bool = False - COMPONENTS_PATH: List[Path] = [] + COMPONENTS_PATH: List[str] = [] @validator("DATABASE_URL", pre=True) def set_database_url(cls, value): @@ -52,12 +52,15 @@ class Settings(BaseSettings): def set_components_path(cls, value): if os.getenv("LANGFLOW_COMPONENTS_PATH"): logger.debug("Adding LANGFLOW_COMPONENTS_PATH to components_path") - langflow_component_path = Path(os.getenv("LANGFLOW_COMPONENTS_PATH")) + langflow_component_path = os.getenv("LANGFLOW_COMPONENTS_PATH") if ( - langflow_component_path.exists() + Path(langflow_component_path).exists() and langflow_component_path not in value ): - value.append(langflow_component_path) + if isinstance(langflow_component_path, list): + value.extend(langflow_component_path) + else: + value.append(langflow_component_path) logger.debug(f"Adding {langflow_component_path} to components_path") if not value: