gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.73k stars 2.29k forks source link

Set orig_name in python client file uploads #8371

Closed freddyaboulton closed 1 month ago

freddyaboulton commented 1 month ago

Description

Closes: #8366

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

gradio-pr-bot commented 1 month ago

🪼 branch checks and previews

• Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
:unicorn: Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/5433ba625969061948c250473a2daaf134102ed6/gradio-4.31.5-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/5433ba625969061948c250473a2daaf134102ed6/gradio-client-0.19.4.tgz
gradio-pr-bot commented 1 month ago

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
gradio_client patch

With the following changelog entry.

Set orig_name in python client file uploads

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](https://github.com/gradio-app/gradio/edit/8366-preserve-orig-name-python-client/.changeset/poor-roses-wait.md).
hannahblair commented 1 month ago

btw @freddyaboulton it seems my CI change has broken the PR previews so i'll get on fixing that

freddyaboulton commented 1 month ago

Thanks @hannahblair !

abidlabs commented 1 month ago

@freddyaboulton I tested this with a modified version of the repro in the original issue and not sure its working with me. Here's what I tried:

import gradio as gr

def img_test(img):
    return img

with gr.Blocks() as demo:
    image1 = gr.Image(format="png", type="filepath")
    btn = gr.Button(value="process")
    btn.click(fn=img_test,inputs=[image1],outputs=[image1],api_name="process")

_, url, _ = demo.launch()

from gradio_client import Client, file

client = Client(url)
result = client.predict(
        img=file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
        api_name="/process"
)
print(result)

I still got a .webp image:

/private/var/folders/kf/ll6fqkys7_s05x4tvb546mdc0000gn/T/gradio/d5fe0b3ad36a18307d3bba4a5c1a0dd1caa9167c/image.webp
freddyaboulton commented 1 month ago

@abidlabs should be fixed now! Was an issue with the url case

freddyaboulton commented 1 month ago

Thank you @abidlabs !