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
32.22k stars 2.41k forks source link

Reload Mode not reloading changes from indirectly referenced modules #8917

Open JackismyShephard opened 1 month ago

JackismyShephard commented 1 month ago

Describe the bug

I am using gradio for a larger project where my main app.py script is importing render functions from several frontend modules. These modules themselves import functionality from backend modules. When I make changes in the backend modules, those files are not reloaded by Reload Mode.

Have you searched existing issues? πŸ”Ž

Reproduction

Here is a minimal example that reproduces the error on my system:

app.py:

import gradio as gr

from frontend import render

with gr.Blocks(title="Ultimate RVC") as app:
    render()

if __name__ == "__main__":
    app.launch()

frontend.py:

import gradio as gr

from backend import print_success

def render() -> None:
    button = gr.Button("Print", variant="primary")
    message = gr.Text(label="Output message", interactive=False)
    button.click(print_success, outputs=message)

backend.py:

def print_success() -> str:
    return f"Sus!"

I run the app in reload mode by executing gradio ./app.py --demo-name app.

When I change the string returned by print_success in backend.py, the output message displayed in the app is not updated accordingly

Screenshot

No response

Logs

No response

System Info

Gradio 4.38.1

Python 3.11 (using miniconda)

Windows 11 (also tested on Ubuntu 22.04 and 24.04)

Severity

I can work around it

freddyaboulton commented 1 month ago

I can look into this but probably not until late next week or later so if you have bandwidth to propose and implement a fix @JackismyShephard , that would be much appreciated!

JackismyShephard commented 1 month ago

@freddyaboulton I probably also won't have time for it before then. My plan is to try and look into https://github.com/gradio-app/gradio/issues/8928 tomorrow. If you have not gotten around to it before next weekend I might have a look at it then, although I don't really know where to start πŸ˜…

relubwu commented 1 month ago

Encountered the same here, worked around by mounting gradio app to fastapi & use their reload, albeit much slower than gradio's. Tried downgrading to previous versions but some other problems popped up, likely due to dependency conflicts. Looking forward to solutions to this!

JackismyShephard commented 1 month ago

@freddyaboulton Might be nice to escalate this a bit. I am not sure it is something I can solve