Allow gradio embeds in colab without share#2455
Conversation
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2455-all-demos |
|
Still a draft because the colab.html code I copied from your colab @pngwn but I assumed that might not be the final version of that code. feel free to edit this PR directly |
| return JSONResponse( | ||
| content={ | ||
| "error": f"This app has no endpoint /api/{api_name}/." | ||
| "error": f"This app has no endpoint /run/{api_name}/." |
There was a problem hiding this comment.
It looks like we are migrating from "/api" to "/run" as the official API endpoint. Let's make sure to update the "view API" page as well.
Also this is a bit of an edge case but what happens if a user-supplied api_name includes the string "api". Perhaps we can print a warning to users letting them know that their app will not work inside Colab
There was a problem hiding this comment.
Does colab block any call with a substring "api"? Anyways, even if they create a custom named API, the frontend does not use the names API's, so gradio UI will still work fine.
|
This is really cool stuff @aliabid94 and @pngwn! I released a new version In the meantime, I'm testing with |
|
Tested a bunch of different Gradio demos with
I thought this error only happens if you have queuing enabled, but I experienced with a very simple UI without the demo enabled. We should investigate what's going on here.
|
pngwn
left a comment
There was a problem hiding this comment.
This is great. I think most of the frontend code is fine, left a few comments but I can't think of anything else we really need to cover.
|
Okay everything should be fixed!
I think it's good to go! |
|
LGTM, I can confirm that the issues above have been fixed 🚀 🚀 Made a very small tweak to the printed message to link to the GitHub repo |
|
What's the right version to test with? 3.0.1b121? |
It looks like @aliabid94 modified the original Colab to install from this branch instead of pypi |


Embeds Gradio apps directly into using colabs
output.serve_kernel_port_as_iframe. Had to change default api endpoint name to/run(though/apiis still supported for backwards compatibility.).Note: websockets with queueing are not supported, so will still use sharing in that case.
Example colab: https://colab.research.google.com/drive/1oOyMGV0cxziK_ViSmh0y2c2FxPOHPFMs?usp=sharing