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

Fix state changes within a gr.render #10095

Merged
merged 3 commits into from
Dec 4, 2024
Merged

Conversation

aliabid94
Copy link
Collaborator

State change triggers did not fire within gr.render. Fixes: #9472

Test with:

import gradio as gr

with gr.Blocks() as demo:
    iden = lambda x:x

    @gr.render()
    def render():
        a = gr.Textbox()
        b = gr.Textbox()
        s = gr.State()
        z = gr.Textbox()

        a.change(iden, a, b)
        b.change(iden, b, s)
        s.change(iden, s, z)

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

@aliabid94 aliabid94 requested review from abidlabs, freddyaboulton and dawoodkhan82 and removed request for abidlabs December 2, 2024 21:56
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 2, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/d31133894736bcb0fa91f9012c9e2c1b406b59ad/gradio-5.7.1-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@d31133894736bcb0fa91f9012c9e2c1b406b59ad#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/d31133894736bcb0fa91f9012c9e2c1b406b59ad/gradio-client-1.8.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/d31133894736bcb0fa91f9012c9e2c1b406b59ad/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 2, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fix state changes within a gr.render

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, looks good to me!

@abidlabs
Copy link
Member

abidlabs commented Dec 4, 2024

Merging to clean up the PRs

@abidlabs abidlabs merged commit 97d647e into main Dec 4, 2024
22 of 23 checks passed
@abidlabs abidlabs deleted the fix_state_change_in_render branch December 4, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

State.change not working inside dynamic rendering
3 participants