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

Ensure the height param in gr.File works as expected #10209

Merged
merged 7 commits into from
Dec 17, 2024
Merged

Conversation

hannahblair
Copy link
Collaborator

Description

Height wasn't being properly applied in gr.File, and we also weren't accept the height as a string even though it says so in the documentation for height in file.py.

Closes: #10184

🎯 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.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

* change max-height to height
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 16, 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/2d97a33b5bef4ca209ae482fc38fc16e7b03b0eb/gradio-5.9.1-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

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

Use Lite from this PR

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

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 16, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Ensure the height param in gr.File works as expected

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.

This fix does not work for me. This PR changes the behavior of height to force a height that applies when files are uploaded:

image

however, this is contrary to the docstring, which says that the height parameter serves as a "maximum height of the file component when files are present". So this is not correct.

The underlying issue is that height should also apply to the file upload box, and that does not seem to be happening, as you can check with an example like this:

import gradio as gr
with gr.Blocks() as demo:
    file = gr.File(
        label='File', file_count='single', interactive=True, visible=True,
        height=50,
    )
demo.launch()

and this PR doesn't change that behavior.

@hannahblair
Copy link
Collaborator Author

hannahblair commented Dec 17, 2024

Oh you're right, I massively jumped the gun with this one! Pushing up actual fixes shortly

@abidlabs
Copy link
Member

Nice @hannahblair indeed this fixes it for me. Perhaps we add a story to prevent regressions.

@hannahblair
Copy link
Collaborator Author

also this isn't ideal whenever upload is less than 100px but something to fix in another PR and pretty niche.

Screenshot 2024-12-17 at 16 27 25

@abidlabs
Copy link
Member

agreed

@hannahblair hannahblair enabled auto-merge (squash) December 17, 2024 16:40
@hannahblair hannahblair merged commit 2700d18 into main Dec 17, 2024
23 checks passed
@hannahblair hannahblair deleted the file-height branch December 17, 2024 16:59
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.

Setting height on gr.File() has no effect
3 participants