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

Set share=True for all Gradio apps in Colab by default #5767

Merged
merged 4 commits into from Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/yummy-mice-start.md
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Set share=True for all Gradio apps in Colab by default
2 changes: 1 addition & 1 deletion gradio/blocks.py
Expand Up @@ -2080,7 +2080,7 @@ def reverse(text):
utils.launch_counter()
self.is_sagemaker = utils.sagemaker_check()
if share is None:
if self.is_colab and self.enable_queue:
if self.is_colab:
if not quiet:
print(
"Setting queue=True in a Colab notebook requires sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n"
Expand Down
6 changes: 3 additions & 3 deletions test/test_blocks.py
Expand Up @@ -65,11 +65,11 @@ def test_set_share_in_colab(self, mock_colab_check, mock_setup_tunnel):
with gr.Blocks() as demo:
# self.share is False when instantiating the class
assert not demo.share
# share default is False, if share is None in colab and no queueing
# share default is True, if share is None in colab and queueing
demo.launch(prevent_thread_lock=True)
assert not demo.share
assert demo.share
demo.close()
# share becomes true, if share is None in colab with queueing
# share is also true, if share is None in colab with queueing
demo.queue()
demo.launch(prevent_thread_lock=True)
assert demo.share
Expand Down
8 changes: 0 additions & 8 deletions test/test_interfaces.py
Expand Up @@ -103,14 +103,6 @@ def test_block_thread(self, mock_sleep):
"Keyboard interruption in main thread... closing server." in output
)

@mock.patch("gradio.utils.colab_check")
def test_launch_colab_share(self, mock_colab_check):
mock_colab_check.return_value = True
interface = Interface(lambda x: x, "textbox", "label")
_, _, share_url = interface.launch(prevent_thread_lock=True)
assert share_url is None
interface.close()

@mock.patch("gradio.utils.colab_check")
@mock.patch("gradio.networking.setup_tunnel")
def test_launch_colab_share_error(self, mock_setup_tunnel, mock_colab_check):
Expand Down