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
Lite: Websocket queueing #5124
Lite: Websocket queueing #5124
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
43772d5
to
01148dc
Compare
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-5124-all-demos You can install the changes in this PR by running: pip install https://gradio-builds.s3.amazonaws.com/b8e1f4fd6311f56f1467a9a34d71e298e85d1ac6/gradio-3.39.0-py3-none-any.whl |
5493b63
to
698abf2
Compare
d502afc
to
da6dc10
Compare
1399fad
to
749c36e
Compare
🪼 branch checks and previews
|
@whitphx like we discussed in sync, I ran into a few issues:
Here's two simple examples: import gradio as gr
demo = gr.Interface(lambda x:x, "text", "text")
if __name__ == "__main__":
demo.queue().launch() import gradio as gr
def greet(inp):
return "hello " + inp + "!"
with gr.Blocks() as demo:
text = gr.Textbox()
output = gr.Textbox()
button = gr.Button("Submit")
button.click(greet, inputs=text, outputs=output)
if __name__ == "__main__":
demo.queue().launch()
|
@aliabd Thank you! Will work on these! |
Note: About the first problem
This is because -> I will fix here to call About the second problem
-> I will merge the latest |
… it from wasm_utils.register_app() to dispose an old app instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliabd The bugs should have been fixed 👍
But I have some things to ask for better code. Appreciate your thoughts, thanks!
gradio/blocks.py
Outdated
if re.match( | ||
r"\w+_\d+", task_name | ||
): # This regex matches the task names set by `utils.set_task_name()` | ||
task.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is indented to cancel the tasks created at the following places, which normally run in an event loop in the server thread and stopped by self.server.cancel()
, however, in the case of Wasm, run in an event loop in the main thread.
Lines 573 to 576 in ea0e00b
task = run_coro_in_background( blocks._queue.process_events, [event], False ) set_task_name(task, event.session_hash, event.fn_index, batch=False) Lines 136 to 138 in ea0e00b
task = run_coro_in_background(self.process_events, events, batch) run_coro_in_background(self.broadcast_live_estimations) set_task_name(task, events[0].session_hash, events[0].fn_index, batch)
The current code here is ad-hoc. @aliabd do you have any ideas about where we should put this code snippet better or what code snippet we can write?
(I firstly thought I could write this code at queueing.Queue.close()
, but it seemed the Queue
is expected to be resume()
-ed, so I finally didn't. Was it correct?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whitphx Blocks.close()
only makes sense in the context of a server, because it's used to free up ports/terminate the server.
Really, the only use case is in a notebook setting, because users can be running multiple demos sequentially in cells and could use it to reduce bloat once a demo is done. Or to run gr.close_all()
which closes every port an Interface is running on. We do also use it in our tests. But there's no use case for it inside a demo or anything like that (we don't even document it anywhere). So it doesn't make sense in the wasm context, since there's no server or ports anyway. So I think if it's called inside wasm it shouldn't do anything (or potentially it could do something with app). You do call it in wasm_utils.py
but I'm not sure what it's doing there? (left a comment)
Same with queue().close()
which is only meant to be used in the context of threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if this makes sense or if I'm missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review!
My original intension was to "clean up" all the resources and running tasks bound to the running app
and blocks
when a user runs new app code including Blocks.launch()
with run_code()
or run_file()
.
The clean-up here should be something like what happens when a normal Gradio app is terminated, and I thought Blocks.close()
was it.
Also, wasm_utils.register_app()
is called with a new FastAPI app
object every time a user calls Blocks.launch()
.
So I thought putting the clean-up code in Blocks.close()
and calling it from wasm_utils.register_app()
before registering the new app
object would be a good solution.
If it doesn't make sense, it's ok if we can put this task cancellation code somewhere and call it on every Blocks.launch()
call as written above. Appreciate it if you have some suggestions on it as well.
For the semantics of the server-context you wrote:
Even in the Wasm ver., there is a FastAPI app
object, and if we see it as a part of the "server", things may make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, putting this task cancellation code to wasm_utils.register_app()
directly also works, instead of modifying Blocks.close()
and calling it from register_app()
, like
def register_app(_app):
global app
# HERE!
for task in asyncio.all_tasks():
task_name = task.get_name()
if re.match(
r"\w+_\d+", task_name
): # This regex matches the task names set by `utils.set_task_name()`
task.cancel()
app = _app
Blocks.close()
looked like a general purpose cleanup method paired with Blocks.launch()
, so I thought using it makes the code more robust for future changes rather than adding Wasm-specific cleanup code, but it's ok to decline it if it doesn't make sense from your aspect. Please give an advice :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliabd Thanks!
Can't we just cancel all the tasks?
There are some tasks which must not be cancelled, such as
gradio/js/wasm/src/webworker/index.ts
Line 109 in abb5e9d
async def _call_asgi_app_from_js(scope, receive, send): |
Such tasks are mainly executed outside Gradio to manage the Gradio server across multiple
run_file()
or run_code()
executions.Also, I wanted to reduce risks of unexpected side effects in the future.
I'm fine with doing it your way
So, let me take this path, thanks!
I added a comment explaining this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whitphx I really like this, much cleaner! and no regex :)
But this is causing an error on the console.
PyodideTask exception was never retrieved
pyodide.asm.js:9 future: <PyodideTask finished name='41bqrtb8ssv_0' coro=<Queue.process_events() done, defined at /lib/python3.11/site-packages/gradio/queueing.py:425> exception=ValueError('[<gradio.queueing.Event object at 0x78dcda8>] is not in list')>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliabd Thanks!
I added a fix: 9c65c01
As I commented in the code, this is an existing bug.
The thrown error is not printed in the normal Python env (Why exceptions in asnycio are late or do not appear at all? - Stack Overflow) but it is in the Pyodide/Wasm env due to its unique event loop design.
Even in the normal env, we can confirm the same exception is raised, for example when reloading an app using gr.load(every=...)
by adding a callback to the task created here to print the exception as below.
blocks._queue.process_events, [event], False
)
set_task_name(task, event.session_hash, event.fn_index, batch=False)
+ def task_done_callback(task):
+ if task.exception():
+ print(task.exception())
+ task.add_done_callback(task_done_callback)
python run.py
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
[<gradio.queueing.Event object at 0x12dafc2e0>] is not in list
This implies we should fix all the code using run_coro_in_background()
to handle exceptions (as a separate ticket of course). The Stack Overflow answer says
You should never do fire-and-forget technique for created tasks.
-> Created an issue: #5784
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah got it!
# so all the asyncio tasks created by the queue runs in an event loop in that thread and | ||
# will be cancelled just by stopping the server. | ||
# In contrast, in the Wasm env, we can't do that because `threading` is not supported and all async tasks will run in the same event loop, `pyodide.webloop.WebLoop` in the main thread. | ||
# So we need to manually cancel them. See `self.close()`.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliabid94 Is this comment correct about the purpose of calling the HTTP endpoint startup-events
? (Ref: #1969)
gradio/blocks.py
Outdated
if re.match( | ||
r"\w+_\d+", task_name | ||
): # This regex matches the task names set by `utils.set_task_name()` | ||
task.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whitphx Blocks.close()
only makes sense in the context of a server, because it's used to free up ports/terminate the server.
Really, the only use case is in a notebook setting, because users can be running multiple demos sequentially in cells and could use it to reduce bloat once a demo is done. Or to run gr.close_all()
which closes every port an Interface is running on. We do also use it in our tests. But there's no use case for it inside a demo or anything like that (we don't even document it anywhere). So it doesn't make sense in the wasm context, since there's no server or ports anyway. So I think if it's called inside wasm it shouldn't do anything (or potentially it could do something with app). You do call it in wasm_utils.py
but I'm not sure what it's doing there? (left a comment)
Same with queue().close()
which is only meant to be used in the context of threads.
gradio/blocks.py
Outdated
if re.match( | ||
r"\w+_\d+", task_name | ||
): # This regex matches the task names set by `utils.set_task_name()` | ||
task.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if this makes sense or if I'm missing something
Both bugs are indeed gone! All the queue apps I'm trying are working great :) Will just do some more testing and then I'm fine with merging this. Nice work @whitphx! |
gradio-ui / functional-test is failing because of an issue we had that's fixed on main. You should just update the branch. |
While these are not direct answers to your comment, I tried to explain what the "server" mechanism of the Wasm ver. looks like:
|
….active_jobs` when `queue.process_events` is called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @whitphx for the great work here!
I tested everything:
- queueing is working as expected in a wasm environment.
- queueing is working as expected in a non-wasm environment. (here's a space with demos reflecting last commit)
This is good to merge! Please just update the pr from main, and run the linter so the backend tests pass (sh scripts/format_backend.sh
)
Thank you! Will merge it. |
omg, Nice space for manual tests, btw! |
* Accessibility Improvements (#5554) * allow remove token via keyboard * more a11y enhancements * upload + dataset a11y tweaks * add changeset * add webcam label * improve checkbox focus styling and allow interaction via keyboard * add changeset * improve radio focus color * tweak * add radio label * add changeset * add annotated image alt + use button for labels * button tweaks * add changeset * tweak * more changes * tiny tweaks * galley / image * label tweaks and add semantic tags to confidence * nit + docstring * tweak * add changeset * fix tests * unit test fix * range tweak * fix alignment in gallery * range tweak * slider test tweak * tweak * more test fixes * last? test tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix secondary hue bug in gr.themes.builder() (#5660) * fix: builder_app.py * add changeset * add changeset --------- Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Improve plot rendering (#5642) * changes * add changeset * changes * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com> * Add `render_markdown` parameter to chatbot (#5604) * disable markdown * add changeset * pr fixes * format * add changeset * new line --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Prevent Clients from accessing API endpoints that set `api_name=False` (#5653) * only autoscroll if user hasn't scrolled up * docstring * format * client * add changeset * add changeset * restore * add changeset * fix python client, add test * format * js client * format * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix width and height issues that would cut off content in `gr.DataFrame` (#5616) * fix dataframe height * fix widths * add changeset * fixes * format * case * add changeset * dataframe docstring * format * fix ts * test components --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Add the brand assets page to the website (#5643) * Add the /brand page to the website * add changeset * Fix layout * Put each logo in a different line * fix footer * remove unnenecessary header * better spacing * Add png files * Set the size of brand-assets/gradio-logo.svg as 64x64 --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: aliabd <ali.si3luwa@gmail.com> * Fix functional tests (#5682) * unnamed * add changeset * add build --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix small issues in docs and guides (#5669) * Keep website guides sidebar width consistent * add next / prev buttons to chatinterface * add changeset * sidebar fixes on docs * clean iframes from guides * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * [Refactoring] Convert async functions that don't contain `await` statements to normal functions (#5677) * [Refactoring] Convert async functions that don't contain `await` statements to normal functions * add changeset * add changeset * fix tests --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Pause autoscrolling if a user scrolls up in a `gr.Textbox` and resume autoscrolling if they go all the way down (#5652) * only autoscroll if user hasn't scrolled up * docstring * fixes * add changeset * format --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore(deps): update dependency @types/prismjs to v1.26.1 (#5671) * chore(deps): update dependency @types/prismjs to v1.26.1 * add changeset --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add `gr.on` listener method (#5639) * changes * changes * changes * changes * changes * add changeset * changes * changes * changes * changes * changes * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * add query parameters to the `gr.Request` object through the `query_params` attribute (#5681) * add queryParams to frontend request to backend * add changeset * update guide * added docs * add changeset * fix tests * client --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Reorganize Docs Navbar and Fill in Gaps (#5675) * remove combining-interfaces * reorg navbar and other changes * better docs for error, warning, and info * group them together * navbar reactively update * add changeset * lint * fix chatinterface test * fix test again * revert changes to chatinterface test * Update gradio/helpers.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Update gradio/helpers.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@hotmail.co.uk> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Fix functional tests, part 2 (#5687) * remove build * intentionally break * add changeset * testing string * change to false * throw error * revert break * delete changeset * add client js files to cache --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * setting share=True on Spaces or in wasm should warn instead of raising error (#5696) * setting share=True on Spaces or in wasm should raise warning instead of error * tweak * add changeset * lint * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix incorrect behavior of `gr.load()` with `gr.Examples` (#5690) * testing * fixes * chat fix * lint * add changeset * fix * simplify * simplify * spacing * remove print * docstring * dataset * lint * add changeset * fix test * add test * added test --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Increase Slider clickable area (#5697) * slider click area * add changeset * fix --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix blocks essay demo to use non-reserved keywords (#5698) * fix demo * notebook * chore: update versions (#5596) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix for regression in rendering empty Markdown (#5701) * quick fix * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore: update versions (#5702) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: prevent internal log_message error from `/api/predict` (#5711) * Prevent erroring on log_message from /api/predict * add changeset * add changeset * add changeset * updated docstrings --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Context-based Progress tracker (#5693) * Context-based Progress tracker * Lint * add changeset * Context-based virtual unpatch * Avoid creating TrackedIterable if not patched * Fix function_wrapper args * More correct * Add some types * Single Progress instance to allow nested tqdms * progress_tracker -> progress --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Fully resolve generated filepaths when running on Hugging Face Spaces with multiple replicas (#5668) * print * add changeset * url * routes * routes * test * test * add to / route * comment * root_url approach * replica url * print * print * test * revert * fixes * changes * replica url fix * lint * routes * routes * fix * docstring * add changeset * add changeset * add changeset * modify in place * add test * unit tests * fix copy --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fixes gr.select() Method Issues with Dataframe Cells (#5713) * fixes * add changeset * pr fixes * fix --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Make Tab and Tabs updatable (#5714) * fix * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * fix changelogs (#5718) * Adds copy buttons to website, and better descriptions to API Docs (#5721) * add missing docstring to highlightedtext * add description to return types in api_docs * add copy buttons to docs * fix up descriptions for filepaths * add copy buttons to every codeblock * add changeset * fix backend tests * add changeset * better worded descriptions * fix color_map description * fix formatting in code snippets * add space --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Adjust translation (#5726) * Adjust translation * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com> * Fix for deepcopy errors when running the replica-related logic on Spaces (#5722) * fix changelogs * pass * add changeset * test * config * change * fixes * route utils * add changeset * add changeset * add lock * print * route url * replicas * replicas --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * ensure internal data has updated before dispatching `success` or `then` events (#5705) * ensure internal data has updated before dispatching then or success events * ensure internal data has updated before dispatching then or success events * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add a bare `Component` type to the acceptable type list of `gr.load()`'s `inputs` and `outputs` (#5732) * Add a bare `Component` type to the acceptable type list of `gr.load()`'s `inputs` and `outputs` * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com> * chore: update versions (#5712) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Added timeout and error handling for frpc tunnel (#5731) * added timeout and error handling for frpc tunnel * add changeset * lint * typing * spell * tunneling * lint * strip --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Ensure images with no caption download in gallery (#5735) * ensure images with no caption download in gallery * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add design tokens to storybook (#5750) * add design tokens to storybook * tweak * tweak * visual tweaks * add icons * Improve chatbot accessibility and UX (#5699) * add a11y changes and css tweaks * add a11y changes and css tweaks * change like/dislike/copy buttons ux * cleanup * add laout param * tweak * add changeset * fill icon on click * text alignment tweak * format + test * fix browser test * avatar tweaks * add stories * tweak * tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Set share=True for all Gradio apps in Colab by default (#5767) * Set share=True for all Gradio apps in Colab by default * add changeset * fix tests --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Added support for pandas `Styler` object to `gr.DataFrame` (initially just sets the `display_value`) (#5569) * adding precision to df * add changeset * docstring * precision * add changeset * fix * fixes * add changeset * add visual test * lint * fixes * lint * format * add changeset * ts changes * analytics * dataframe typing * typing * demo * fix * lint * interactive dataframe * dataframe * fix typing * add test * upgrade pandas version * fix pandas version --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Don't raise warnings when returning an updated component in a dictionary (#5766) * testing * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix Gallery `columns` and `rows` params (#5754) * fix gallery params * add changeset * lint --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix new line issue in chatbot (#5755) * fix new line * add changeset * line breaks param * add changeset * fix test * Update gradio/components/chatbot.py * Update gradio/components/dataframe.py * Update gradio/components/markdown.py * add changeset * fix static markdown * lint * line breaks * fixes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * chore: update versions (#5742) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * add label to changeset pr (#5772) * Always deploy to spaces (#5777) * Lite: Websocket queueing (#5124) * Create a Wasm-emulated WebSocket connection and fix @gradio/client to inject it * Explicitly set the default response class for the Wasm mode * add changeset * Fix is_self_origin() to compare only hosts and rename it to is_self_host() * Fix Blocks.close() to cancel async tasks in the case of Wasm and call it from wasm_utils.register_app() to dispose an old app instance * Update comment * Hold the asyncio.Task objects and cancel them at `Blocks.close()` * Add try-except to handle the case where `events` is not set to `queue.active_jobs` when `queue.process_events` is called * Format queueing.py --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * fix pending chatbot message styling and ensure messages with value `None` don't render (#5775) * fix pending chatbot message styling * border fixes * add changeset * add changeset * ensure null messages arent shown * add hide css again * render loading inside message + add test * fix test * add changeset * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * change minor to patch (#5793) * chore: update versions (#5786) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Adds `change()` event to `gr.Gallery` (#5780) * add change event to gallery * revert * format * add changeset * lint * add tests * lint --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Throw helpful error when media devices are not found (#5794) * add test * add changeset * tweak copy * error logic * add changeset * copy tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * ensure the client does not depend on `window` when running in a node environment (#5787) * modify url_params * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Add component <-> server direct communication support, as well as a "file explorer" component (#5672) * changes * changes * add changeset * add changeset * Server fns ext (#5760) * start changes * changes * changes * fix arrows * add changeset * rename demo * fix some ci * add changeset * add changeset * fix * remove configs * fix * fix * add changeset * fixes * linting * Update gradio/components/file_explorer.py * notebook * typing * tweaks * fixed class method problem * fix test * file explorer * gr.load * format * tweaks * fix * fix * fix * fix * final tweaks + changelog * changelog * changelog * changelog * lint --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Update `CONTRIBUTING.md` (#5799) * updates * tweak * tweaks * tweaks * add troubleshooting * storybook tweak * add review changes * fe tweak * Revert replica proxy logic and instead implement using the `root` variable (#5776) * Revert "Fix for deepcopy errors when running the replica-related logic on Spaces (#5722)" This reverts commit dba6519. * Revert "Fully resolve generated filepaths when running on Hugging Face Spaces with multiple replicas (#5668)" This reverts commit d626c21. * add changeset * Trigger local * add changeset * add to root * add changeset * strip url * resolve root * changes * fix * format * logs * format * add changeset * reverse order --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Prevent bokeh from injecting bokeh js multiple times (#5795) * remove dep line in demo * linting * linting * fix * merge * add changeset * lint * notebook: --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Adds the ability to set the `selected_index` in a `gr.Gallery` (#5783) * selected_index * Gallery * changes * modify * add changeset * fix select issue --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * added try except block in `state.py` (#5790) * added try except block in `state.py` added try except block in `state.py` which will raise a "ValueError" * add changeset * updated `state.py` and added test for deepcopy updated `state.py` and added test for deepcopy named test_initial_value_deepcopy in `test/test_components.py` * lint * test fix * explain test --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Fix `gr.SelectData` so that the target attribute is correctly attached, and the filedata is included in the data attribute with `gr.Gallery` (#5798) * fix select * add changeset * add changeset * restore * refactor * add pytest * typo --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * docs: fix website directory in CONTRIBUTING.md (#5810) * chore: update versions (#5796) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix calls to the component server so that `gr.FileExplorer` works on Spaces (#5816) * changes * add changeset * changes * demo * file explorer * lint * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * chore: update versions (#5817) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Lite: Fix Examples.create() to be a normal func so it can be called in the Wasm env (#5821) * Fix Examples.create() to be a normal func so it can be called in the Wasm env * add changeset * Add a comment line --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Convert async methods in the Examples class into normal sync methods (#5822) * Convert async methods in the Examples class into normal sync methods * add changeset * Fix test/test_chat_interface.py * Fix test/test_helpers.py * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Quick fix: Chatbot change event (#5827) * fix * add changeset * add dequal to dependency * package * lint --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Assert refactor in external.py (#5811) * Refactored assert statements to if statements * format-addons * format * add changeset * Update gradio/external.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * refactored video.py * refactored all the assert statements with response * add changeset * add changeset * Apply suggestions from code review * Refactored documentation.py and few more files * avoid circular * Replaced all assert statements * lint * notebooks * fix * minor changes * final changes according to tests * Lint * last fix * fix * fix utils test * fix serialization error * fix serialization error --------- Co-authored-by: harry-urek <hariombhardwaj038@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Fix error when scrolling dropdown with scrollbar (#5839) * Fix error when scrolling dropdown with scrollbar * added comment * add changeset --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Mention that audio is normalized when converting to wav in docs (#5835) * Mention that audio is normalized when converting to wav in docs * add changeset --------- Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Add support for gr.Request to gr.ChatInterface (#5819) * Add support for gr.Request to gr.ChatInterface * add changeset * gr.ChatInterface: loose check for gr.Request * add request test * update test and chat_interface * chat interface * fix test * formatting * fixes * fix examples and add test * remove .update usage * revert interface changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add code * lint * Lint * Radio --------- Co-authored-by: Hannah <hannahblair@users.noreply.github.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Freckles <hellofreckles@163.com> Co-authored-by: aliabid94 <aabid94@gmail.com> Co-authored-by: Dawood Khan <dawoodkhan82@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com> Co-authored-by: aliabd <ali.si3luwa@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: D V <77478658+DarhkVoyd@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@hotmail.co.uk> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Charles Bensimon <charles@huggingface.co> Co-authored-by: ylhsieh <morpheus.h@gmail.com> Co-authored-by: Florian Bruggisser <github@broox.ch> Co-authored-by: gibiee <37574274+gibiee@users.noreply.github.com> Co-authored-by: Srijan Sahay Srivastava <70461251+SrijanSahaySrivastava@users.noreply.github.com> Co-authored-by: Regina Reynolds <regina.c.reynolds@gmail.com> Co-authored-by: Hari Om Bhardwaj <94731227+harry-urek@users.noreply.github.com> Co-authored-by: harry-urek <hariombhardwaj038@gmail.com> Co-authored-by: Kit PANG <pangkit888@gmail.com> Co-authored-by: Aileen Villanueva Lecuona <aileenvl@gmail.com>
Description
The queueing module in Python uses in-server HTTP communications but it doesn't work on the Gradio-lite's architecture, so this PR also includes the changes on it (67c432d is it for now, while it might be replaced with better solution).Probably we should extract only these changes on the Python part to another PR.🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh