Spaces:
Running
Running
Commit History
-
Revert cached-Client call_space monkeypatch Running
The app-side cache did not fix the high-load 429: a concurrency test showed 20 simultaneous call_space calls produced 20 Client() constructions (20 /config fetches) with zero cache hits, due to a thundering-herd on the cold-cache miss. Even with that race fixed, per-user (space_id, token) keying means N concurrent users = N cold /config fetches during the burst that causes the 429 - the wrong granularity, since the backend /config is identical for everyone. The config is token-independent but gradio_client.Client bundles config + token, so an app-side Client cache cannot both (a) collapse the concurrent config-fetch storm and (b) preserve per-user ZeroGPU billing. The real fix is upstream in gradio: cache the token-independent config per space_id and build per-user Clients that reuse it without re-fetching - needs a gradio_client API like Client(space_id, token=..., config=cached_config). Revert app.py to the clean a8659be state (api_visibility=private only). Co-Authored-By: Claude …35dd666 -
Fix monkeypatch: preserve call_space __name__ so the canvas finds it
The previous commit broke the frontend with "Server call function not available": the patched fn was named "_patched_call_space", but WorkflowCanvas registers each server_function under getattr(fn, "__name__") (components/base.py:99) and the frontend canvas invokes server.call_space(...) by that exact name. So the route did getattr(block, "call_space") -> None -> 404 "Function not found" -> the canvas showed "Server call function not available". Use functools.wraps(orig_call_space) so the patched fn keeps __name__ / __doc__ / __wrapped__ == "call_space". Verified: __name__ is "call_space", setattr(canvas, "call_space", ...) succeeds, the route finds it, and the cached-client generation path still works (call 1 fetches /config, call 2 reuses the cached client with no refetch). Co-Authored-By: Claude <noreply@anthropic.com>30e3b70 -
Prototype: cached-Client call_space to stop /config 429 storm
Root cause (verified from gradio_client + gradio source + a captured failing response): gradio.workflow.call_space constructs a FRESH gradio_client.Client on EVERY call (workflow.py:524), and constructing a Client fetches the backend /config over HTTP. Under high traffic that is a storm of /config requests against the public backend; HF rate-limits the public Space /config -> HTTP 429 -> gradio_client raises TooManyRequestsError -> call_space wraps it as error_type "unknown" -> the canvas shows "Z-Image-Turbo (backend): Too many requests". This fires BEFORE the GPU call, so it is identity-blind (even logged-in PRO users hit it). Fix: monkeypatch gradio.workflow.call_space to reuse a Client per (space_id, token) so /config is fetched ~once per 5min TTL instead of per call. gradio_client.Client is designed to be constructed once and .predict() many times. Cache is a bounded (256) thread-safe LRU with TTL, and evicts on failure (rebuilding a stale client, e.g. after a backend restart) be…62e8a32 -
Turn off workflow REST API: set subject endpoints private
gr.Workflow exposes each subject node as a public REST endpoint (/output_image, /seed_used) registered via .click(api_name=...) with no api_visibility, so they default to 'public' — callable by any gradio_client and listed on the API docs page. The Workflow constructor takes no api_visibility flag, so flip the registered BlockFunctions to 'private' after construction: hidden from API docs and not callable by clients. Canvas UI is unaffected (Run button drives the backend Space directly). Co-Authored-By: Claude <noreply@anthropic.com>a8659be
-
Update app.py
Verified signature1eb1a07 -
Update app.py
Verified signature8c46283
-
Test mirror of mrfakename PR #92: workflow frontend calls akhaliq backend
akhaliqPure gr.Workflow frontend whose canvas's space operator calls akhaliq/Z-Image-Turbo /generate_image via gradio_client's call_space. hf_oauth: true so the canvas forwards the visitor's HF OAuth token to the backend, where @spaces.GPU meters PRO quota against the signed-in visitor. - app.py -> gr.Workflow(graph=workflow.json).launch() - workflow.json -> operator kind: space, target akhaliq/Z-Image-Turbo /generate_image, same 6 in / 2 out shape - requirements.txt -> gradio only (no GPU, no diffusers; backend owns those) - README.md -> hf_oauth: true + test-mirror description4d40c75 -
initial commit
Verified signaturef4d153d