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 Progress Bar component #2750

Merged
merged 80 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
66c9b85
changes
aliabid94 Dec 1, 2022
fd97d93
version
abidlabs Dec 1, 2022
b475014
Merge branch 'main' into progress
abidlabs Dec 1, 2022
b52f921
changes
aliabid94 Dec 13, 2022
7ffcf79
changes
aliabid94 Dec 15, 2022
4e29cf7
fixes
aliabid94 Dec 16, 2022
1bc7788
changes
aliabid94 Dec 20, 2022
9c1ee0d
Merge remote-tracking branch 'origin' into progress
aliabid94 Dec 20, 2022
0f630b8
changes
aliabid94 Dec 20, 2022
10211c3
Merge remote-tracking branch 'origin' into progress
aliabid94 Dec 20, 2022
451050e
changes
aliabid94 Dec 21, 2022
2672e24
changes
aliabid94 Dec 21, 2022
316606f
chagnes
aliabid94 Dec 21, 2022
cec8100
Merge remote-tracking branch 'origin' into progress
aliabid94 Dec 21, 2022
799eeeb
chagnes
aliabid94 Dec 21, 2022
356bb3d
fix
aliabid94 Dec 21, 2022
fd65378
changes
aliabid94 Dec 21, 2022
0dd7a07
changes
aliabid94 Dec 21, 2022
7498c9b
changes
aliabid94 Dec 21, 2022
e6cd154
change
aliabid94 Dec 21, 2022
adc4ba3
changes
aliabid94 Dec 21, 2022
141f1a8
Merge remote-tracking branch 'origin' into progress
aliabid94 Dec 21, 2022
0ee8240
changes
aliabid94 Dec 21, 2022
4d1511e
changes
aliabid94 Dec 21, 2022
684e052
changes
aliabid94 Dec 21, 2022
dd0b78f
changes
aliabid94 Dec 21, 2022
7098773
changes
aliabid94 Dec 21, 2022
763c074
changes
aliabid94 Dec 21, 2022
0a9b830
changes
aliabid94 Dec 21, 2022
1885eb7
changes
aliabid94 Dec 21, 2022
7dc58d5
changes
aliabid94 Dec 21, 2022
7483d96
changes
aliabid94 Dec 21, 2022
96cc934
changes
aliabid94 Dec 21, 2022
d5195be
version update
aliabid94 Dec 21, 2022
f98b799
Commit from GitHub Actions (Upload Python Package)
aliabid94 Dec 21, 2022
0675d7f
merge change
aliabid94 Dec 21, 2022
84d2e57
changes
aliabid94 Dec 21, 2022
ecb871b
changes
aliabid94 Dec 21, 2022
97179af
changes
aliabid94 Dec 21, 2022
053c368
changes
aliabid94 Dec 21, 2022
e19fb20
fix
aliabid94 Dec 21, 2022
234cb72
Merge remote-tracking branch 'origin' into progress
aliabid94 Dec 21, 2022
1331d4f
changes
aliabid94 Dec 21, 2022
3411b15
changes
aliabid94 Dec 21, 2022
510bccc
changes
aliabid94 Dec 21, 2022
3b0b238
Update CHANGELOG.md
aliabid94 Dec 21, 2022
6f5bc0f
Update CHANGELOG.md
aliabid94 Dec 21, 2022
f0c22dc
Update CHANGELOG.md
aliabid94 Dec 21, 2022
3ced7f8
changes
aliabid94 Dec 22, 2022
9f98cea
changes
aliabid94 Dec 28, 2022
efaaa34
changes
aliabid94 Dec 28, 2022
2ce6082
Merge remote-tracking branch 'origin' into progress
aliabid94 Dec 29, 2022
a759178
changes
aliabid94 Dec 29, 2022
14a0df7
changes
aliabid94 Dec 30, 2022
871fadb
change
aliabid94 Dec 30, 2022
58d6dfa
changes
aliabid94 Dec 30, 2022
61a07da
Update guides/01_getting_started/02_key_features.md
aliabid94 Dec 30, 2022
a1f4041
Update gradio/helpers.py
aliabid94 Dec 30, 2022
78e6c31
Update gradio/routes.py
aliabid94 Dec 30, 2022
4c76322
Update gradio/helpers.py
aliabid94 Dec 30, 2022
6fed596
Update guides/01_getting_started/02_key_features.md
aliabid94 Dec 30, 2022
ede2fb2
Update guides/01_getting_started/02_key_features.md
aliabid94 Dec 30, 2022
6c4b7ec
Update demo/progress_simple/run.py
aliabid94 Dec 30, 2022
795e163
Update demo/progress_simple/run.py
aliabid94 Dec 30, 2022
dc26716
Update demo/progress_simple/run.py
aliabid94 Dec 30, 2022
d6ee858
Update website/homepage/src/docs/template.html
aliabid94 Dec 30, 2022
96a8684
Update website/homepage/src/docs/template.html
aliabid94 Dec 30, 2022
fb6f8d7
changes
aliabid94 Dec 30, 2022
48e096f
Merge branch 'progress' of https://github.com/gradio-app/gradio into …
aliabid94 Dec 30, 2022
b5ec46d
changes
aliabid94 Dec 30, 2022
cfd35d2
changes
aliabid94 Dec 30, 2022
2da33db
changes
aliabid94 Dec 30, 2022
b8b4aaa
changes
aliabid94 Dec 30, 2022
8c35a66
changes
aliabid94 Dec 30, 2022
5bc8956
changes
aliabid94 Dec 30, 2022
ce6299a
change
aliabid94 Dec 30, 2022
2bda4e1
changes
aliabid94 Dec 30, 2022
9a86969
changes
aliabid94 Dec 30, 2022
e9ab760
changes
aliabid94 Dec 30, 2022
112ed39
change
aliabid94 Dec 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# Upcoming Release

