From 7d1a01b6053ccdf82ba2b5b2e8523d40efec509f Mon Sep 17 00:00:00 2001 From: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com> Date: Mon, 27 Oct 2025 10:52:10 +0530 Subject: [PATCH] [MISC] Move Redis clients to unstract-core for better code organization (#1613) - Moved redis_client.py and redis_queue_client.py from workers/shared/cache/ to unstract/core/src/unstract/core/cache/ - Created new cache module in unstract-core with __init__.py exports - Updated all import statements across workers to use unstract.core.cache instead of shared.cache - Updated imports in log_consumer tasks and cache_backends to use new location - Maintains backward compatibility by keeping same API and functionality --- unstract/core/src/unstract/core/cache/__init__.py | 9 +++++++++ .../core/src/unstract/core}/cache/redis_client.py | 0 .../core/src/unstract/core}/cache/redis_queue_client.py | 2 +- workers/log_consumer/process_log_history.py | 3 ++- workers/log_consumer/tasks.py | 2 +- workers/shared/cache/cache_backends.py | 2 +- 6 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 unstract/core/src/unstract/core/cache/__init__.py rename {workers/shared => unstract/core/src/unstract/core}/cache/redis_client.py (100%) rename {workers/shared => unstract/core/src/unstract/core}/cache/redis_queue_client.py (98%) diff --git a/unstract/core/src/unstract/core/cache/__init__.py b/unstract/core/src/unstract/core/cache/__init__.py new file mode 100644 index 00000000..f13c7c53 --- /dev/null +++ b/unstract/core/src/unstract/core/cache/__init__.py @@ -0,0 +1,9 @@ +"""Redis Cache Clients for Unstract. + +This module provides Redis client implementations for caching and queue operations. +""" + +from .redis_client import RedisClient +from .redis_queue_client import RedisQueueClient + +__all__ = ["RedisClient", "RedisQueueClient"] diff --git a/workers/shared/cache/redis_client.py b/unstract/core/src/unstract/core/cache/redis_client.py similarity index 100% rename from workers/shared/cache/redis_client.py rename to unstract/core/src/unstract/core/cache/redis_client.py diff --git a/workers/shared/cache/redis_queue_client.py b/unstract/core/src/unstract/core/cache/redis_queue_client.py similarity index 98% rename from workers/shared/cache/redis_queue_client.py rename to unstract/core/src/unstract/core/cache/redis_queue_client.py index 026cc939..0a9362bc 100644 --- a/workers/shared/cache/redis_queue_client.py +++ b/unstract/core/src/unstract/core/cache/redis_queue_client.py @@ -7,7 +7,7 @@ Inherits from RedisClient for basic Redis functionality. import logging from typing import Any -from .redis_client import RedisClient +from unstract.core.cache.redis_client import RedisClient logger = logging.getLogger(__name__) diff --git a/workers/log_consumer/process_log_history.py b/workers/log_consumer/process_log_history.py index fb6ece40..a941bb06 100755 --- a/workers/log_consumer/process_log_history.py +++ b/workers/log_consumer/process_log_history.py @@ -17,7 +17,8 @@ import os import sys import httpx -from shared.cache.redis_queue_client import RedisQueueClient + +from unstract.core.cache.redis_queue_client import RedisQueueClient logger = logging.getLogger(__name__) diff --git a/workers/log_consumer/tasks.py b/workers/log_consumer/tasks.py index 93c44398..eeae05f4 100644 --- a/workers/log_consumer/tasks.py +++ b/workers/log_consumer/tasks.py @@ -8,11 +8,11 @@ from typing import Any import socketio from celery import shared_task -from shared.cache.redis_queue_client import RedisQueueClient from shared.infrastructure.config import WorkerConfig from shared.infrastructure.logging import WorkerLogger from shared.utils.api_client_singleton import get_singleton_api_client +from unstract.core.cache.redis_queue_client import RedisQueueClient from unstract.core.constants import LogEventArgument, LogProcessingTask from unstract.core.log_utils import store_execution_log diff --git a/workers/shared/cache/cache_backends.py b/workers/shared/cache/cache_backends.py index 695ba766..24363801 100644 --- a/workers/shared/cache/cache_backends.py +++ b/workers/shared/cache/cache_backends.py @@ -11,7 +11,7 @@ from abc import ABC, abstractmethod from datetime import UTC, datetime from typing import Any -from .redis_client import RedisClient +from unstract.core.cache.redis_client import RedisClient logger = logging.getLogger(__name__)