Skip to content

Commit

Permalink
Added time to progress message
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhichang committed Dec 23, 2024
1 parent 85083ad commit 8e55d79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/db/services/task_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import random
import xxhash
import bisect
from datetime import datetime

from api.db.db_utils import bulk_insert_into_db
from deepdoc.parser import PdfParser
Expand Down Expand Up @@ -84,7 +85,7 @@ def get_task(cls, task_id):
if not docs:
return None

msg = "\nTask has been received."
msg = f"\n{datetime.now().strftime('%H:%M:%S.%f')} Task has been received."
prog = random.random() / 10.0
if docs[0]["retry_count"] >= 3:
msg = "\nERROR: Task is abandoned after 3 times attempts."
Expand Down
6 changes: 4 additions & 2 deletions rag/svr/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

CONSUMER_NAME = "task_consumer_" + CONSUMER_NO
PAYLOAD: Payload | None = None
BOOT_AT = datetime.now().isoformat()
BOOT_AT = datetime.now().astimezone().isoformat(timespec="milliseconds")
PENDING_TASKS = 0
LAG_TASKS = 0

Expand Down Expand Up @@ -116,6 +116,8 @@ def set_progress(task_id, from_page=0, to_page=-1, prog=None, msg="Processing...
if to_page > 0:
if msg:
msg = f"Page({from_page + 1}~{to_page + 1}): " + msg
if msg:
msg = datetime.now().strftime("%H:%M:%S.%f") + " " + msg
d = {"progress_msg": msg}
if prog is not None:
d["progress"] = prog
Expand Down Expand Up @@ -550,7 +552,7 @@ def report_status():
with mt_lock:
heartbeat = json.dumps({
"name": CONSUMER_NAME,
"now": now.isoformat(),
"now": now.astimezone().isoformat(timespec="milliseconds"),
"boot_at": BOOT_AT,
"pending": PENDING_TASKS,
"lag": LAG_TASKS,
Expand Down

0 comments on commit 8e55d79

Please sign in to comment.