rpa
This commit is contained in:
parent
1676e917cc
commit
e57b504e12
|
|
@ -60,3 +60,5 @@ class LiveStreamResult(BaseModel):
|
||||||
error: Optional[str] = None
|
error: Optional[str] = None
|
||||||
msg: Optional[str] = None
|
msg: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
LIVE_WATCH_TASK_DOING: str = "LIVE_WATCH_TASK_DOING"
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
# my_job_queue_endpoint.py
|
# my_job_queue_endpoint.py
|
||||||
import fastapi
|
import fastapi
|
||||||
from typing import List, Optional, Any
|
from typing import List, Optional, Any, Coroutine
|
||||||
import modal
|
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
|
from scalar_fastapi import get_scalar_api_reference
|
||||||
|
|
||||||
image = (modal.Image.debian_slim()
|
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}")
|
@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)
|
function_call = modal.FunctionCall.from_id(call_id)
|
||||||
try:
|
try:
|
||||||
result = function_call.get(timeout=0)
|
result = function_call.get(timeout=0)
|
||||||
|
|
@ -51,6 +53,10 @@ async def get_job_result_endpoint(call_id: str) -> Optional[LiveStreamResult]:
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
return fastapi.responses.JSONResponse(content="", status_code=202)
|
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
|
return result
|
||||||
|
|
||||||
# modal serve my_job_queue_endpoint.py
|
# modal serve my_job_queue_endpoint.py
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue