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

Function that returns a dictionary is not working in gradio reload mode #10253

Open
1 task done
Col0ring opened this issue Dec 25, 2024 · 3 comments
Open
1 task done
Labels
bug Something isn't working Regression Bugs did not exist in previous versions of Gradio

Comments

@Col0ring
Copy link
Contributor

Describe the bug

The error is shown below:

ValueError: Returned component <gradio.components.number.Number object at 0x12348fef0> not specified as output of function.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

with gr.Blocks() as demo:
    food_box = gr.Number(value=10, label="Food Count")
    status_box = gr.Textbox()

    def eat(food):
        if food > 0:
            return {food_box: food - 1, status_box: "full"}
        else:
            return {status_box: "hungry"}

    gr.Button("Eat").click(fn=eat,
                           inputs=food_box,
                           outputs=[food_box, status_box])

demo.launch()

Additionally, the same code works in gradio 5.4.0.

Screenshot

No response

Logs

No response

System Info

gradio version: 5.9.1
gradio_client version: 1.5.2

Severity

Blocking usage of gradio

@Col0ring Col0ring added the bug Something isn't working label Dec 25, 2024
@abidlabs abidlabs added the Regression Bugs did not exist in previous versions of Gradio label Dec 25, 2024
@abidlabs
Copy link
Member

Hi @Col0ring I can't repro this with the latest version of Gradio. The provided repro works for me locally and on Colab: https://colab.research.google.com/drive/1BVtyY_TtSBnYZugjyNgCHAGP6yOA-i_w?usp=sharing

@abidlabs abidlabs added the needs repro Awaiting full reproduction label Dec 25, 2024
@Col0ring
Copy link
Contributor Author

Hi @Col0ring I can't repro this with the latest version of Gradio. The provided repro works for me locally and on Colab: https://colab.research.google.com/drive/1BVtyY_TtSBnYZugjyNgCHAGP6yOA-i_w?usp=sharing

Did you run python app.py or gradio app.py? I found that only gradio app.py will cause this issue.

@abidlabs
Copy link
Member

Weird, I can reproduce that!

@abidlabs abidlabs changed the title Function return a dictionary is not working Function return a dictionary is not working in gradio reload mode Dec 25, 2024
@abidlabs abidlabs changed the title Function return a dictionary is not working in gradio reload mode Function that returns a dictionary is not working in gradio reload mode Dec 25, 2024
@abidlabs abidlabs removed the needs repro Awaiting full reproduction label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Regression Bugs did not exist in previous versions of Gradio
Projects
None yet
Development

No branches or pull requests

2 participants