Skip to content

Adds missing parameters to Blocks.load() #2755

Merged
abidlabs merged 3 commits into
mainfrom
blocks-load-missing-params
Dec 1, 2022
Merged

Adds missing parameters to Blocks.load() #2755
abidlabs merged 3 commits into
mainfrom
blocks-load-missing-params

Conversation

@abidlabs
Copy link
Copy Markdown
Member

@abidlabs abidlabs commented Dec 1, 2022

Adds queue and other missing parameters to Blocks.load(), as well as to the documentation.

Fixes: #2714

To test, run

import gradio as gr
import time

def identity():
    time.sleep(5)
    return "hello"

with gr.Blocks() as demo:
    textbox = gr.Textbox()
    demo.load(identity, None, textbox, queue=False)
    
demo.queue().launch()

and open on multiple tabs. Since queue is disabled, you should not see a queue on the subsequent tabs and instead they should all run concurrently.

As a side note, we should refactor Blocks.load() altogether, as I suggest in #2754

Comment thread gradio/blocks.py
api_key: Optional[str] = None,
alias: Optional[str] = None,
_js: Optional[str] = None,
every: None | int = None,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No problem bringing a parameter after "" to before "" (the other way around would cause backwards incompatibility)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like gh markdown messed up what you're trying to say? I don't understand this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Whoops I meant to say that it's safe to make the _js and every positional parameters instead of just named parameters. Wouldn't have been safe the other way around

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 1, 2022

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

@abidlabs abidlabs requested a review from aliabd December 1, 2022 23:18
Copy link
Copy Markdown
Contributor

@aliabd aliabd left a comment

Choose a reason for hiding this comment

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

LGTM, but maybe we should make same changes to Interface.load()?

@abidlabs
Copy link
Copy Markdown
Member Author

abidlabs commented Dec 1, 2022

Interface.load() is only the class method, it doesn't have the event trigger associated with it (although Interface().load() inherits from Blocks, so you can use it like that)

@abidlabs abidlabs merged commit 82cd554 into main Dec 1, 2022
@abidlabs abidlabs deleted the blocks-load-missing-params branch December 1, 2022 23:52
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.

Add and document queue parameter in blocks.load()

2 participants