Skip to content
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

Add support for async generators #3821

Merged
merged 16 commits into from May 9, 2023
Merged

Add support for async generators #3821

merged 16 commits into from May 9, 2023

Conversation

freddyaboulton
Copy link
Collaborator

@freddyaboulton freddyaboulton commented Apr 11, 2023

Description

Closes: #3618 . @deep-diver would appreciate if you could test this to see if it fixes your issue. Click on the link on the gradio-pr-bot message, Go to Files in the top right, requirements.txt will have a url hosting a wheel built for this PR.

To test

Blocks case

import asyncio
import gradio as gr
import time


async def async_iteration(count: int):
    for i in range(count):
        yield i
        await asyncio.sleep(1)


def iteration(count: int):
    for i in range(count):
        yield i
        time.sleep(1)


with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            num1 = gr.Number(value=4, precision=0)
            o1 = gr.Number()
            async_iterate = gr.Button(value="Async Iteration")
            async_iterate.click(async_iteration, num1, o1)
        with gr.Column():
            num2 = gr.Number(value=4, precision=0)
            o2 = gr.Number()
            iterate = gr.Button(value="Iterate")
            iterate.click(iteration, num2, o2)

demo.queue(concurrency_count=20).launch()

Interface case

app1 = gr.Interface(async_iteration, gr.Number(precision=0, value=4), gr.Number())
app2 = gr.Interface(iteration, gr.Number(precision=0, value=4), gr.Number())

with gr.Blocks() as demo:
    with gr.Row():
        app1.render()
    with gr.Row():
        app2.render()

demo.queue(concurrency_count=20).launch()

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3821-all-demos

@deep-diver
Copy link

Thanks for doing this @freddyaboulton! I will test and get back as soon as possible!

@freddyaboulton
Copy link
Collaborator Author

Just checking in @deep-diver :)

@davidrios
Copy link

davidrios commented May 1, 2023

I can confirm this works. Here's my app using it: https://github.com/davidrios/speech2text-server, the response comes streaming when using this branch.
But I wasn't able to catch the stop action from the form. Do you know how to do that in this case?

@freddyaboulton
Copy link
Collaborator Author

Thanks for testing and verifying it works! Can you elaborate a bit more on what you couldn't do @davidrios ?

@davidrios
Copy link

davidrios commented May 1, 2023

Oh, sure. The Gradio form has a Submit button, when the user clicks it the process starts and the results come streaming, meanwhile the Submit turns to a Stop button. I would like to catch that Stop action to stop the underlying processing, because it's a heavy process running in another thread. Right now when I click the Stop button, in the UI it seems like it stopped, but nothing happens in my code and the processing keeps going until the end. Some times when I click submit again it just continues from where it left off and some times it really stops but I get this in the log:

INFO:     127.0.0.1:52450 - "POST /api/predict HTTP/1.1" 200 OK
Executing <Task finished name='Task-51' coro=<RequestResponseCycle.run_asgi() done, defined at /home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:433> result=None created at /home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:312> took 0.984 seconds
/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/gradio/processing_utils.py:180: UserWarning: Trying to convert audio automatically from int32 to 16-bit int format.
  warnings.warn(warning.format(data.dtype))
INFO:     127.0.0.1:52450 - "POST /api/predict HTTP/1.1" 200 OK
Executing <Task finished name='Task-53' coro=<RequestResponseCycle.run_asgi() done, defined at /home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:433> result=None created at /home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:312> took 0.948 seconds
/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/gradio/processing_utils.py:180: UserWarning: Trying to convert audio automatically from int32 to 16-bit int format.
  warnings.warn(warning.format(data.dtype))
INFO:     127.0.0.1:52450 - "POST /api/predict HTTP/1.1" 200 OK
Executing <Task finished name='Task-55' coro=<RequestResponseCycle.run_asgi() done, defined at /home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:433> result=None created at /home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:312> took 0.979 seconds
INFO:     127.0.0.1:47866 - "POST /run/predict HTTP/1.1" 200 OK
INFO:     127.0.0.1:52450 - "POST /reset HTTP/1.1" 200 OK
Task exception was never retrieved
future: <Task finished name='Task-60' coro=<<async_generator_athrow without __name__>()> exception=RuntimeError('async generator ignored GeneratorExit') created at /usr/lib/python3.11/asyncio/runners.py:118>
source_traceback: Object created at (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.11/multiprocessing/spawn.py", line 120, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/usr/lib/python3.11/multiprocessing/spawn.py", line 133, in _main
    return self._bootstrap(parent_sentinel)
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
    target(sockets=sockets)
  File "/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
RuntimeError: async generator ignored GeneratorExit
INFO:     127.0.0.1:47876 - "POST /run/predict HTTP/1.1" 200 OK

Also, if I try to stop the server, it stops fine if I have never clicked Stop, but after that it goes:

^CINFO:     Shutting down
INFO:     Waiting for background tasks to complete. (CTRL+C to force quit)

But it never stops and if I force:

.... lots of lines
  File "/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 289, in app
    await dependant.call(**values)
  File "/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/gradio/routes.py", line 535, in join_queue
    await asyncio.sleep(1)
  File "/usr/lib/python3.11/asyncio/tasks.py", line 639, in sleep
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

... lots of lines
ERROR:    Traceback (most recent call last):
  File "/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/starlette/routing.py", line 686, in lifespan
    await receive()
  File "/home/david/work/speech2text/server/.venv/lib/python3.11/site-packages/uvicorn/lifespan/on.py", line 139, in receive
    return await self.receive_queue.get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/queues.py", line 158, in get
    await getter
asyncio.exceptions.CancelledError

@davidrios
Copy link

So, after improving the robustness of my code and adding a lot of logging, I'm almost certain the issue is that my async generator passed to Gradio is never cancelled or awaited when I click the Stop button. Something inside Gradio stops but it doesn't clean up the generator, so I can't run my clean up code either.

@davidrios
Copy link

davidrios commented May 1, 2023

Here's a minimal example to reproduce the issue:

import asyncio

import gradio as gr

execution = 0


async def gradio_output_iterator(text):
    try:
        output = "* Counting to 30... *\n"
        yield output
        for i in range(1, 31):
            await asyncio.sleep(1)
            output += f"{i}... "
            yield output
            if i % 10 == 0:
                output += "\n"
                yield output
        output += "\ndone!"
        yield output
    finally:
        global execution
        execution += 1
        print(
            f"*** {execution} finished gradio output. this should appear in the log "
            "when the user clicks Stop or the counter finishes"
        )


demo = gr.Interface(
    gradio_output_iterator,
    inputs=[
        gr.Text(info="no need to put anything"),
    ],
    outputs=gr.Text(label="Results"),
    allow_flagging="never",
)

demo.queue(concurrency_count=20).launch()

@@ -396,69 +396,6 @@ def test_mount_gradio_app_raises_error_if_event_queued_but_queue_disabled(self):
demo.close()


class TestGeneratorRoutes:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored this test to use a websocket connection

{"__type__": "generic_update"} for _ in self.output_components
] + [Button.update(visible=True), Button.update(visible=False)]

pred.then(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the Interface cancel button to use then as opposed to a finally block. Helps prevent the issues with the generator not being cleaned up

@@ -609,27 +617,25 @@ def attach_submit_events(self, submit_btn: Button | None, stop_btn: Button | Non
if stop_btn:

# Wrap the original function to show/hide the "Stop" button
def fn(*args):
async def fn(*args):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to wrap an sync iterator into an async one so that we can have one api for yielding outputs from the iterator

@freddyaboulton
Copy link
Collaborator Author

Think I figured out the issue @davidrios - the finally block in your repro prints for me and there are no scary warnings printed to the console. Thanks for the help!

async_iterator

@freddyaboulton freddyaboulton marked this pull request as ready for review May 4, 2023 20:30
@abidlabs
Copy link
Member

abidlabs commented May 7, 2023

Elegant solution @freddyaboulton! I was able to fine just one edge case where it seems to get stuck, which is when the async generator is started and stopped, then the sync generator is started and stopped, and and then the async generator is started and stopped Interface example. In the frontend, I get this error:

runtime.esm.js:1  Uncaught (in promise) TypeError: Cannot read properties of null (reading 'id')
    at Array.Wl (runtime.esm.js:1:5521)
    at Object.p (Button.svelte:24:3)
    at Vt (index.mjs:100:14)
    at Object.p (Button.svelte:25:9)
    at Mn (index.mjs:1273:36)
    at en (index.mjs:1233:17)

I think that even though the async generator is stopped, the frontend still expects some payload returned? Here's a GIF showing the behavior happening:

Recording 2023-05-07 at 11 13 29 (1)

To reproduce, run:

import asyncio
import gradio as gr
import time


async def async_iteration(count: int):
    for i in range(count):
        yield i
        await asyncio.sleep(1)


def iteration(count: int):
    for i in range(count):
        yield i
        time.sleep(1)


app1 = gr.Interface(async_iteration, gr.Number(precision=0, value=4), gr.Number())
app2 = gr.Interface(iteration, gr.Number(precision=0, value=4), gr.Number())

with gr.Blocks() as demo:
    with gr.Row():
        app1.render()
    with gr.Row():
        app2.render()

demo.queue(concurrency_count=20).launch()

Then:

  • Start the async Interface and stop it before prediction is complete
  • Start the sync Interface and stop it before prediction is complete
  • Start the async Interface and stop it before prediction is complete --> error is thrown

It's definitely an edge case, but it's happening consistently so might be worth investigating if there's a deeper issue here?

@freddyaboulton
Copy link
Collaborator Author

@abidlabs Thanks for the review! The app was crashing because we were retuning None as the value of the stop button. This was because we were also returning update values for the buttons from the prediction function. Long story short, I refactored the submit -> stop -> submit button update flow to use then api entirely. This is much nicer, as the generator no longer outputs values for the buttons so view_api for the client is much nicer. The one downside is that because of #4113, if the generator fails the stop button won't get converted back to submit button. The user can click the stop button again to "reset" it though. This is a pre-existing bug so I'm ok merging this in but we can also fix #4113 beforehand as not changing the stop button back is technically a change of behavior.

Also, there can still be a weird race condition if you stop and start separate iterators in the example you tried. The app will not crash however.

async_iteration_debug

@aliabid94
Copy link
Collaborator

Working on fixing #4113 now

@abidlabs
Copy link
Member

abidlabs commented May 9, 2023

Looks great!! Thanks @freddyaboulton for the great PR and @aliabid94 for the quick fix for .then(). Merging in

@abidlabs abidlabs merged commit 96c17a7 into main May 9, 2023
15 of 19 checks passed
@abidlabs abidlabs deleted the 3618-async-generator branch May 9, 2023 04:21
@deepankarm
Copy link

Do we know when is the next release planned with this PR?

@freddyaboulton
Copy link
Collaborator Author

@deepankarm This got released yesterday with gradio 3.29.0!

dawoodkhan82 pushed a commit that referenced this pull request Jun 2, 2023
* Add impl + unit test

* CHANGELOG

* Lint

* Type check

* Remove print

* Fix tests

* revert change

* Lint

* formatting

* Fix test

* Lint

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abid <aabid94@gmail.com>
dawoodkhan82 added a commit that referenced this pull request Jun 11, 2023
* Add min max handling for Number (#3871)

* feat: add min max handling for Number

* Update CHANGELOG.md

* fix: Error when min or max is not specified

* fix formatting

* fix: error when nothing is specified

* Just put infinity in min and max

---------

Co-authored-by: Dawood Khan <dawoodkhan82@gmail.com>

* number limit

* Update gradio/components.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* New Version Docs (#4027)

* [create-pull-request] automated change

* Trigger Build

---------

Co-authored-by: aliabd <aliabd@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>

* Safer `HuggingFaceDatasetSaver` (and deprecate `HuggingFaceDatasetJsonSaver`) (#3973)

* Draft for a safer HuggingFaceDatasetSaver

* Rename (and replace) gr.SaferHuggingFaceDatasetSaver as gr.HuggingFaceDatasetSaver

* update changelog

* ruff

* doc

* tmp work

* merge 2 classes

* remove useless code

* adapt tests

* Update gradio/flagging.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update CHANGELOG.md

* fix typing

* code formatting

* removed print from tests

* removing imports

* removing imports

* fix paths

* formatting

* wording

* formating

* fix tests

---------

Co-authored-by: testbot <lucainp@hf.co>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* merge

* Allow state to be rendered multiple times (#4030)

* state render

* add test

* formatting

* changelog

* Allow decoding b64 string without header in processing utils (#4031)

* allow decoding b64 string without headers

* install gradio-client in edittable mode

* update GH actions

* add test for decoding headerless b64

* add test for decoding headerless b64 image

* some linting

* fix test

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Sets matplotlib backend to agg before rendering math (#4029)

* matplotlib-agg

* fix

* context manager

* Update CHANGELOG.md

* update demos

* linting

* removed warning

* fix test

* fixes

* fix tests

* Upgrade pyright to 1.1.305 (#4042)

* Fastapi Python Client Guide (#3892)

* fastapi guide

* changelog

* writing

* finish guide

* fix

* Update guides/06_client-libraries/fastapi-app-with-the-gradio-client.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/06_client-libraries/fastapi-app-with-the-gradio-client.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/06_client-libraries/fastapi-app-with-the-gradio-client.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Update guides/06_client-libraries/fastapi-app-with-the-gradio-client.md

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* dependencies

* html

---------

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* fix overflowing gutter and dark mode base color (#4051)

* Add ability to blocklist filepaths, ability to specify where gradio temp files are created (#4047)

* temporary file

* tests

* formatting

* rename

* added another test

* guide

* formatting

* changelog

* added custom gradio temp directory (#4053)

* added custom gradio temp directory

* Update 03_sharing-your-app.md

* rename test

* address review

* remove print

* Chatbot code syntax highlighting (#4048)

* first pass

* fixes

* more fixes

* remove breaks

* format

* version

* pr fixes

* changelog

* test fix

* background color

* format

* revert test fix

* changes

* changes

* test

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abid <aabid94@gmail.com>

* Fixes issue with indentation in code field with streaming (#4043)

* indent fix

* fix

* changelog

* fix overflowing gutter and dark mode base color (#4051)

* Add ability to blocklist filepaths, ability to specify where gradio temp files are created (#4047)

* temporary file

* tests

* formatting

* rename

* added another test

* guide

* formatting

* changelog

* added custom gradio temp directory (#4053)

* added custom gradio temp directory

* Update 03_sharing-your-app.md

* rename test

* address review

* remove print

* Chatbot code syntax highlighting (#4048)

* first pass

* fixes

* more fixes

* remove breaks

* format

* version

* pr fixes

* changelog

* test fix

* background color

* format

* revert test fix

* changes

* changes

* test

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abid <aabid94@gmail.com>

* fix

* fix test

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Ali Abid <aabid94@gmail.com>

* [create-pull-request] automated change (#4059)

Co-authored-by: aliabid94 <aliabid94@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changelog (#4064)

* New Version Docs (#4069)

* [create-pull-request] automated change

* Trigger Build

---------

Co-authored-by: aliabd <aliabd@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>

* Soft theme fix (#4070)

* fix

* fix

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Empty gallery fix (#4072)

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix bug where functions with type hints caused errors (#4068)

* Fix + test

* CHANGELOG

* Update test/test_utils.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/utils.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* More Ruff rules (#4038)

* Bump ruff to 0.0.264

* Enable Ruff Naming rules and fix most errors

* Move `clean_html` to utils (to fix an N lint error)

* Changelog

* Clean up possibly leaking file handles

* Enable and autofix Ruff SIM

* Fix remaining Ruff SIMs

* Enable and autofix Ruff UP issues

* Fix misordered import from #4048

* Fix bare except from #4048

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* [WIP] Language Agnostic Typing in `/info` route (#4039)

* First commit

* All serializers

* Remove output type

* Add route

* Format json

* Modify dropdown and slider choices

* Fix impl

* Lint

* Add tests

* Fix lint

* remove breakpoint

* Tests passing locally

* Format code

* Address comments

* Use union + fix tests

* handle multiple file case

* Add serializer to info payload

* lint

* Add to CHANGELOG

* grc version

* requirements

* fix test

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Keep hidden Accordion content in DOM (#4073)

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Theme builder fixes (#4080)

* theme-builder-fixes

* theme-builder-fixes

* fix expand issue

* changes

* Update gradio/themes/builder_app.py

* changelog

---------

Co-authored-by: Ali Abid <aabid94@gmail.com>

* Misc file and docs fixes (#4086)

* uvicorn version

* uvicorn version

* changes

* guides

* guide

* changelog

* typo

* typo

* Update guides/04_integrating-other-frameworks/01_using-hugging-face-integrations.md

* chinese lang

* rename

* Update guides/04_integrating-other-frameworks/01_using-hugging-face-integrations.md

* Update guides/03_building-with-blocks/04_custom-CSS-and-JS.md

Co-authored-by: aliabid94 <aabid94@gmail.com>

* address review

* simplify section

---------

Co-authored-by: aliabid94 <aabid94@gmail.com>

* Removing "State" from view API info (#4107)

* wip pr

* update client version

* update space fetcher

* changelog, workflow

* fix not flaky tests

* lint

* v2

* Dont send request to `/info` if version before 3.28.3 (#4109)

* Add code

* Lint

* CHANGELOG

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Upload audio ios (#4071)

* changes

* changes

* change

* changes

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Allow textbox / number submits to trigger Interface submit (#4090)

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix slider released event not triggering when released on mobile (#4098)

* Fix slider released event not triggering when released on mobile

* Update CHANGELOG

* fix range test

* retrigger

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix then logic to work after failures (#4115)

* change

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fixes to view API page (#4112)

* logo

* fix for new info and logo path

* changelog

* remove example_input from returns

---------

Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* Add support for async generators (#3821)

* Add impl + unit test

* CHANGELOG

* Lint

* Type check

* Remove print

* Fix tests

* revert change

* Lint

* formatting

* Fix test

* Lint

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abid <aabid94@gmail.com>

* release (#4116)

* Bumpt client version (#4125)

* New Version Docs (#4131)

* [create-pull-request] automated change

* Trigger Build

---------

Co-authored-by: aliabd <aliabd@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>

* Fix create version docs action (#4130)

* define version instead of upgrading

* add sleep

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix dev docs (#4132)

* Move .config/README.md to js/README.md

* Link js/README.md from CONTRIBUTING.md

* Update CHANGELOG.md

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changelog (#4136)

* Fix website build issue (#4142)

* upgrade pnpm

* changelgo

* Fix python client test (#4138)

* Fix python client test

* CHANGELOG

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix isssue with running with nginx (#4133)

* nginx-root

* fix

* ability to set root path

* removed root

* removed root

* fix

* changelog

* Update gradio/routes.py

Co-authored-by: aliabid94 <aabid94@gmail.com>

* Update gradio/routes.py

Co-authored-by: aliabid94 <aabid94@gmail.com>

---------

Co-authored-by: aliabid94 <aabid94@gmail.com>

* Record username when flagging (#4135)

* record username

* fix

* changelog fix

* format

* fix hf saver

* fix deserialization

* fixes

* Fix api info for File component (#4153)

* Fix output file type info

* Fix example inputs

* CHANGELOG

* Update client

* Add test

* Bump version

* Bump min client version

* Update .prettierignore adding client/js/dist and .venv (#4160)

* Fix the prettier.ignorePath field in the VSCode workspace settings (#4164)

Co-authored-by: pngwn <hello@pngwn.io>

* simplify format of changelog (#4163)

* Fix the wildcard in .editorconfig to match files in nested directories (#4165)

* Fix the wildcard in .editorconfig to match files in nested directories

* Remove a wrong whitespace in a brace expansion notation in .editorconfig

---------

Co-authored-by: pngwn <hello@pngwn.io>

* Fix flaky interface test (#4168)

* Fix test

* Lint

* Fix vs code lint

* Adds missing components to gradio client serializing's component mapping (#4167)

* add missing serialization

* format

* update release note format

* update release note format

* fix test

* Release 3.30 (#4166)

* release

* requirements

* [Docs] Resolve numerous typos (#4170)

* Resolve numerous typos

* Delete test.py

* Run generate_notebooks

* notebooks

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* New Version Docs (#4172)

* [create-pull-request] automated change

* Update v3.30.0_template.html

---------

Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Dispatch dropdown change on value change for any reason (#4128)

* changes

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* hotfix for test (#4173)

* hotfix for test

* removed comment

* 3712 js client (#3899)

* update ci (#4184)

* bump client version (#4185)

* bump client version

* ignore spaces-test

* Fix (#4186)

* bump client version

* ignore spaces-test

* fix

* update token for npm action (#4187)

* change (#4189)

* ci typo (#4190)

* Fix npm publish again again (#4191)

* ci typo

* fix

* Fix npm publish again again (#4192)

* ci typo

* fix

* again

* Fix npm publish again again (#4193)

* ci typo

* fix

* again

* again

* Add format argument to Audio (#4178)

* experimental

* Add test

* Rename to format

* Rename

* CHANGELOG

* Add to docstring

* Update gradio/components.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* chore: update versions (#4188)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix npm publish again again (#4195)

* ci typo

* fix

* again

* again

* again

* client docs tweaks (#4196)

* ci typo

* fix

* again

* again

* again

* ignore workbench

* small tweaks for publish + docs

* Fix "TypeError: issubclass() arg 1 must be a class" When Optional args  (#4200)

* fix "issubclass() arg 1 must be a class" when args is Optional

* Update CHANGELOG.md

add fix "TypeError: issubclass() arg 1 must be a class" when use Optional args

* Update gradio/helpers.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* changelog

* formatting

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Aarni Koskela <akx@iki.fi>

* Fix semiver import (#4201)

* fix token (#4208)

* fix token

* add label

* Fix Explanation Regarding NumPy Image Component (#4204)

* 20230513 swap np height and width in docs

* changelog

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Correct stacklevel for check_deprecated_parameters (#4203)

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Programmatically launch reload to allow factories and arguments to be passed to the app (#4119)

* Programmatically lauch reload to allow factories and arguments to be passed to the app

* add warning

* modify warning

* guide fixes

* formatting

* changes

* warning

* import fix

* fix tests

* fix tests

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update CONTRIBUTING.md (#4220)

* Input listener (#4157)

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* chnages

* fix

* changes

* changes

* merge

* changes

* restore

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Do not do any analytics requests if analytics are disabled (#4194)

* Move analytics-related bits to gradio.analytics

* Do not do any analytics requests if analytics are disabled

* Remove unused log_feature_analytics

* removed redundant analytics, rewrote

* renamed

* save

* fixed test'

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Increase websocket messaging timeout (#4235)

* increase websocket timeout

* changelog

* Fix for `typing.get_type_hints()` on Python 3.9 or lower (#4228)

* fix

* fix docstring

* type hint fix

* fix test

* Update gradio/utils.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* fix indentation

---------

Co-authored-by: Aarni Koskela <akx@iki.fi>

* Some tweaks to the Client (#4230)

* parameter names

* tweaks

* separate out serialize

* fix

* changelog

* fix

* fix

* improve test

* Only allow messaging update if analytics is enabled (#4236)

* Only allow messaging update if analytics are allowed

Follows up on #4194

* Remove duplicate changelog entry

* remove circular import

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix client filepaths (#4202)

* transform returned paths to useful URLs

* changeset

* update app

* revert

* revert

* changelog

* Update client/js/src/client.ts

Co-authored-by: aliabid94 <aabid94@gmail.com>

* format

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: aliabid94 <aabid94@gmail.com>

* fix cancels (#4225)

* fix cancels

* changelog

* refactor to make it work

* chore: update versions (#4207)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix publish (#4240)

* fix npm publish

* fix npm publish

* release (#4219)

Co-authored-by: pngwn <hello@pngwn.io>

* Fixes chatbot_dialogpt demo (#4238)

* demo fix

* changelog

* fix

* demo

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix JSONDecodeError (#4241)

* Fix JSONDecodeError bug (#4237)

* Remove unused import

* Clean up code

* Fix JSONDecodeError (#4241)

* Accept all Exceptions

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* make workbench private (#4247)

* Refactoring (#4223)

* Replace var with const in js/app/src/main.ts

* Remove unnecessary nullish coalescing in js/app/src/main.ts

* Remove unnecessary white spaces in the NPM scripts in js/app/package.json

* Use object key-value shorthand

* changelog

---------

Co-authored-by: pngwn <hello@pngwn.io>

* Move mount_css() from main.ts to css.ts (#4222)

* Move mount_css() from main.ts to css.ts because these is a circular dependency between main.ts and Index.svelte (and it will help the development of the Wasm ver in the future)

* changelog

---------

Co-authored-by: pngwn <hello@pngwn.io>

* [create-pull-request] automated change (#4250)

Co-authored-by: aliabd <aliabd@users.noreply.github.com>

* Fix run on click (#4258)

* fix run on click

* changelog

* Upgrade black to 23.3 (#4259)

* Upgrade black

* Conservatively upgrade packaging too since it's black's dependency

* Using marked for chatbot markdown parsing (#4150)

* fix info request in js client (#4271)

* fix info request in js client

* changelog

* Temp file fixes (#4256)

* Fix bug

* Linting

* CHANGELOG

* Add tests

* Update test

* Fix remaining components + add tests

* Fix tests

* Fix tests

* Address comments

* Ensure error modal display as expected when using the queue (#4273)

* Allow passing FastAPI app options (#4282)

* App: don't force docs_url and redoc_url to None

* App.create_app: allow passing in app_kwargs

* start_server + launch: allow passing in app_kwargs

* Changelog

* Apply suggestions from code review

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Use .launch for tests

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Katex support in chatbot (#4285)

* katex

* katex support

* changelog

* fixes

* pr fixes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Release 3.32.0 (#4293)

* release 3.32.0

* changelog

* New Version Docs (#4296)

* [create-pull-request] automated change

* Update v3.32.0_template.html

---------

Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Add overridden type annotations on `normalise_file()` to remove @TS-i… (#4315)

* Add overridden type annotations on `normalise_file()` to remove @ts-ignore, and remove its unnecessary export

* changeset

---------

Co-authored-by: pngwn <hello@pngwn.io>

* typo (minor): extra newline puts the documentation of colums to grid (#4337)

* typo (minor): extra newline puts the documentation of colums to grid

* edited changelog

* changelog

---------

Co-authored-by: thiswillbeyourgithub <github@32mail.33mail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* return a Dependency instance from Blocks.load event listener (#4304)

* return a Dependency instance from Blocks.load event listener

* a test case for chaining then from load event

* update CHANGELOG

* add test for load.then with blocks re-used

* fixes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix typo in client/js/README.md (#4310)

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* chore: update versions (#4283)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Optimize frontend's is_dep calls (#4334)

* Optimize is_dep (36 to 12 msec)

* Call is_dep less (12 msec to 9 msec)

* Changelog

---------

Co-authored-by: pngwn <hello@pngwn.io>

* various client refactors + tweaks (#4357)

* changeset

* Add a type annotation on the `api` variable to which the return value of `view_config()` is assigned, and update the type annotation and exception handling on `view_config` as well (#4311)

* Remove unnecessary @ts-ignore (#4314)

* Remove unnecessary Promise wrapping another promise (#4313)

* Remove unnecessary Promise wrapping another promise

* Remove an error handeler that may remove detailed error stacks

* changeset

* remove changeset

---------

Co-authored-by: pngwn <hello@pngwn.io>

* Stop using `let` for unchanged variables in `client.ts` (#4312)

* Stop using `let` for unchanged variables in `client.ts`

* fixes

---------

Co-authored-by: pngwn <hello@pngwn.io>

---------

Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>

* Remove a bunch of unused frontend code (#4275)

Co-authored-by: pngwn <hello@pngwn.io>

* Respect `interactive=True` in output of `gr.Interface` (#4356)

* tests

* changelog

* lint

* Update gradio/interface.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* format

---------

Co-authored-by: Aarni Koskela <akx@iki.fi>

* Don't allow dotfiles for /file= route (#4303)

* Don't allow dotfiles or files in "dot directories" for /file=

* update guide

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Push to spaces (#4033)

* changes

* first commit

* Update gradio/upload.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* Update gradio/upload.py

Co-authored-by: Aarni Koskela <akx@iki.fi>

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* chnages

* changes

* changes

* changes

* changes

* Update 03_sharing-your-app.md

* changes

* changes

* change

* changes

* changes

* changes

* Update gradio/deploy_space.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

* changes

* changes

---------

Co-authored-by: Aarni Koskela <akx@iki.fi>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Do not send HF token to other domains via `/proxy` (#4368)

* test

* fix

* changelog

* fix, add warnings

* Make chatbot input fields non-interactive while bot is streaming (#4363)

* Add demo impl

* trigger then if generating

* remove unused value

* CHANGELOG

* Fix code

* Update guide

* Update guides/07_other-tutorials/creating-a-chatbot.md

Co-authored-by: pngwn <hello@pngwn.io>

---------

Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Prevent path traversal in `/file` routes (#4370)

* add tests

* add tests

* file route fix

* update tests

* formatting

* file access

* cleanup

* cleaning

* fix tests

* Favicon fix for Windows (#4369)

* favicon fix

* changelog

* svg

* remove favicon

* actual fix

* Add pypi classifiers to pyproject.toml (#4383)

* Add pypi classifiers to pyproject.toml

* Add OS classifier

---------

Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>

* Use DOMPurify to sanitize html in chatbot (#4360)

* dompurify

* changelog

* format

* clean

* changelog

* Update run.py

* update happy-dom

---------

Co-authored-by: pngwn <hello@pngwn.io>

* fix copy button invalid & copy button (invisible) duplication bug in chatbot (#4350)

* fix a copy button duplication bug in chatbot

* fix copy button invalid issue

* Update CHANGELOG.md: Fixed Copy Button

* fix changelog typo

* switch to static HTML + event delegation for copy button

* fix

* format + notebooks

* format + notebooks

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: pngwn <hello@pngwn.io>

* release 3.33.0 (#4392)

Co-authored-by: aliabid94 <aabid94@gmail.com>

* Restore offline support (#4398)

* changes

* changes

* changes

* New Version Docs (#4397)

* [create-pull-request] automated change

* Update temporary_template.html

---------

Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix Base parent in Docs, add Group (#4391)

* fix base parent

* add group to docs

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Remove old versioned docs and fix repo classification  (#4362)

* remove old versioned docs

* delete versioned docs when new one is created

* ignore website dir in linguist calc

* upload and download versioned docs

* modify github action

* remove gitattributes file

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update message when share link binary is blocked (#4380)

* update share link message

* address suggestion

* changelog

* fix

* formatting

* Update utils.py for validate_url (#4388)

* Update utils.py for validate_url

AWS s3 presigned url cannot work for both HEAD and GET. So when HEAD the presigned url, it will return 403(Forbidden)

* Update gradio/utils.py

* changelog

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* v3.33.1 + Guide on setting up Gradio behind nginx... (#4379)

* nginx guide

* delete 3.33.0

* version

* unindent

* Prevent label change event from triggering itself (#4371)

* Fix the Node and pnpm setup actions (#4394)

* Run `pnpm i` with pnpm@8.6.0 to re-generate the lock file (#4393)

* fix indent (#4404)

* Throttle scroll event  (#4158)

* Throttle scroll event

This decreases the amount of function calls when scrolling through the documentation website.

* fix themes base

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>

* merge

* fixes

* changes

* more changes

* notebook

* changelog

* error handle backend

* Update gradio/components.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/components.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Adds `variant` and `interactive` props to `gr.UploadButton` (#4436)

* upload button

* fix index

* changelog

* formatting

* cleanup

* fix  get_continuous_fn bug when having every (#4434)

* fix the bug for wrap continuous func with parameter every while origin func return generator

* Update utils.py

* Update CHANGELOG.md

* Update test_utils.py

* Update CHANGELOG.md

* formatting

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix Safari video playback (#4433)

* changes

* changes

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* test fix

* test

* tests

* fix ui test

* format

* Increase version gradio-client version/changelog (#4441)

* Increase version gradio-client version/changelog

* req

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* fixes

* notebook

* fixed tests finally

* format

* python test fix

* test fix

* remove style from test

* Update CHANGELOG.md

* theme test fix

---------

Co-authored-by: Artemy Egorov <artegoser@gmail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: aliabd <aliabd@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>
Co-authored-by: Lucain <lucainp@gmail.com>
Co-authored-by: testbot <lucainp@hf.co>
Co-authored-by: 1lint <105617163+1lint@users.noreply.github.com>
Co-authored-by: Aarni Koskela <akx@iki.fi>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Ali Abid <aabid94@gmail.com>
Co-authored-by: aliabid94 <aliabid94@users.noreply.github.com>
Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
Co-authored-by: space-nuko <24979496+space-nuko@users.noreply.github.com>
Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
Co-authored-by: Tom Aarsen <37621491+tomaarsen@users.noreply.github.com>
Co-authored-by: abidlabs <abidlabs@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: LingFeng.Chen.Cn <lingfeng.chen.cn@gmail.com>
Co-authored-by: Der Chien <b03902015@ntu.edu.tw>
Co-authored-by: Micky Brunetti <micky2be@users.noreply.github.com>
Co-authored-by: David Ai <davidai2018@gmail.com>
Co-authored-by: thiswillbeyourgithub <26625900+thiswillbeyourgithub@users.noreply.github.com>
Co-authored-by: thiswillbeyourgithub <github@32mail.33mail.com>
Co-authored-by: Paul Garner <ego@anentropic.com>
Co-authored-by: WilliamRoyNelson <william.roy.nelson@gmail.com>
Co-authored-by: binary-husky <96192199+binary-husky@users.noreply.github.com>
Co-authored-by: Yan <alvindaiyan@gmail.com>
Co-authored-by: Shavit <shavit@users.noreply.github.com>
Co-authored-by: dkjshk <xie0510@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

async generator support
7 participants