Progress
import timeimport surfra
@surfra.handlerdef render(request: surfra.Request): frames = int(request.input.get("frames", 20)) for index in range(frames): time.sleep(0.5) surfra.progress((index + 1) / frames, f"frame {index + 1} of {frames}") return {"frames": frames}If your library takes a callback, decorate it instead:
@surfra.progressdef on_step(fraction: float): pass
pipeline(prompt, callback=lambda step, total: on_step(step / total))Read progress while the request runs:
import timeimport surfra
call = surfra.App("render").enqueue({"frames": 20})while (view := call.get())["status"] == "running": print(view["stages"][0]["progress"]) time.sleep(1)The Requests tab shows the same value.
