gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
34.31k stars 2.61k forks source link

Can't load some chatbot demos on huggingface spaces #7362

Closed freddyaboulton closed 8 months ago

freddyaboulton commented 9 months ago

Describe the bug

I can't load the following two chatbot demos in the gradio org. The cause is different for each once. Might be fixed by #7350 but just noting here.

  1. gr.load("gradio/chatinterface_streaming_echo", src="spaces")
    
    Fetching Space from: https://huggingface.co/spaces/gradio/chatinterface_streaming_echo
    Loaded as API: https://gradio-chatinterface-streaming-echo.hf.space ✔
    ---------------------------------------------------------------------------
    KeyError                                  Traceback (most recent call last)
    Cell In[3], line 1
    ----> 1 gr.load("gradio/chatinterface_streaming_echo", src="spaces")

File ~/miniconda3/envs/dotenv-dev/lib/python3.10/site-packages/gradio/external.py:72, in load(name, src, hf_token, alias, kwargs) 48 @document() 49 def load( 50 name: str, (...) 54 kwargs, 55 ) -> Blocks: 56 """ 57 Method that constructs a Blocks from a Hugging Face repo. Can accept 58 model repos (if src is "models") or Space repos (if src is "spaces"). The input (...) 70 demo.launch() 71 """ ---> 72 return load_blocks_from_repo( 73 name=name, src=src, hf_token=hf_token, alias=alias, **kwargs 74 )

File ~/miniconda3/envs/dotenv-dev/lib/python3.10/site-packages/gradio/external.py:111, in load_blocks_from_repo(name, src, hf_token, alias, kwargs) 106 warnings.warn( 107 """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.""" 108 ) 109 Context.hf_token = hf_token --> 111 blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, kwargs) 112 return blocks

File ~/miniconda3/envs/dotenv-dev/lib/python3.10/site-packages/gradio/external.py:527, in from_spaces(space_name, hf_token, alias, **kwargs) 520 if kwargs: 521 warnings.warn( 522 "You cannot override parameters for this Space by passing in kwargs. " 523 "Instead, please load the Space as a function and use it to create a " 524 "Blocks or Interface locally. You may find this Guide helpful: " 525 "https://gradio.app/using_blocks_like_functions/" 526 ) --> 527 return from_spaces_blocks(space=space_name, hf_token=hf_token)

File ~/miniconda3/envs/dotenv-dev/lib/python3.10/site-packages/gradio/external.py:546, in from_spaces_blocks(space, hf_token) 544 else: 545 predict_fns.append(None) --> 546 return gradio.Blocks.from_config(client.config, predict_fns, client.src)

File ~/miniconda3/envs/dotenv-dev/lib/python3.10/site-packages/gradio/blocks.py:731, in Blocks.from_config(cls, config, fns, proxy_url) 729 _targets = dependency.pop("targets") 730 trigger = dependency.pop("trigger", None) --> 731 targets = [ 732 getattr( 733 original_mapping[ 734 target if isinstance(target, int) else target[0] 735 ], 736 trigger if isinstance(target, int) else target[1], 737 ) 738 for target in _targets 739 ] 740 dependency.pop("backend_fn") 741 dependency.pop("documentation", None)

File ~/miniconda3/envs/dotenv-dev/lib/python3.10/site-packages/gradio/blocks.py:733, in (.0) 729 _targets = dependency.pop("targets") 730 trigger = dependency.pop("trigger", None) 731 targets = [ 732 getattr( --> 733 original_mapping[ 734 target if isinstance(target, int) else target[0] 735 ], 736 trigger if isinstance(target, int) else target[1], 737 ) 738 for target in _targets 739 ] 740 dependency.pop("backend_fn") 741 dependency.pop("documentation", None)

KeyError: None


2. `gr.load("gradio/chatbot_multimodal", src="spaces")`

Fetching Space from: https://huggingface.co/spaces/gradio/chatbot_multimodal Loaded as API: https://gradio-chatbot-multimodal.hf.space

FileNotFoundError Traceback (most recent call last)

