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

Custom component in rerender #10170

Merged
merged 7 commits into from
Dec 13, 2024
Merged

Custom component in rerender #10170

merged 7 commits into from
Dec 13, 2024

Conversation

aliabid94
Copy link
Collaborator

@aliabid94 aliabid94 commented Dec 10, 2024

Custom components did not work in @render blocks, fixed now. Fixes: #8722 (the remaining issue).

Custom components don't work in dev mode (not sure why), so you'll have to build to test the frontend changes.

Test with:

# pip install gradio_modal

import gradio as gr
from gradio_modal import Modal

with gr.Blocks() as demo:
    @gr.render()
    def render():
        with Modal(visible=True):
            gr.Number(1234)

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

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 10, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detecting...

Install Gradio from this PR

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

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

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

Use Lite from this PR

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

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 10, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Custom component in rerender

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
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Nice fix! Also tested with a different custom component

import gradio as gr
from gradio_pdf import PDF

with gr.Blocks() as demo:
    button = gr.Button("Make PDF Visible")
    @gr.render(triggers=[button.click])
    def render():
       PDF("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")

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

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks @aliabid94!

aliabid94 and others added 2 commits December 12, 2024 12:26
* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
@abidlabs
Copy link
Member

Thanks folks, merging so that we can do a release tom

@abidlabs abidlabs merged commit 5e6e234 into main Dec 13, 2024
22 of 23 checks passed
@abidlabs abidlabs deleted the custom_component_in_rerender branch December 13, 2024 01:40
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.

Issues with gr.render
5 participants