## New Features:
No changes to highlight.

### Custom Progress Updates

Send custom progress updates by adding a `gr.Progress` argument after the input arguments to any function. Example:

```python
def clean_imgs(text, progress=gr.Progress()):
progress(0.2, message="Collecting Images")
time.sleep(1.5)
progress(0.8, message="Sending Images")
time.sleep(1.5)
return "done"
clean_imgs_btn.click(clean_imgs, text, text2)
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
```

Progress indicator bar by [@aliabid94](https://github.com/aliabid94) in [PR 2750](https://github.com/gradio-app/gradio/pull/2750).


## Bug Fixes:
* Fixed bug where setting `default_enabled=False` made it so that the entire queue did not start by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2876](https://github.com/gradio-app/gradio/pull/2876)
Expand Down
1 change: 1 addition & 0 deletions demo/progress/run.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: progress"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "import tqdm\n", "from datasets import load_dataset\n", "import shutil\n", "from uuid import uuid4\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " text = gr.Textbox()\n", " textb = gr.Textbox()\n", " with gr.Row():\n", " load_set_btn = gr.Button(\"Load Set\")\n", " load_nested_set_btn = gr.Button(\"Load Nested Set\")\n", " load_random_btn = gr.Button(\"Load Random\")\n", " clean_imgs_btn = gr.Button(\"Clean Images\")\n", " wait_btn = gr.Button(\"Wait\")\n", " do_all_btn = gr.Button(\"Do All\")\n", " track_tqdm_btn = gr.Button(\"Bind TQDM\")\n", " bind_internal_tqdm_btn = gr.Button(\"Bind Internal TQDM\")\n", "\n", " text2 = gr.Textbox()\n", "\n", " # track list\n", " def load_set(text, text2, progress=gr.Progress()):\n", " imgs = [None] * 24\n", " for img in progress.track(imgs, desc=\"Loading from list\"):\n", " time.sleep(0.1)\n", " return \"done\"\n", " load_set_btn.click(load_set, [text, textb], text2)\n", "\n", " # track nested list\n", " def load_nested_set(text, text2, progress=gr.Progress()):\n", " imgs = [[None] * 8] * 3\n", " for img_set in progress.track(imgs, desc=\"Nested list\"):\n", " time.sleep(2)\n", " for img in progress.track(img_set, desc=\"inner list\"):\n", " time.sleep(0.1)\n", " return \"done\"\n", " load_nested_set_btn.click(load_nested_set, [text, textb], text2)\n", "\n", " # track iterable of unknown length\n", " def load_random(data, progress=gr.Progress()):\n", " def yielder():\n", " for i in range(0, random.randint(15, 20)):\n", " time.sleep(0.1)\n", " yield None\n", " for img in progress.track(yielder()):\n", " pass\n", " return \"done\"\n", " load_random_btn.click(load_random, {text, textb}, text2)\n", " \n", " # manual progress\n", " def clean_imgs(text, progress=gr.Progress()):\n", " progress(0.2, desc=\"Collecting Images\")\n", " time.sleep(1)\n", " progress(0.5, desc=\"Cleaning Images\")\n", " time.sleep(1.5)\n", " progress(0.8, desc=\"Sending Images\")\n", " time.sleep(1.5)\n", " return \"done\"\n", " clean_imgs_btn.click(clean_imgs, text, text2)\n", "\n", " # no progress\n", " def wait(text):\n", " time.sleep(4)\n", " return \"done\"\n", " wait_btn.click(wait, text, text2)\n", "\n", " # multiple progressions\n", " def do_all(data, progress=gr.Progress()):\n", " load_set(data[text], data[textb], progress)\n", " load_random(data, progress)\n", " clean_imgs(data[text], progress)\n", " progress(None)\n", " wait(text)\n", " return \"done\"\n", " do_all_btn.click(do_all, {text, textb}, text2)\n", "\n", " def track_tqdm(data, progress=gr.Progress(track_tqdm=True)):\n", " for i in tqdm.tqdm(range(5), desc=\"outer\"):\n", " for j in tqdm.tqdm(range(4), desc=\"inner\"):\n", " time.sleep(1)\n", " return \"done\"\n", " track_tqdm_btn.click(track_tqdm, {text, textb}, text2)\n", "\n", " def bind_internal_tqdm(data, progress=gr.Progress(track_tqdm=True)):\n", " outdir = \"__tmp/\" + str(uuid4())\n", " dataset = load_dataset(\"beans\", split=\"train\", cache_dir=outdir)\n", " shutil.rmtree(outdir)\n", " return \"done\"\n", " bind_internal_tqdm_btn.click(bind_internal_tqdm, {text, textb}, text2)\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.queue(concurrency_count=20).launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
97 changes: 97 additions & 0 deletions demo/progress/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import gradio as gr
import random
import time
import tqdm
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
from datasets import load_dataset
import shutil
from uuid import uuid4

with gr.Blocks() as demo:
with gr.Row():
text = gr.Textbox()
textb = gr.Textbox()
with gr.Row():
load_set_btn = gr.Button("Load Set")
load_nested_set_btn = gr.Button("Load Nested Set")
load_random_btn = gr.Button("Load Random")
clean_imgs_btn = gr.Button("Clean Images")
wait_btn = gr.Button("Wait")
do_all_btn = gr.Button("Do All")
track_tqdm_btn = gr.Button("Bind TQDM")
bind_internal_tqdm_btn = gr.Button("Bind Internal TQDM")

text2 = gr.Textbox()

# track list
def load_set(text, text2, progress=gr.Progress()):
imgs = [None] * 24
for img in progress.track(imgs, desc="Loading from list"):
time.sleep(0.1)
return "done"
load_set_btn.click(load_set, [text, textb], text2)

# track nested list
def load_nested_set(text, text2, progress=gr.Progress()):
imgs = [[None] * 8] * 3
for img_set in progress.track(imgs, desc="Nested list"):
time.sleep(2)
for img in progress.track(img_set, desc="inner list"):
time.sleep(0.1)
return "done"
load_nested_set_btn.click(load_nested_set, [text, textb], text2)

# track iterable of unknown length
def load_random(data, progress=gr.Progress()):
def yielder():
for i in range(0, random.randint(15, 20)):
time.sleep(0.1)
yield None
for img in progress.track(yielder()):
pass
return "done"
load_random_btn.click(load_random, {text, textb}, text2)

# manual progress
def clean_imgs(text, progress=gr.Progress()):
progress(0.2, desc="Collecting Images")
time.sleep(1)
progress(0.5, desc="Cleaning Images")
time.sleep(1.5)
progress(0.8, desc="Sending Images")
time.sleep(1.5)
return "done"
clean_imgs_btn.click(clean_imgs, text, text2)

# no progress
def wait(text):
time.sleep(4)
return "done"
wait_btn.click(wait, text, text2)

# multiple progressions
def do_all(data, progress=gr.Progress()):
load_set(data[text], data[textb], progress)
load_random(data, progress)
clean_imgs(data[text], progress)
progress(None)
wait(text)
return "done"
do_all_btn.click(do_all, {text, textb}, text2)

def track_tqdm(data, progress=gr.Progress(track_tqdm=True)):
for i in tqdm.tqdm(range(5), desc="outer"):
for j in tqdm.tqdm(range(4), desc="inner"):
time.sleep(1)
return "done"
track_tqdm_btn.click(track_tqdm, {text, textb}, text2)

def bind_internal_tqdm(data, progress=gr.Progress(track_tqdm=True)):
outdir = "__tmp/" + str(uuid4())
dataset = load_dataset("beans", split="train", cache_dir=outdir)
shutil.rmtree(outdir)
return "done"
bind_internal_tqdm_btn.click(bind_internal_tqdm, {text, textb}, text2)


if __name__ == "__main__":
demo.queue(concurrency_count=20).launch()
1 change: 1 addition & 0 deletions demo/progress_simple/run.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: progress_simple"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import time\n", "\n", "def reverse(word, progress=gr.Progress()):\n", " progress(0, desc=\"Starting\")\n", " time.sleep(1)\n", " new_string = \"\"\n", " for letter in progress.track(word, desc=\"Reversing\"):\n", " time.sleep(0.25)\n", " new_string = letter + new_string\n", " return new_string\n", "\n", "demo = gr.Interface(reverse, gr.Text(), gr.Text())\n", "\n", "if __name__ == \"__main__\":\n", " demo.queue(concurrency_count=10).launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
16 changes: 16 additions & 0 deletions demo/progress_simple/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import gradio as gr
import time

def reverse(word, progress=gr.Progress()):
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
progress(0, desc="Starting")
time.sleep(1)
new_string = ""
for letter in progress.track(word, desc="Reversing"):
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
time.sleep(0.25)
new_string = letter + new_string
return new_string

demo = gr.Interface(reverse, gr.Text(), gr.Text())
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
demo.queue(concurrency_count=10).launch()
7 changes: 4 additions & 3 deletions gradio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import gradio.outputs as outputs
import gradio.processing_utils
import gradio.templates
from gradio.blocks import Blocks, skip, update
from gradio.blocks import Blocks
from gradio.components import (
HTML,
JSON,
Expand Down Expand Up @@ -49,7 +49,6 @@
Video,
component,
)
from gradio.examples import create_examples as Examples
from gradio.exceptions import Error
from gradio.flagging import (
CSVLogger,
Expand All @@ -58,6 +57,9 @@
HuggingFaceDatasetSaver,
SimpleCSVLogger,
)
from gradio.helpers import Progress
from gradio.helpers import create_examples as Examples
from gradio.helpers import make_waveform, skip, update
from gradio.interface import Interface, TabbedInterface, close_all
from gradio.ipython_ext import load_ipython_extension
from gradio.layouts import Accordion, Box, Column, Group, Row, Tab, TabItem, Tabs
Expand All @@ -79,7 +81,6 @@
TextArea,
Webcam,
)
from gradio.utils import make_waveform