in () ----> 1 g.load("gradio/chatbot_multimodal", src="spaces") ~/sources/gradio/gradio/external.py in load(name, src, hf_token, alias, **kwargs) 58 demo.launch() 59 """ ---> 60 return load_blocks_from_repo( 61 name=name, src=src, hf_token=hf_token, alias=alias, **kwargs 62 ) ~/sources/gradio/gradio/external.py in load_blocks_from_repo(name, src, hf_token, alias, **kwargs) 97 Context.hf_token = hf_token 98 ---> 99 blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs) 100 return blocks 101 ~/sources/gradio/gradio/external.py in from_spaces(space_name, hf_token, alias, **kwargs) 415 "https://gradio.app/using_blocks_like_functions/" 416 ) --> 417 return from_spaces_blocks(space=space_name, hf_token=hf_token) 418 419 ~/sources/gradio/gradio/external.py 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) 441 442 ~/sources/gradio/gradio/blocks.py in from_config(cls, config, fns, proxy_url) 707 original_mapping[0] = Context.root_block or blocks 708 --> 709 iterate_over_children(config["layout"]["children"]) 710 711 first_dependency = None ~/sources/gradio/gradio/blocks.py in iterate_over_children(children_list) 688 for child_config in children_list: 689 id = child_config["id"] --> 690 block = get_block_instance(id) 691 692 original_mapping[id] = block ~/sources/gradio/gradio/blocks.py in get_block_instance(id) 671 672 constructor_args = cls.recover_kwargs(block_config["props"]) --> 673 block = cls(**constructor_args) 674 if postprocessed_value is not None: 675 block.value = postprocessed_value # type: ignore ~/sources/gradio/gradio/component_meta.py in wrapper(*args, **kwargs) 155 return None 156 else: --> 157 return fn(self, **kwargs) 158 159 return wrapper ~/sources/gradio/gradio/components/chatbot.py in __init__(self, value, label, every, show_label, container, scale, min_width, visible, elem_id, elem_classes, render, height, latex_delimiters, rtl, show_share_button, show_copy_button, avatar_images, sanitize_html, render_markdown, bubble_full_width, line_breaks, likeable, layout) 130 self.avatar_images = [ 131 processing_utils.move_resource_to_block_cache(avatar_images[0], self), --> 132 processing_utils.move_resource_to_block_cache(avatar_images[1], self), 133 ] 134 ~/sources/gradio/gradio/processing_utils.py in move_resource_to_block_cache(url_or_file_path, block) 234 left here for backwards compatibility for any custom components created in Gradio 4.2.0 or earlier. 235 """ --> 236 return block.move_resource_to_block_cache(url_or_file_path) 237 238 ~/sources/gradio/gradio/blocks.py in move_resource_to_block_cache(self, url_or_file_path) 255 url_or_file_path = str(utils.abspath(url_or_file_path)) 256 if not utils.is_in_or_equal(url_or_file_path, self.GRADIO_CACHE): --> 257 temp_file_path = processing_utils.save_file_to_cache( 258 url_or_file_path, cache_dir=self.GRADIO_CACHE 259 ) ~/sources/gradio/gradio/processing_utils.py in save_file_to_cache(file_path, cache_dir) 168 """Returns a temporary file path for a copy of the given file path if it does 169 not already exist. Otherwise returns the path to the existing temp file.""" --> 170 temp_dir = hash_file(file_path) 171 temp_dir = Path(cache_dir) / temp_dir 172 temp_dir.mkdir(exist_ok=True, parents=True) ~/sources/gradio/gradio/processing_utils.py in hash_file(file_path, chunk_num_blocks) 100 def hash_file(file_path: str | Path, chunk_num_blocks: int = 128) -> str: 101 sha1 = hashlib.sha1() --> 102 with open(file_path, "rb") as f: 103 for chunk in iter(lambda: f.read(chunk_num_blocks * sha1.block_size), b""): 104 sha1.update(chunk) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/gradio/2d311a7a2d0f31be8bde44af2b667b9c782f645f/avatar.png' ``` ### Have you searched existing issues? 🔎 - [X] I have searched and found no existing issues ### Reproduction ```python import gradio as gr gr.load("gradio/chatbot_multimodal", src="spaces") gr.load("gradio/chatinterface_streaming_echo", src="spaces") ``` ### Screenshot _No response_ ### Logs _No response_ ### System Info ```shell Gradio Environment Information: ------------------------------ Operating System: Darwin gradio version: 4.16.0 gradio_client version: 0.8.1 ------------------------------------------------ gradio dependencies in your environment: aiofiles: 23.2.1 altair: 5.2.0 fastapi: 0.109.0 ffmpy: 0.3.1 gradio-client==0.8.1 is not installed. httpx: 0.26.0 huggingface-hub: 0.20.3 importlib-resources: 6.1.1 jinja2: 3.1.3 markupsafe: 2.1.4 matplotlib: 3.8.2 numpy: 1.26.3 orjson: 3.9.12 packaging: 23.2 pandas: 2.2.0 pillow: 10.2.0 pydantic: 2.6.0 pydub: 0.25.1 python-multipart: 0.0.6 pyyaml: 6.0.1 ruff: 0.1.14 semantic-version: 2.10.0 tomlkit==0.12.0 is not installed. typer: 0.9.0 typing-extensions: 4.9.0 uvicorn: 0.27.0.post1 authlib; extra == 'oauth' is not installed. itsdangerous; extra == 'oauth' is not installed. gradio_client dependencies in your environment: fsspec: 2023.12.2 httpx: 0.26.0 huggingface-hub: 0.20.3 packaging: 23.2 typing-extensions: 4.9.0 websockets: 11.0.3 ``` ### Severity I can work around it
abidlabs commented 8 months ago

Just noting that some non-chatbot demos like gr.load("spaces/gradio/kitchen_sink") are also broken

abidlabs commented 8 months ago

This is actually not closed.