Skip to content

Commit

Permalink
removing unnecessary changes from unclear test results in last run
Browse files Browse the repository at this point in the history
  • Loading branch information
himan-k committed Jul 10, 2024
1 parent 0914d63 commit 8670c64
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/backend/base/langflow/services/session/service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Coroutine, Optional

from langflow.services.base import Service
from langflow.services.cache.base import CacheService, AsyncBaseCacheService
from langflow.services.cache.base import CacheService
from langflow.services.session.utils import compute_dict_hash, session_id_generator


Expand All @@ -12,16 +12,12 @@ def __init__(self, cache_service):
self.cache_service: "CacheService" = cache_service

async def load_session(self, key, flow_id: str, data_graph: Optional[dict] = None):
# Check if the data is cached
if isinstance(self.cache_service, AsyncBaseCacheService):
result = await self.cache_service.get(key)
# Check if the data is cached
if key in self.cache_service:
result = self.cache_service.get(key)
if isinstance(result, Coroutine):
result = await result
return result
else:
if key in self.cache_service:
result = self.cache_service.get(key)
if isinstance(result, Coroutine):
result = await result
return result

if key is None:
key = self.generate_key(session_id=None, data_graph=data_graph)
Expand All @@ -48,12 +44,11 @@ def generate_key(self, session_id, data_graph):
return self.build_key(session_id, data_graph=data_graph)

async def update_session(self, session_id, value):
if isinstance(self.cache_service, AsyncBaseCacheService):
result = self.cache_service.set(session_id, value)
if isinstance(result, Coroutine):
await result
else:
self.cache_service.set(session_id, value)
result = self.cache_service.set(session_id, value)
# if it is a coroutine, await it
if isinstance(result, Coroutine):
await result

async def clear_session(self, session_id):
result = self.cache_service.delete(session_id)
# if it is a coroutine, await it
Expand Down

0 comments on commit 8670c64

Please sign in to comment.