Refactor component filtering in DirectoryReader class
This commit is contained in:
parent
4ee7a9c62d
commit
5677dd9ad3
1 changed files with 12 additions and 12 deletions
|
|
@ -66,18 +66,18 @@ class DirectoryReader:
|
||||||
def filter_loaded_components(self, data: dict, with_errors: bool) -> dict:
|
def filter_loaded_components(self, data: dict, with_errors: bool) -> dict:
|
||||||
from langflow.interface.custom.utils import build_component
|
from langflow.interface.custom.utils import build_component
|
||||||
|
|
||||||
items = [
|
items = []
|
||||||
{
|
for menu in data["menu"]:
|
||||||
"name": menu["name"],
|
components = []
|
||||||
"path": menu["path"],
|
for component in menu["components"]:
|
||||||
"components": [
|
try:
|
||||||
(*build_component(component), component)
|
if component["error"] if with_errors else not component["error"]:
|
||||||
for component in menu["components"]
|
component_tuple = (*build_component(component), component)
|
||||||
if (component["error"] if with_errors else not component["error"])
|
components.append(component_tuple)
|
||||||
],
|
except Exception as e:
|
||||||
}
|
logger.error(f"Error while loading component: {e}")
|
||||||
for menu in data["menu"]
|
continue
|
||||||
]
|
items.append({"name": menu["name"], "path": menu["path"], "components": components})
|
||||||
filtered = [menu for menu in items if menu["components"]]
|
filtered = [menu for menu in items if menu["components"]]
|
||||||
logger.debug(f'Filtered components {"with errors" if with_errors else ""}: {len(filtered)}')
|
logger.debug(f'Filtered components {"with errors" if with_errors else ""}: {len(filtered)}')
|
||||||
return {"menu": filtered}
|
return {"menu": filtered}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue