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

Examples don't work for streaming #4

Open
pablovela5620 opened this issue Jun 11, 2024 · 4 comments
Open

Examples don't work for streaming #4

pablovela5620 opened this issue Jun 11, 2024 · 4 comments

Comments

@pablovela5620
Copy link

pablovela5620 commented Jun 11, 2024

Settings examples to True or lazy breaks things and I get the following error. You can test using this code https://github.com/pablovela5620/mini-dpvo

git clone https://github.com/pablovela5620/mini-dpvo.git
cd mini-dpvo
pixi run app

, and adding cache_examples=True here

Traceback (most recent call last):
  File "/home/pablo/0Dev/personal/mini-dpvo/tools/app.py", line 244, in <module>
    main(tyro.cli(GradioDPVOConfig))
  File "/home/pablo/0Dev/personal/mini-dpvo/tools/app.py", line 215, in main
    examples = gr.Examples(
               ^^^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio/helpers.py", line 74, in create_examples
    examples_obj.create()
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio/helpers.py", line 314, in create
    self._start_caching()
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio/helpers.py", line 365, in _start_caching
    client_utils.synchronize_async(self.cache)
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio_client/utils.py", line 855, in synchronize_async
    return fsspec.asyn.sync(fsspec.asyn.get_loop(), func, *args, **kwargs)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/fsspec/asyn.py", line 103, in sync
    raise return_result
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/fsspec/asyn.py", line 56, in _runner
    result[0] = await coro
                ^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio/helpers.py", line 487, in cache
    prediction = await Context.root_block.process_api(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio/blocks.py", line 1938, in process_api
    data = await self.postprocess_data(block_fn, result["prediction"], state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio/blocks.py", line 1761, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio_rerun/rerun.py", line 126, in postprocess
    root=[
         ^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio_rerun/rerun.py", line 132, in <listcomp>
    if not is_url(file)
           ^^^^^^^^^^^^
  File "/home/pablo/0Dev/personal/mini-dpvo/.pixi/envs/default/lib/python3.11/site-packages/gradio_rerun/rerun.py", line 123, in is_url
    return input.startswith("http:https://") or input.startswith("https://")
           ^^^^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'startswith'
@jleibs
Copy link
Contributor

jleibs commented Jun 12, 2024

Oh neat! I hadn't realized Gradio could do that. Would be super nice to just cache and serve an rrd for each example.

@radames
Copy link
Owner

radames commented Jun 12, 2024

yes the examples should work. I need to check in case lazy mode enabled, does the backend component need anything special

@radames
Copy link
Owner

radames commented Jun 15, 2024

I'm working on a fix here https://github.com/radames/gradio-rerun-viewer/tree/fix-cache-examples, but still having an issue
I think there must be something on the Gradio side, I've asked for help

payload = self.data_model.from_json(payload)

  File "/gradio-rerun-viewer/venv/lib/python3.10/site-packages/gradio/data_classes.py", line 186, in from_json

    return cls(root=x)

  File "/gradio-rerun-viewer/venv/lib/python3.10/site-packages/pydantic/root_model.py", line 71, in __init__

    self.__pydantic_validator__.validate_python(root, self_instance=self)

pydantic_core._pydantic_core.ValidationError: 1 validation error for RerunData

  Input should be a valid list 

    For further information visit https://errors.pydantic.dev/2.7/v/list_type

@pablovela5620
Copy link
Author

I'm working on a fix here https://github.com/radames/gradio-rerun-viewer/tree/fix-cache-examples, but still having an issue I think there must be something on the Gradio side, I've asked for help

payload = self.data_model.from_json(payload)

  File "/gradio-rerun-viewer/venv/lib/python3.10/site-packages/gradio/data_classes.py", line 186, in from_json

    return cls(root=x)

  File "/gradio-rerun-viewer/venv/lib/python3.10/site-packages/pydantic/root_model.py", line 71, in __init__

    self.__pydantic_validator__.validate_python(root, self_instance=self)

pydantic_core._pydantic_core.ValidationError: 1 validation error for RerunData

  Input should be a valid list 

    For further information visit https://errors.pydantic.dev/2.7/v/list_type

With 0.17 on the horizon, did you end up finding a fix for this?

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

No branches or pull requests

3 participants