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 output directory of files in client & when calling Blocks as function #4501

Merged
merged 14 commits into from
Jun 14, 2023

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Jun 13, 2023

Previously, different serializers saved output files in inconsistent places. This meant that if you used the client to do a prediction, it could save output files in various places -- including the working directory for the Gallery component (see #4494). This fixes that -- all of the serializers save output files to a folder created within the GRADIO_TEMP_DIR directory.

Test with:

import gradio as gr

demo = gr.Interface(
    lambda x:["cheetah.jpg"],
    inputs=[gr.Slider(value=3, minimum=1, maximum=3, step=1)],
    outputs=[gr.Gallery(columns=2, preview=True)],
)

demo(4)
demo = gr.Interface(
    lambda x:"cheetah.jpg",
    inputs=[gr.Slider(value=3, minimum=1, maximum=3, step=1)],
    outputs=[gr.Image()],
)

demo(4)

and so on.

Furthermore, if you are using the python Client, you can specify the output directory with a new output_dir parameter.

Closes: #4494
Closes: #4495

@gradio-pr-bot
Copy link
Collaborator

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4501-all-demos

@freddyaboulton
Copy link
Collaborator

@abidlabs is this ready? Got tagged for review but it's still a draft. Quick turnaround!

@abidlabs
Copy link
Member Author

Just adding tests @freddyaboulton! Will open up soon

@abidlabs abidlabs marked this pull request as ready for review June 13, 2023 20:48
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.

Looks good @abidlabs !

gradio/blocks.py Outdated Show resolved Hide resolved
gradio/components.py Outdated Show resolved Hide resolved
test/test_blocks.py Show resolved Hide resolved
client/python/gradio_client/utils.py Show resolved Hide resolved
@abidlabs
Copy link
Member Author

Thanks @freddyaboulton for the review! Will address the suggestions tomorrow

@abidlabs
Copy link
Member Author

I'll need to release a new version of gradio_client for the regular tests to pass

@abidlabs abidlabs merged commit d65512c into main Jun 14, 2023
@abidlabs abidlabs deleted the fix-serializing branch June 14, 2023 22:08
@pngwn pngwn mentioned this pull request Jul 26, 2023
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