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
Improvements to State
#2100
Improvements to State
#2100
Conversation
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2100-all-demos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abidlabs Looks good to me except the change in the config for gr.Variable I note in one of the comments
|
||
With more complex apps, you will likely have many Variables storing session state in a single Blocks app. | ||
With more complex apps, you will likely have many State variables storing session state in a single Blocks app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interface_state.md
guide should we mention that interfaces only support a single state variable? And point them to blocks for more complex state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will make the addition
Thanks for the catches @freddyaboulton! Have updated the PR and will merge after the tests pass |
This PR makes some enhancements to session state. First, it introduces
gr.State()
as an alias ofgr.Variable()
, unifying the naming we use inBlocks
andInterface
. To use state inInterface
, one can do either of these approaches:gr.State()
,gr.State()
) (previously, this would not work)In Blocks, the same approach works as before but using
gr.State()
instead ofgr.Variable()
.Some additional tests have been added. The demos and documentation have also been updated to use
gr.State()
. For backwards compatibility,gr.Variable()
is still accepted.Fixes: #730