This repository was archived by the owner on Sep 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
src/ai/backend/client/func Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ Display kernel-pull-progress from background-task-reporter
Original file line number Diff line number Diff line change @@ -298,6 +298,27 @@ async def get_or_create(
298298 rqst .set_json (params )
299299 async with rqst .fetch () as resp :
300300 data = await resp .json ()
301+ with tqdm (total = 100 , unit = '%' ) as pbar :
302+ task_id = data ['background_task' ]
303+ bgtask = resp .session .BackgroundTask (task_id )
304+ async with bgtask .listen_events () as response :
305+ async for ev in response :
306+ progress = json .loads (ev .data )
307+ if ev .event == 'bgtask_updated' :
308+ current = progress ['current_progress' ]
309+ total = progress ['total_progress' ]
310+ if total == 0 :
311+ total = 1e-2
312+ pbar .n = round (current / total * 100 , 2 )
313+ pbar .update (0 )
314+ pbar .refresh ()
315+ elif ev .event == 'bgtask_done' :
316+ pbar .n = 100.0
317+ pbar .update (0 )
318+ pbar .refresh ()
319+ pbar .clear ()
320+ async with rqst .fetch () as resp :
321+ data = await resp .json ()
301322 o = cls (name , owner_access_key ) # type: ignore
302323 if api_session .get ().api_version [0 ] >= 5 :
303324 o .id = UUID (data ['sessionId' ])
You can’t perform that action at this time.
0 commit comments