From d393a66b2f2592d7efcb989bdf9136a501dd80a0 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 17 Aug 2023 09:11:52 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(base.py):=20handle=20ImportE?= =?UTF-8?q?rror=20when=20importing=20celery.result.AsyncResult=20to=20allo?= =?UTF-8?q?w=20building=20the=20vertex=20locally=20when=20Celery=20is=20no?= =?UTF-8?q?t=20installed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/graph/vertex/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/graph/vertex/base.py b/src/backend/langflow/graph/vertex/base.py index 87c8fa851..bbd2bbb65 100644 --- a/src/backend/langflow/graph/vertex/base.py +++ b/src/backend/langflow/graph/vertex/base.py @@ -11,7 +11,7 @@ import inspect import types from typing import Any, Dict, List, Optional from typing import TYPE_CHECKING -from celery.result import AsyncResult + if TYPE_CHECKING: from langflow.graph.edge.base import Edge @@ -180,6 +180,11 @@ class Vertex: return self._built_object # Check if there's a task_id, which means it was sent to a Celery worker + try: + from celery.result import AsyncResult + except ImportError: + # If Celery is not installed, just build the vertex locally + return self.build() if self.is_task and self.task_id is not None: result = AsyncResult(self.task_id).get( timeout=timeout