-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release updated Gradio Support #2013
Comments
I have an idea for a possible direction building on top of https://github.com/radames/gradio-rerun-viewer/tree/main that I think would play nicely with the Gradio streaming execution model: https://www.gradio.app/guides/reactive-interfaces This requires building a little bit of extra functionality onto the python and javascript APIs:
This lets us set up Gradio in streaming mode, and have a job incrementally yield rrd chunks which are sent over Gradios comms mechanism and then added to the viewer where they are accumulated and a single RRD. Theoretical API might look something like:
|
#6187) ### What - This was motivated by #2013 The main piece of work, plumbing through drain was relatively straight-forward. In addition, when creating an example that roughly models the gradio streaming workflow, I realized it would be helpful to introduce a decorator which simplifies setting up an isolated recording stream, and works with the sort of streaming generators we expect to see with Gradio. ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6187?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6187?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/6187) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
…y as bytes (#6189) ### What - This was motivated by #2013 This API means that an RRD file transmitted over a side-channel such as gradio can be injected directly into the viewer instead of needing to point the viewer at a separate url. Tested with an adhoc svelte component: ```ts <script lang="ts"> import { WebViewer, LogChannel } from "@rerun-io/web-viewer"; import { onMount } from "svelte"; let rr: WebViewer; let ref: HTMLDivElement; let channel: LogChannel; onMount(() => { rr = new WebViewer(); rr.start(undefined, ref).then(() => { channel = rr.open_channel("gradio"); }); return () => { channel.close(); rr.stop(); }; }); let data1 = '...' let data2 = '...' let data3 = '...' function push(data: string) { var intermediate = atob(data); var buff = new Uint8Array(intermediate.length); for (var i = 0; i < intermediate.length; i++) { { buff[i] = intermediate.charCodeAt(i); } } channel.send_rrd(buff); } </script> <div class="container"> <button on:click={() => push(data1)}> Data1 </button> <button on:click={() => push(data2)}> Data2 </button> <button on:click={() => push(data3)}> Data3 </button> </div> <div class="viewer" bind:this={ref} /> ``` ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6189?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6189?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/6189) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
Reminder to self: give the gradio component a blueprint argument that does the right thing. |
This has been published. |
Background
A few of the complexities to figure out with Gradio:
(1) Gradio (and in particular hugging face spaces) run as a persistent service even across multiple users. This means we need to avoid, or at least be able to avoid global session state interfering across multiple user sessions.
(2) In Gradio's normal execution model, jobs fully execute, then produce an output. This is somewhat similar to how our current notebook cells works with a single static resource output. Instead, we would like the embedded rerun viewer context to exist the whole time the job is running with data incrementally streaming to it. Gradio already has its own incremental streaming mechanism used for things like streaming audio or video, so tying into this framework would be nice.
(3) HF spaces, including Gradio, do everything over a single port. This means we really don't want to depend on running our own websocket server. Somehow retrieving the data-stream back from Rerun and tunneling it through Gradios websocket, as done with the other data that Gradio transmits, would simplify integration. This is also somewhat related to user-isolation, since Gradio already manages user session context.
Next Steps
All of the above are functional in our PR: radames/gradio-rerun-viewer#1
Need to clean up PR to get it into a final state and then merge.
Live demonstration: https://huggingface.co/spaces/jleibs/rerun_streaming_poc
The text was updated successfully, but these errors were encountered: