Skip to content

Commit

Permalink
added types for func
Browse files Browse the repository at this point in the history
  • Loading branch information
jagadeeswaran-zipstack committed Jun 26, 2024
1 parent 7f579a8 commit 9088beb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class ProfileManagerHelper:

@classmethod
def get_profile_manager(cls, profile_manager_id):
def get_profile_manager(cls, profile_manager_id: str) -> ProfileManager:
try:
return ProfileManager.objects.get(profile_id=profile_manager_id)
except ProfileManager.DoesNotExist:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def dynamic_indexer(
) from e

@staticmethod
def wait_for_document_indexing(doc_id_key):
def wait_for_document_indexing(doc_id_key: str) -> str:
max_wait_time = settings.MAX_WAIT_TIME # 30 minutes
wait_time = 0
polling_interval = settings.POLLING_INTERVAL # Poll every 5 seconds
Expand Down
10 changes: 5 additions & 5 deletions backend/prompt_studio/prompt_studio_core/redis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
from utils.cache_service import CacheService


def set_document_indexing(doc_id_key, ttl=1800):
def set_document_indexing(doc_id_key: str, ttl: int = 1800) -> None:
CacheService.set_key(f"document_indexing:{doc_id_key}", "started", expire=ttl)


def is_document_indexing(doc_id_key):
def is_document_indexing(doc_id_key: str) -> bool:
return CacheService.get_key(f"document_indexing:{doc_id_key}") == b"started"


def mark_document_indexed(doc_id_key, doc_id):
def mark_document_indexed(doc_id_key: str, doc_id: str) -> None:
CacheService.set_key(
f"document_indexing:{doc_id_key}", doc_id, expire=settings.INDEXING_FLAG_TTL
)


def get_indexed_document_id(doc_id_key):
def get_indexed_document_id(doc_id_key: str) -> str | None:
result = CacheService.get_key(f"document_indexing:{doc_id_key}")
if result and result != b"started":
return result
return None


def remove_document_indexing(doc_id_key):
def remove_document_indexing(doc_id_key: str) -> None:
CacheService.delete_a_key(f"document_indexing:{doc_id_key}")

0 comments on commit 9088beb

Please sign in to comment.