🐛 fix(celery_app.py): ignore type error for Celery import to avoid linting issues

🐛 fix(base.py): ignore type error for AsyncResult import to avoid linting issues

🐛 fix(worker.py): ignore type error for SoftTimeLimitExceeded import to avoid linting issues
 feat(worker.py): add conditional clearing of session cache based on clear_cache flag to improve performance
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-05 15:35:14 -03:00
commit 0d9d4856fb
3 changed files with 5 additions and 5 deletions

View file

@ -1,4 +1,4 @@
from celery import Celery
from celery import Celery # type: ignore
def make_celery(app_name: str):

View file

@ -76,7 +76,7 @@ class Vertex:
def get_task(self):
# using the task_id, get the task from celery
# and return it
from celery.result import AsyncResult
from celery.result import AsyncResult # type: ignore
return AsyncResult(self.task_id)

View file

@ -1,9 +1,8 @@
from langflow.core.celery_app import celery_app
from typing import Any, Dict, Optional, Tuple
from typing import TYPE_CHECKING
from celery.exceptions import SoftTimeLimitExceeded
from celery.exceptions import SoftTimeLimitExceeded # type: ignore
from langflow.processing.process import (
clear_caches_if_needed,
generate_result,
process_inputs,
)
@ -42,8 +41,9 @@ def process_graph_cached_task(
session_id=None,
) -> Tuple[Any, str]:
initialize_session_manager()
clear_caches_if_needed(clear_cache)
session_manager = get_session_manager()
if clear_cache:
session_manager.clear_session(session_id)
# Load the graph using SessionManager
langchain_object, artifacts = session_manager.load_session(session_id, data_graph)
processed_inputs = process_inputs(inputs, artifacts)