current_pkg_version = pkgutil.get_data(__name__, "version.txt").decode("ascii").strip()
__version__ = current_pkg_version
109 changes: 31 additions & 78 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import random
import sys
import time
import typing
import warnings
import webbrowser
from types import ModuleType
Expand Down Expand Up @@ -44,6 +43,7 @@
from gradio.deprecation import check_deprecated_parameters
from gradio.documentation import document, set_documentation_group
from gradio.exceptions import DuplicateBlockError, InvalidApiName
from gradio.helpers import create_tracker, skip, special_args
from gradio.tunneling import CURRENT_TUNNELS
from gradio.utils import (
TupleNoPrint,
Expand Down Expand Up @@ -354,58 +354,6 @@ def __get__(self, instance, type_):
return descr_get(instance, type_)


set_documentation_group("component-helpers")


@document()
def update(**kwargs) -> dict:
"""
Updates component properties. When a function passed into a Gradio Interface or a Blocks events returns a typical value, it updates the value of the output component. But it is also possible to update the properties of an output component (such as the number of lines of a `Textbox` or the visibility of an `Image`) by returning the component's `update()` function, which takes as parameters any of the constructor parameters for that component.
This is a shorthand for using the update method on a component.
For example, rather than using gr.Number.update(...) you can just use gr.update(...).
Note that your editor's autocompletion will suggest proper parameters
if you use the update method on the component.
Demos: blocks_essay, blocks_update, blocks_essay_update

Parameters:
kwargs: Key-word arguments used to update the component's properties.
Example:
# Blocks Example
import gradio as gr
with gr.Blocks() as demo:
radio = gr.Radio([1, 2, 4], label="Set the value of the number")
number = gr.Number(value=2, interactive=True)
radio.change(fn=lambda value: gr.update(value=value), inputs=radio, outputs=number)
demo.launch()
# Interface example
import gradio as gr
def change_textbox(choice):
if choice == "short":
return gr.Textbox.update(lines=2, visible=True)
elif choice == "long":
return gr.Textbox.update(lines=8, visible=True)
else:
return gr.Textbox.update(visible=False)
gr.Interface(
change_textbox,
gr.Radio(
["short", "long", "none"], label="What kind of essay would you like to write?"
),
gr.Textbox(lines=2),
live=True,
).launch()
"""
kwargs["__type__"] = "generic_update"
return kwargs


set_documentation_group("blocks")


def skip() -> dict:
return update()


def postprocess_update_dict(block: Block, update_dict: Dict, postprocess: bool = True):
"""
Converts a dictionary of updates into a format that can be sent to the frontend.
Expand Down Expand Up @@ -452,23 +400,6 @@ def convert_component_dict_to_list(outputs_ids: List[int], predictions: Dict) ->
return predictions


def add_request_to_inputs(
fn: Callable, inputs: List[Any], request: routes.Request | List[routes.Request]
):
"""
Adds the FastAPI Request object to the inputs of a function if the type of the parameter is FastAPI.Request.
"""
param_names = inspect.getfullargspec(fn)[0]
try:
parameter_types = typing.get_type_hints(fn)
for idx, param_name in enumerate(param_names):
if parameter_types.get(param_name, "") == routes.Request:
inputs.insert(idx, request)
except TypeError: # A TypeError is raised if the function is a partial or other rare cases.
pass
return inputs


@document("load")
class Blocks(BlockContext):
"""
Expand Down Expand Up @@ -831,6 +762,7 @@ async def call_function(
processed_input: List[Any],
iterator: Iterator[Any] | None = None,
request: routes.Request | List[routes.Request] | None = None,
event_id: str | None = None,
):
"""Calls and times function with given index and preprocessed input."""
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
block_fn = self.fns[fn_index]
Expand All @@ -843,18 +775,30 @@ async def call_function(
for input_component, data in zip(block_fn.inputs, processed_input)
}
]
processed_input = add_request_to_inputs(
block_fn.fn, list(processed_input), request

processed_input, _, progress_index = special_args(
block_fn, processed_input, request
)
progress_tracker = (
processed_input[progress_index] if progress_index is not None else None
)

start = time.time()

if iterator is None: # If not a generator function that has already run
if inspect.iscoroutinefunction(block_fn.fn):
prediction = await block_fn.fn(*processed_input)
if progress_tracker is not None:
progress_tracker, fn = create_tracker(
self, event_id, block_fn.fn, progress_tracker.track_tqdm
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
)
processed_input[progress_index] = progress_tracker
else:
fn = block_fn.fn

if inspect.iscoroutinefunction(fn):
prediction = await fn(*processed_input)
else:
prediction = await anyio.to_thread.run_sync(
block_fn.fn, *processed_input, limiter=self.limiter
fn, *processed_input, limiter=self.limiter
)

if inspect.isasyncgenfunction(block_fn.fn):
Expand Down Expand Up @@ -971,6 +915,7 @@ async def process_api(
username: str = None,
state: Dict[int, Any] | List[Dict[int, Any]] | None = None,
iterators: Dict[int, Any] | None = None,
event_id: str | None = None,
) -> Dict[str, Any]:
"""
Processes API calls from the frontend. First preprocesses the data,
Expand Down Expand Up @@ -1004,15 +949,19 @@ async def process_api(
)

inputs = [self.preprocess_data(fn_index, i, state) for i in zip(*inputs)]
result = await self.call_function(fn_index, zip(*inputs), None, request)
result = await self.call_function(
fn_index, zip(*inputs), None, request, event_id
)
preds = result["prediction"]
data = [self.postprocess_data(fn_index, o, state) for o in zip(*preds)]
data = list(zip(*data))
is_generating, iterator = None, None
else:
inputs = self.preprocess_data(fn_index, inputs, state)
iterator = iterators.get(fn_index, None) if iterators else None
result = await self.call_function(fn_index, inputs, iterator, request)
result = await self.call_function(
fn_index, inputs, iterator, request, event_id
)
data = self.postprocess_data(fn_index, result["prediction"], state)
is_generating, iterator = result["is_generating"], result["iterator"]

Expand Down Expand Up @@ -1647,8 +1596,12 @@ def attach_load_events(self):

def startup_events(self):
"""Events that should be run when the app containing this block starts up."""

if self.enable_queue:
utils.run_coro_in_background(self._queue.start)
progress_tracking = any(
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
special_args(block_fn)[2] is not None for block_fn in self.fns
)
utils.run_coro_in_background(self._queue.start, (progress_tracking,))
utils.run_coro_in_background(self.create_limiter)

def queue_enabled_for_fn(self, fn_index: int):
Expand Down
1 change: 1 addition & 0 deletions gradio/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class PredictBody(BaseModel):
session_hash: Optional[str]
event_id: Optional[str]
data: List[Any]
fn_index: Optional[int]
batched: Optional[
Expand Down
5 changes: 3 additions & 2 deletions gradio/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def document_fn(fn: Callable) -> Tuple[str, List[Dict], Dict, Optional[str]]:
if mode == "description":
description.append(line if line.strip() else "<br>")
continue
assert line.startswith(
" "
assert (
line.startswith(" ") or line.strip() == ""
aliabid94 marked this conversation as resolved.
Show resolved Hide resolved
), f"Documentation format for {fn.__name__} has format error in line: {line}"
line = line[4:]
if mode == "parameter":
Expand All @@ -85,6 +85,7 @@ def document_fn(fn: Callable) -> Tuple[str, List[Dict], Dict, Optional[str]]:
"name": param_name,
"annotation": param.annotation,
"doc": parameters.get(param_name),
"kind": param.kind.description,
}
if param_name in parameters:
del parameters[param_name]
Expand Down
Loading