fix api progress reporting endpoint

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-07-30 08:32:30 -04:00
parent eccf062add
commit e8fedf0a73
3 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -85,7 +85,7 @@ def get_history(req: models.ReqHistory = Depends()):
return res
def get_progress(req: models.ReqProgress = Depends()):
if shared.state.job_count == 0:
if shared.state.job_count == 0: # idle state
return models.ResProgress(id=shared.state.id, progress=0, eta_relative=0, state=shared.state.dict(), textinfo=shared.state.textinfo)
shared.state.do_set_current_image()
current_image = None
@@ -100,6 +100,7 @@ def get_progress(req: models.ReqProgress = Depends()):
progress = min((current / total) if current > 0 and total > 0 else 0, 1)
time_since_start = time.time() - shared.state.time_start
eta_relative = (time_since_start / progress) - time_since_start if progress > 0 else 0
# shared.log.critical(f'get_progress: batch {batch_x}/{batch_y} step {step_x}/{step_y} current {current}/{total} time={time_since_start} eta={eta_relative}')
res = models.ResProgress(id=shared.state.id, progress=round(progress, 2), eta_relative=round(eta_relative, 2), current_image=current_image, textinfo=shared.state.textinfo, state=shared.state.dict(), )
return res