From 1b94fc9d922734ec30961e071dfbc0085b762ebb Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 17 Aug 2023 10:26:17 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(endpoints.py):=20fix=20dupli?= =?UTF-8?q?cate=20loading=20of=20custom=20components=20from=20the=20same?= =?UTF-8?q?=20path=20=E2=9C=A8=20feat(endpoints.py):=20improve=20performan?= =?UTF-8?q?ce=20by=20skipping=20duplicate=20loading=20of=20custom=20compon?= =?UTF-8?q?ents=20from=20the=20same=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/endpoints.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index a6b85dde2..928d6609c 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -44,15 +44,21 @@ def get_all(): logger.info( f"Building custom components from {settings_manager.settings.COMPONENTS_PATH}" ) - custom_component_dicts = [ - build_langchain_custom_component_list_from_path(str(path)) - for path in settings_manager.settings.COMPONENTS_PATH - ] + + custom_component_dicts = [] + processed_paths = [] + for path in settings_manager.settings.COMPONENTS_PATH: + if str(path) in processed_paths: + continue + custom_component_dict = build_langchain_custom_component_list_from_path( + str(path) + ) + custom_component_dicts.append(custom_component_dict) + processed_paths.append(str(path)) + logger.info(f"Loading {len(custom_component_dicts)} category(ies)") for custom_component_dict in custom_component_dicts: # custom_component_dict is a dict of dicts - if not custom_component_dict: - continue category = list(custom_component_dict.keys())[0] logger.info( f"Loading {len(custom_component_dict[category])} component(s) from category {category}"