Conversation
Contributor
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2100-all-demos |
Collaborator
freddyaboulton
left a comment
There was a problem hiding this comment.
@abidlabs Looks good to me except the change in the config for gr.Variable I note in one of the comments
| 3. In `guess_letter`, we pass the value of this `State` to `used_letters`, and then return an updated value of this `State` in the return statement. | ||
|
|
||
| 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. |
Collaborator
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
Sure will make the addition
Member
Author
|
Thanks for the catches @freddyaboulton! Have updated the PR and will merge after the tests pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes some enhancements to session state. First, it introduces
gr.State()as an alias ofgr.Variable(), unifying the naming we use inBlocksandInterface. 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