🐛 fix(custom_component.py): remove unused import of UUID from langflow.interface.custom.custom_component.py
🐛 fix(custom_component.py): handle case when code is None in is_check_valid method of CustomComponent class 🐛 fix(custom_component.py): handle case when code is None in get_function_entrypoint_args property of CustomComponent class 🐛 fix(custom_component.py): handle case when code is None in get_function_entrypoint_return_type property of CustomComponent class 🐛 fix(custom_component.py): change flow_id parameter type from UUID to str in load_flow method of CustomComponent class 🐛 fix(util.py): ignore type error for multiprocess import in langflow.utils.util module 🐛 fix(util.py): handle case when _type is a type object in remove_optional_wrapper function of langflow.utils.util module
This commit is contained in:
parent
c4a2c1c80a
commit
67b2aeae67
2 changed files with 10 additions and 5 deletions
|
|
@ -5,7 +5,6 @@ from langflow.interface.custom.component import Component
|
||||||
|
|
||||||
from langflow.utils import validate
|
from langflow.utils import validate
|
||||||
|
|
||||||
from uuid import UUID
|
|
||||||
from langflow.database.base import session_getter
|
from langflow.database.base import session_getter
|
||||||
from langflow.database.models.flow import Flow
|
from langflow.database.models.flow import Flow
|
||||||
from pydantic import Extra
|
from pydantic import Extra
|
||||||
|
|
@ -44,13 +43,15 @@ class CustomComponent(Component, extra=Extra.allow):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def is_check_valid(self) -> bool:
|
def is_check_valid(self) -> bool:
|
||||||
return self._class_template_validation(self.code)
|
return self._class_template_validation(self.code) if self.code else False
|
||||||
|
|
||||||
def get_code_tree(self, code: str):
|
def get_code_tree(self, code: str):
|
||||||
return super().get_code_tree(code)
|
return super().get_code_tree(code)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_function_entrypoint_args(self) -> str:
|
def get_function_entrypoint_args(self) -> str:
|
||||||
|
if not self.code:
|
||||||
|
return ""
|
||||||
tree = self.get_code_tree(self.code)
|
tree = self.get_code_tree(self.code)
|
||||||
|
|
||||||
component_classes = [
|
component_classes = [
|
||||||
|
|
@ -78,6 +79,8 @@ class CustomComponent(Component, extra=Extra.allow):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_function_entrypoint_return_type(self) -> str:
|
def get_function_entrypoint_return_type(self) -> str:
|
||||||
|
if not self.code:
|
||||||
|
return ""
|
||||||
tree = self.get_code_tree(self.code)
|
tree = self.get_code_tree(self.code)
|
||||||
|
|
||||||
component_classes = [
|
component_classes = [
|
||||||
|
|
@ -138,7 +141,7 @@ class CustomComponent(Component, extra=Extra.allow):
|
||||||
def get_function(self):
|
def get_function(self):
|
||||||
return validate.create_function(self.code, self.function_entrypoint_name)
|
return validate.create_function(self.code, self.function_entrypoint_name)
|
||||||
|
|
||||||
def load_flow(self, flow_id: UUID = None):
|
def load_flow(self, flow_id: str):
|
||||||
from langflow.processing.process import build_sorted_vertices_with_caching
|
from langflow.processing.process import build_sorted_vertices_with_caching
|
||||||
|
|
||||||
with session_getter() as session:
|
with session_getter() as session:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from docstring_parser import parse # type: ignore
|
||||||
from langflow.template.frontend_node.constants import FORCE_SHOW_FIELDS
|
from langflow.template.frontend_node.constants import FORCE_SHOW_FIELDS
|
||||||
from langflow.utils import constants
|
from langflow.utils import constants
|
||||||
from langflow.utils.logger import logger
|
from langflow.utils.logger import logger
|
||||||
from multiprocess import cpu_count
|
from multiprocess import cpu_count # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def build_template_from_function(
|
def build_template_from_function(
|
||||||
|
|
@ -301,13 +301,15 @@ def get_type(value: Any) -> Union[str, type]:
|
||||||
return _type if isinstance(_type, str) else _type.__name__
|
return _type if isinstance(_type, str) else _type.__name__
|
||||||
|
|
||||||
|
|
||||||
def remove_optional_wrapper(_type: str) -> str:
|
def remove_optional_wrapper(_type: Union[str, type]) -> str:
|
||||||
"""
|
"""
|
||||||
Removes the 'Optional' wrapper from the type string.
|
Removes the 'Optional' wrapper from the type string.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The type string with the 'Optional' wrapper removed.
|
The type string with the 'Optional' wrapper removed.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(_type, type):
|
||||||
|
_type = str(_type)
|
||||||
if "Optional" in _type:
|
if "Optional" in _type:
|
||||||
_type = _type.replace("Optional[", "")[:-1]
|
_type = _type.replace("Optional[", "")[:-1]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue