From 52323eae4a6805d47e39fd1fd4f83936fb90816f Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Fri, 7 Jun 2024 14:40:24 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20(component.py):=20update=20varia?= =?UTF-8?q?ble=20name=20from=20display=5Fname=20to=20name=20for=20consiste?= =?UTF-8?q?ncy=20and=20clarity=20=F0=9F=93=9D=20(component.py):=20improve?= =?UTF-8?q?=20variable=20naming=20for=20better=20readability=20and=20maint?= =?UTF-8?q?ainability=20=F0=9F=93=9D=20(=5F=5Finit=5F=5F.py):=20refactor?= =?UTF-8?q?=20function=20name=20=5Fimport=5Ftemplate=5Ffield=20to=20=5Fimp?= =?UTF-8?q?ort=5Finput=5Fclass=20for=20better=20naming=20clarity=20?= =?UTF-8?q?=F0=9F=93=9D=20(=5F=5Finit=5F=5F.py):=20refactor=20function=20n?= =?UTF-8?q?ame=20=5Fimport=5Ftemplate=5Ffield=20to=20=5Fimport=5Finput=5Fc?= =?UTF-8?q?lass=20for=20better=20naming=20clarity=20=F0=9F=93=9D=20(=5F=5F?= =?UTF-8?q?init=5F=5F.py):=20add=20function=20=5Fimport=5Foutput=5Fclass?= =?UTF-8?q?=20to=20import=20Output=20class=20from=20langflow.template.fiel?= =?UTF-8?q?d.base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/custom/custom_component/component.py | 4 ++-- src/backend/base/langflow/field_typing/__init__.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/backend/base/langflow/custom/custom_component/component.py b/src/backend/base/langflow/custom/custom_component/component.py index 767f5fc7b..aaa16771d 100644 --- a/src/backend/base/langflow/custom/custom_component/component.py +++ b/src/backend/base/langflow/custom/custom_component/component.py @@ -71,13 +71,13 @@ class Component(CustomComponent): for output in self.outputs: # Build the output if it's connected to some other vertex # or if it's not connected to any vertex - if not vertex.outgoing_edges or output.display_name in vertex.edges_source_names: + if not vertex.outgoing_edges or output.name in vertex.edges_source_names: method: Callable | Awaitable = getattr(self, output.method) result = method() # If the method is asynchronous, we need to await it if inspect.iscoroutinefunction(method): result = await result - _results[output.display_name] = result + _results[output.name] = result self._results = _results return _results diff --git a/src/backend/base/langflow/field_typing/__init__.py b/src/backend/base/langflow/field_typing/__init__.py index 7ae9c61a9..9383008dc 100644 --- a/src/backend/base/langflow/field_typing/__init__.py +++ b/src/backend/base/langflow/field_typing/__init__.py @@ -29,18 +29,26 @@ from .constants import ( from .range_spec import RangeSpec -def _import_template_field(): +def _import_input_class(): from langflow.template.field.base import Input return Input +def _import_output_class(): + from langflow.template.field.base import Output + + return Output + + def __getattr__(name: str) -> Any: # This is to avoid circular imports if name == "Input": - return _import_template_field() + return _import_input_class() elif name == "RangeSpec": return RangeSpec + elif name == "Output": + return _import_output_class() # The other names should work as if they were imported from constants # Import the constants module langflow.field_typing.constants from . import constants