From b188400517c6124f439fe649d432dc8109b2bff4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 29 Jun 2023 19:36:04 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20improve=20err?= =?UTF-8?q?or=20message=20formatting=20when=20failing=20to=20build=20conne?= =?UTF-8?q?ction=20to=20database=20=F0=9F=90=9B=20fix(base.py):=20add=20op?= =?UTF-8?q?tional=20'name'=20parameter=20to=20the=20format=20method=20in?= =?UTF-8?q?=20FieldFormatter=20In=20loading.py,=20the=20error=20message=20?= =?UTF-8?q?when=20failing=20to=20build=20a=20connection=20to=20the=20datab?= =?UTF-8?q?ase=20is=20now=20formatted=20in=20a=20more=20readable=20way.=20?= =?UTF-8?q?This=20improves=20the=20clarity=20of=20the=20error=20message=20?= =?UTF-8?q?and=20makes=20it=20easier=20to=20identify=20the=20cause=20of=20?= =?UTF-8?q?the=20issue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In base.py, the format method in FieldFormatter now accepts an optional 'name' parameter. This allows for more flexibility when formatting the field and provides the ability to include the field name in the formatting process if needed. --- src/backend/langflow/interface/initialize/loading.py | 5 ++++- .../langflow/template/frontend_node/formatter/base.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 046ca0df6..08d17d9fa 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -98,7 +98,10 @@ def instantiate_memory(node_type, class_object, params): exc ) or 'object has no field "conn"' in str(exc): raise AttributeError( - f"Failed to build connection to database. Please check your connection string and try again. Error: {exc}" + ( + "Failed to build connection to database." + f" Please check your connection string and try again. Error: {exc}" + ) ) from exc raise exc diff --git a/src/backend/langflow/template/frontend_node/formatter/base.py b/src/backend/langflow/template/frontend_node/formatter/base.py index 653480e03..67e906593 100644 --- a/src/backend/langflow/template/frontend_node/formatter/base.py +++ b/src/backend/langflow/template/frontend_node/formatter/base.py @@ -1,9 +1,10 @@ from abc import ABC, abstractmethod +from typing import Optional from langflow.template.field.base import TemplateField class FieldFormatter(ABC): @abstractmethod - def format(self, field: TemplateField): + def format(self, field: TemplateField, name: Optional[str]) -> None: pass