Skip to content

Commit

Permalink
Remove **kwargs from queue (#6232)
Browse files Browse the repository at this point in the history
* Rework queue method params

* add changeset

* raise instead

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
freddyaboulton and gradio-pr-bot committed Nov 3, 2023
1 parent e3ede2f commit ac4f2bc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-peaches-speak.md
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:Remove **kwargs from queue
7 changes: 3 additions & 4 deletions gradio/blocks.py
Expand Up @@ -1611,14 +1611,15 @@ def queue(
status_update_rate: float | Literal["auto"] = "auto",
api_open: bool | None = None,
max_size: int | None = None,
**kwargs,
concurrency_count: int | None = None,
):
"""
By enabling the queue you can control when users know their position in the queue, and set a limit on maximum number of events allowed.
Parameters:
status_update_rate: If "auto", Queue will send status estimations to all clients whenever a job is finished. Otherwise Queue will send status at regular intervals set by this parameter as the number of seconds.
api_open: If True, the REST routes of the backend will be open, allowing requests made directly to those endpoints to skip the queue.
max_size: The maximum number of events the queue will store at any given moment. If the queue is full, new events will not be added and a user will receive a message saying that the queue is full. If None, the queue size will be unlimited.
concurrency_count: Deprecated and has no effect. Set the concurrency_limit directly on event listeners e.g. btn.click(fn, ..., concurrency_limit=10) or gr.Interface(concurrency_limit=10). If necessary, the total number of workers can be configured via `max_threads` in launch().
Example: (Blocks)
with gr.Blocks() as demo:
button = gr.Button(label="Generate Image")
Expand All @@ -1630,12 +1631,10 @@ def queue(
demo.queue(max_size=20)
demo.launch()
"""
if "concurrency_count" in kwargs:
if concurrency_count:
raise DeprecationWarning(
"concurrency_count has been deprecated. Set the concurrency_limit directly on event listeners e.g. btn.click(fn, ..., concurrency_limit=10) or gr.Interface(concurrency_limit=10). If necessary, the total number of workers can be configured via `max_threads` in launch()."
)
if len(kwargs):
raise ValueError(f"Invalid arguments: {kwargs}")
if api_open is not None:
self.api_open = api_open
if utils.is_zero_gpu_space():
Expand Down
7 changes: 7 additions & 0 deletions test/test_blocks.py
Expand Up @@ -1536,3 +1536,10 @@ def test_recover_kwargs():
["value"],
)
assert props == {"format": "wav", "autoplay": False}


def test_deprecation_warning_emitted_when_concurrency_count_set():
with pytest.raises(DeprecationWarning):
gr.Interface(lambda x: x, gr.Textbox(), gr.Textbox()).queue(
concurrency_count=12
)

0 comments on commit ac4f2bc

Please sign in to comment.