Skip to content

Commit

Permalink
Merge pull request #86 from ISSResearch/fix-task
Browse files Browse the repository at this point in the history
refactor duplicate task
  • Loading branch information
githubering182 authored Sep 29, 2024
2 parents eb5159b + 99f3b0c commit 4ff2b8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion storage-app/src/router/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def upload_file(
file_id, _status = await project_bucket.put_object(file, file_meta)

if _status == status.HTTP_201_CREATED:
produce_handle_media_task.delay(bucket_name, file_id)
produce_handle_media_task.apply_async((bucket_name, file_id), countdown=10)

return JSONResponse(status_code=_status, content={"result": file_id})

Expand Down
14 changes: 10 additions & 4 deletions storage-app/src/shared/worker_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@


class EmbeddingStatus(Enum):
DUPLICATE = "v"
DUPLICATE = "u"
VALIDATION = "v"
REBOUND = "r"

def __json__(self, *args, **kwargs): return self.name

def to_value(self):
match self.value:
case "u": return "v"
case _: return self.value


class Zipper:
written: bool = False
Expand Down Expand Up @@ -160,9 +165,9 @@ def search_similar(self):
with EmbeddingStorage() as storage:
self.result = storage.search(self.embedding, self.project_id)
self.status = (
EmbeddingStatus.VALIDATION
if not self.result else
EmbeddingStatus.DUPLICATE
if len(self.result)
else EmbeddingStatus.VALIDATION
)

def handle_search_result(self):
Expand All @@ -174,6 +179,7 @@ def handle_search_result(self):

with EmbeddingStorage() as storage:
if self.status == EmbeddingStatus.DUPLICATE:
print("HERE")
rmi: Optional[str] = None
rmd: float = float("inf")

Expand Down Expand Up @@ -216,7 +222,7 @@ def send_update(
payload_token = emit_token({"minutes": 1}, SECRET_KEY, SECRET_ALGO)
payload = {}

if status: payload["status"] = status.value
if status: payload["status"] = status.to_value()
if rebound: payload["rebound"] = rebound

if not status and not rebound: return
Expand Down

0 comments on commit 4ff2b8e

Please sign in to comment.