gradio
gradio copied to clipboard
More fixes for gr.load()
So this is a partial fix to: https://github.com/gradio-app/gradio/issues/7362
This PR allows these two Spaces to be loaded at least. They won't work yet (will tackle that next)
import gradio as gr
gr.load("gradio/chatbot_multimodal", src="spaces").launch()
and partially fixes the first one:
import gradio as gr
gr.load("gradio/chatinterface_streaming_echo", src="spaces").launch()
These demos will load but if you try running them you'll get errors. As far as I can tell, this has to do with the fact that the logic for gathering/uploading files is incorrect. So I'll tackle that separately in https://github.com/gradio-app/gradio/issues/7360
🪼 branch checks and previews
| • | Name | Status | URL |
|---|---|---|---|
| Spaces | Spaces preview | ||
| Website | Website preview | ||
| :unicorn: | Changes | Details |
Install Gradio from this PR
pip install https://gradio-builds.s3.amazonaws.com/ae372689f1e00f49323e9b1eea8cfbd4fb6c3b0a/gradio-4.19.2-py3-none-any.whl
Install Gradio Python Client from this PR
pip install "gradio-client @ git+https://github.com/gradio-app/gradio@ae372689f1e00f49323e9b1eea8cfbd4fb6c3b0a#subdirectory=client/python"
🦄 change detected
This Pull Request includes changes to the following packages.
| Package | Version |
|---|---|
gradio |
patch |
gradio_client |
patch |
- [ ] Maintainers can select this checkbox to manually select packages to update.
With the following changelog entry.
More fixes for gr.load()
Maintainers or the PR author can modify the PR title to modify this entry.
Something isn't right?
- Maintainers can change the version label to modify the version bump.
- If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.
Hello @abidlabs,
I've gone through all the issues and installed the latest gradio and gradio-client libraries but still getting the same error while trying to load one space from another. Output below. Any advice? Thanks, Alexandre
Fetching Space from: https://huggingface.co/spaces/avfranco/ArchitectGPT Loaded as API: https://avfranco-architectgpt.hf.space ✔
{ "name": "KeyError", "message": "None", "stack": "--------------------------------------------------------------------------- KeyError Traceback (most recent call last) Cell In[6], line 7 4 read_key = os.environ.get('HUGGINGFACEHUB_API_TOKEN', None) 6 ##with gr.Blocks() as demo: ----> 7 gr.load("avfranco/ArchitectGPT", hf_token=read_key, src="spaces").launch() 8 ##demo.launch(debug=True)
File ~/.pyenv/versions/3.11.3/envs/huggingface/lib/python3.11/site-packages/gradio/external.py:60, in load(name, src, hf_token, alias, **kwargs) 36 @document() 37 def load( 38 name: str, (...) 42 **kwargs, 43 ) -> Blocks: 44 """ 45 Constructs a demo from a Hugging Face repo. Can accept model repos (if src is "models") or Space repos (if src is "spaces"). The input 46 and output components are automatically loaded from the repo. Note that if a Space is loaded, certain high-level attributes of the Blocks (e.g. (...) 58 demo.launch() 59 """ ---> 60 return load_blocks_from_repo( 61 name=name, src=src, hf_token=hf_token, alias=alias, **kwargs 62 )
File ~/.pyenv/versions/3.11.3/envs/huggingface/lib/python3.11/site-packages/gradio/external.py:99, in load_blocks_from_repo(name, src, hf_token, alias, **kwargs) 94 warnings.warn( 95 """You are loading a model/Space with a different access token than the one you used to load a previous model/Space. This is not recommended, as it may cause unexpected behavior.""" 96 ) 97 Context.hf_token = hf_token ---> 99 blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs) 100 return blocks
File ~/.pyenv/versions/3.11.3/envs/huggingface/lib/python3.11/site-packages/gradio/external.py:417, in from_spaces(space_name, hf_token, alias, **kwargs) 410 if kwargs: 411 warnings.warn( 412 "You cannot override parameters for this Space by passing in kwargs. " 413 "Instead, please load the Space as a function and use it to create a " 414 "Blocks or Interface locally. You may find this Guide helpful: " 415 "https://gradio.app/using_blocks_like_functions/" 416 ) --> 417 return from_spaces_blocks(space=space_name, hf_token=hf_token)
File ~/.pyenv/versions/3.11.3/envs/huggingface/lib/python3.11/site-packages/gradio/external.py:440, in from_spaces_blocks(space, hf_token) 438 else: 439 predict_fns.append(None) --> 440 return gradio.Blocks.from_config(client.config, predict_fns, client.src)
File ~/.pyenv/versions/3.11.3/envs/huggingface/lib/python3.11/site-packages/gradio/blocks.py:729, in Blocks.from_config(cls, config, fns, proxy_url) 727 _targets = dependency.pop("targets") 728 trigger = dependency.pop("trigger", None) --> 729 targets = [ 730 getattr( 731 original_mapping[ 732 target if isinstance(target, int) else target[0] 733 ], 734 trigger if isinstance(target, int) else target[1], 735 ) 736 for target in _targets 737 ] 738 dependency.pop("backend_fn") 739 dependency.pop("documentation", None)
File ~/.pyenv/versions/3.11.3/envs/huggingface/lib/python3.11/site-packages/gradio/blocks.py:731, in
KeyError: None" }
Hi @avfranco-br can you share a public Space with me?
Thanks for reviewing @freddyaboulton, I think this can be merged in as a partial fix for #7362
Hi @avfranco-br can you share a public Space with me?
Thanks @abidlabs for your quick response. Sure, here it's ea4all_gpt.
Thanks @avfranco-br yes so the error you're getting is the one that this PR should fix. If you'd like to try it, you can build Gradio from this PR in your Space.
I've opened a PR for your Space here: https://huggingface.co/spaces/avfranco/ea4all_gpt/discussions/1
Thanks @abidlabs,
I've installed Gradio from both PRs below, but the error still persists. Shall I do something else?
-
pip install https://gradio-builds.s3.amazonaws.com/27241f3ab30854f0ebf21ed70cb734b04726af1e/gradio-4.18.0-py3-none-any.whl
-
pip install "gradio-client @ git+https://github.com/gradio-app/gradio@27241f3ab30854f0ebf21ed70cb734b04726af1e#subdirectory=client/python"
Closing as I'll do this as part of https://github.com/gradio-app/gradio/pull/7575