diff --git a/src/cluster/rpa_comm.py b/src/cluster/rpa_comm.py index cc870ed..64fd939 100644 --- a/src/cluster/rpa_comm.py +++ b/src/cluster/rpa_comm.py @@ -60,3 +60,5 @@ class LiveStreamResult(BaseModel): error: Optional[str] = None msg: Optional[str] = None + +LIVE_WATCH_TASK_DOING: str = "LIVE_WATCH_TASK_DOING" \ No newline at end of file diff --git a/src/cluster/rpa_web_end_point.py b/src/cluster/rpa_web_end_point.py index 9f895ad..dcd1145 100644 --- a/src/cluster/rpa_web_end_point.py +++ b/src/cluster/rpa_web_end_point.py @@ -1,8 +1,10 @@ # my_job_queue_endpoint.py import fastapi -from typing import List, Optional, Any +from typing import List, Optional, Any, Coroutine import modal -from .rpa_comm import LiveStreamProductWatchRequest, LiveStreamResult, ProductSession +from loguru import logger + +from .rpa_comm import LiveStreamProductWatchRequest, LiveStreamResult, ProductSession, LIVE_WATCH_TASK_DOING from scalar_fastapi import get_scalar_api_reference image = (modal.Image.debian_slim() @@ -42,7 +44,7 @@ async def submit_job_endpoint(data: LiveStreamProductWatchRequest) -> Optional[A @web_app.get("/live_watch/result/{call_id}") -async def get_job_result_endpoint(call_id: str) -> Optional[LiveStreamResult]: +async def get_job_result_endpoint(call_id: str) -> Any: function_call = modal.FunctionCall.from_id(call_id) try: result = function_call.get(timeout=0) @@ -51,6 +53,10 @@ async def get_job_result_endpoint(call_id: str) -> Optional[LiveStreamResult]: except TimeoutError: return fastapi.responses.JSONResponse(content="", status_code=202) + logger.debug("res:",result) + if len(result) == 0: + return fastapi.responses.JSONResponse(content=LIVE_WATCH_TASK_DOING, status_code=200) + return result # modal serve my_job_queue_endpoint.py