fix(components): exclude base path from component loading and refine caching (#8735)
* feat: filter out base components path in custom component loading * revert changes to allow testing the function --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
parent
813528682c
commit
ceb98af542
1 changed files with 12 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Any
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from langflow.custom.utils import abuild_custom_components, create_component_template
|
from langflow.custom.utils import abuild_custom_components, create_component_template
|
||||||
|
from langflow.services.settings.base import BASE_COMPONENTS_PATH
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from langflow.services.settings.service import SettingsService
|
from langflow.services.settings.service import SettingsService
|
||||||
|
|
@ -162,22 +163,29 @@ async def get_and_cache_all_types_dict(
|
||||||
logger.debug("Building components cache")
|
logger.debug("Building components cache")
|
||||||
|
|
||||||
langflow_components = await import_langflow_components()
|
langflow_components = await import_langflow_components()
|
||||||
|
component_cache.all_types_dict = {}
|
||||||
if settings_service.settings.lazy_load_components:
|
if settings_service.settings.lazy_load_components:
|
||||||
# Partial loading mode - just load component metadata
|
# Partial loading mode - just load component metadata
|
||||||
logger.debug("Using partial component loading")
|
logger.debug("Using partial component loading")
|
||||||
component_cache.all_types_dict = await aget_component_metadata(settings_service.settings.components_path)
|
component_cache.all_types_dict = await aget_component_metadata(settings_service.settings.components_path)
|
||||||
else:
|
elif (
|
||||||
|
settings_service.settings.components_path
|
||||||
|
and BASE_COMPONENTS_PATH not in settings_service.settings.components_path
|
||||||
|
):
|
||||||
# Traditional full loading
|
# Traditional full loading
|
||||||
component_cache.all_types_dict = await aget_all_types_dict(settings_service.settings.components_path)
|
component_cache.all_types_dict = await aget_all_types_dict(settings_service.settings.components_path)
|
||||||
|
|
||||||
# Log custom component loading stats
|
# Log custom component loading stats
|
||||||
component_count = sum(len(comps) for comps in component_cache.all_types_dict.get("components", {}).values())
|
components_dict = component_cache.all_types_dict or {}
|
||||||
|
component_count = sum(len(comps) for comps in components_dict.get("components", {}).values())
|
||||||
if component_count > 0 and settings_service.settings.components_path:
|
if component_count > 0 and settings_service.settings.components_path:
|
||||||
logger.debug(f"Built {component_count} custom components from {settings_service.settings.components_path}")
|
logger.debug(f"Built {component_count} custom components from {settings_service.settings.components_path}")
|
||||||
|
|
||||||
# merge the dicts
|
# merge the dicts
|
||||||
component_cache.all_types_dict = {**langflow_components["components"], **component_cache.all_types_dict}
|
component_cache.all_types_dict = {
|
||||||
|
**langflow_components["components"],
|
||||||
|
**components_dict,
|
||||||
|
}
|
||||||
component_count = sum(len(comps) for comps in component_cache.all_types_dict.values())
|
component_count = sum(len(comps) for comps in component_cache.all_types_dict.values())
|
||||||
logger.debug(f"Loaded {component_count} components")
|
logger.debug(f"Loaded {component_count} components")
|
||||||
return component_cache.all_types_dict
|
return component_cache.all_types_dict
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue