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 dataset update #8581

Merged
merged 13 commits into from
Jun 19, 2024
Merged

fix dataset update #8581

merged 13 commits into from
Jun 19, 2024

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Jun 19, 2024

Allows the samples in a gr.Dataset to be updated. Here's a quick example:

import gradio as gr

def update(value):
    print(value)
    return value, gr.Dataset(samples=[["a"],["b"]])

with gr.Blocks() as demo:
    with gr.Row():
        textbox = gr.Textbox()
        dataset = gr.Dataset(components = ["text"], samples = [["This"]], label="Saved Prompts")
        dataset.click(update, inputs=[dataset], outputs=[textbox, dataset])

demo.launch()

Closes: #8312
Closes: #7282
Closes: #6415

Also fixes the issue where clearing an Interface that included a Dataset would cause the Interface to crash.

Closes: #6807

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jun 19, 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-builds.s3.amazonaws.com/e7b34a2e270dae09c0808e6be0dd84e7e856cde6/gradio-4.36.1-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/e7b34a2e270dae09c0808e6be0dd84e7e856cde6/gradio-client-1.1.1.tgz

@@ -164,7 +164,7 @@ def flag(
) / client_utils.strip_invalid_filename_characters(
getattr(component, "label", None) or f"component {idx}"
)
if utils.is_update(sample):
Copy link
Member Author

Choose a reason for hiding this comment

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

just a refactor for clarity

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jun 19, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

fix dataset update

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.

@abidlabs abidlabs requested a review from aliabid94 June 19, 2024 22:14
@abidlabs abidlabs requested a review from aliabd June 19, 2024 22:29
@abidlabs abidlabs marked this pull request as ready for review June 19, 2024 22:29
Copy link
Collaborator

@aliabd aliabd left a comment

Choose a reason for hiding this comment

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

Tested and everything lgtm! Thanks @abidlabs. docs look good too!

@abidlabs
Copy link
Member Author

Thanks for the prompt review @aliabd!

@abidlabs abidlabs enabled auto-merge (squash) June 19, 2024 22:51
@abidlabs abidlabs merged commit a1c21cb into main Jun 19, 2024
7 of 8 checks passed
@abidlabs abidlabs deleted the fix-dataset-update branch June 19, 2024 23:00
This was referenced Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants