From ac0aa71c1003d9422e88fedc428d425f3d57f2ab Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jul 2023 10:39:10 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(=5F=5Fmain=5F=5F.py):=20add?= =?UTF-8?q?=20support=20for=20component=5Fpath=20parameter=20to=20update?= =?UTF-8?q?=5Fsettings=20function=20=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py):?= =?UTF-8?q?=20add=20component=5Fpath=20option=20to=20serve=20command=20to?= =?UTF-8?q?=20specify=20the=20directory=20containing=20custom=20components?= =?UTF-8?q?=20=F0=9F=90=9B=20fix(settings.py):=20modify=20update=5Fsetting?= =?UTF-8?q?s=20function=20to=20handle=20list=20attributes=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 11 ++++++++++- src/backend/langflow/settings.py | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 63c5fe87f..729d9207f 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -27,6 +27,7 @@ def update_settings( dev: bool = False, database_url: Optional[str] = None, remove_api_keys: bool = False, + component_path: Optional[Path] = None, ): """Update the settings from a config file.""" @@ -41,6 +42,8 @@ def update_settings( settings.update_settings(remove_api_keys=remove_api_keys) if cache: settings.update_settings(cache=cache) + if component_path: + settings.update_settings(component_path=component_path) def load_params(): @@ -117,8 +120,13 @@ def serve( workers: int = typer.Option( -1, help="Number of worker processes.", envvar="LANGFLOW_WORKERS" ), - timeout: int = typer.Option(60, help="Worker timeout in seconds."), + timeout: int = typer.Option(300, help="Worker timeout in seconds."), port: int = typer.Option(7860, help="Port to listen on.", envvar="LANGFLOW_PORT"), + component_path: Optional[Path] = typer.Option( + Path(__file__).parent, + help="Path to the directory containing custom components.", + envvar="LANGFLOW_COMPONENT_PATH", + ), config: str = typer.Option("config.yaml", help="Path to the configuration file."), # .env file param env_file: Path = typer.Option( @@ -176,6 +184,7 @@ def serve( database_url=database_url, remove_api_keys=remove_api_keys, cache=cache, + component_path=component_path, ) # create path object if path is provided static_files_dir: Optional[Path] = Path(path) if path else None diff --git a/src/backend/langflow/settings.py b/src/backend/langflow/settings.py index 06f925a3c..037f88149 100644 --- a/src/backend/langflow/settings.py +++ b/src/backend/langflow/settings.py @@ -85,7 +85,13 @@ class Settings(BaseSettings): def update_settings(self, **kwargs): for key, value in kwargs.items(): if hasattr(self, key): - setattr(self, key, value) + if isinstance(getattr(self, key), list): + if isinstance(value, list): + getattr(self, key).extend(value) + else: + getattr(self, key).append(value) + else: + setattr(self, key, value) def save_settings_to_yaml(settings: Settings, file_path: str):