Open thiswillbeyourgithub opened 10 months ago
This seems strange.
cc @dawoodkhan82
This is because in the creation of an event trigger we set the fn
to be "decorator" by default. So None
has to explicitly set in order for the js
function to be called. We can set None
to be the default, but that would break event decorators.
fn: Callable | None | Literal["decorator"] = "decorator"
Any ideas around this @abidlabs?
I'm a little confused. So the js
parameter only works if there's no backend function? I thought we could do both -- have a backend function, and a js function
Yeah. You should be able to have any combination of fe and be function as far as I'm aware.
Yes, you can already do both (have a backend function, and a js function). But if you only want to have a js function run, you need to explicitly set fn=None
. Which I think is fine.
But why does the be function being the default prevent the fe function from running?
But why does the be function being the default prevent the fe function from running?
The event_trigger
does not get created properly, because fn
is set to "decorator" and so it hits this line:
https://github.com/gradio-app/gradio/blob/a3cf90e57bc76c231ffc6c9abc8170ef7298f991/gradio/events.py#L234
From my understanding, since there is no actual decorator, it doesn't hit the wrapper function to create the event_trigger.
Synced with @abidlabs. The best solution here seems to be to set fn=None
by default, and figure out how to detect if the fn
is actually decorator. Will take a look at if this is possible.
Hi, apologies for the late follow up. We haven't had a chance to look into this issue recently, but the Gradio codebase has changed quite significantly since this issue was created, particularly with the release of Gradio 5. Could you let us know if this is still an issue in the latest version of Gradio (pip install --upgrade gradio
)? Thanks!
Hi, apologies for the late follow up. We haven't had a chance to look into this issue recently, but the Gradio codebase has changed quite significantly since this issue was created, particularly with the release of Gradio 5. Could you let us know if this is still an issue in the latest version of Gradio (
pip install --upgrade gradio
)? Thanks!
Following up at all is great! Thanks a lot.
I've just tested my reproduction code on version 5.1.0 and confirm the bug is still here.
Thank you for confirming!
Describe the bug
I notice I don't have the same behavior depending on if I comment
fn=None,
.Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
No response
System Info
Severity
I can work around it