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

Clean up gr.DataFrame.postprocess() and fix issue with getting headers of empty dataframes #10476

Merged
merged 11 commits into from
Jan 31, 2025

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Jan 31, 2025

Closes: #10474, refactored the .postprocess() method significantly to break it up into smaller methods & added tests for each method.

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 31, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
🦄 Changes detected! Details

Install Gradio from this PR

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

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/b17392159b0d8eace2a533e6333dce5e90ebaf27/gradio-client-1.10.0.tgz

Use Lite from this PR

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

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 31, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Clean up gr.DataFrame.postprocess() and fix issue with getting headers of empty dataframes

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 marked this pull request as ready for review January 31, 2025 10:20
Copy link
Collaborator

@hysts hysts left a comment

Choose a reason for hiding this comment

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

I confirmed that the issue is resolved and that my Spaces using gr.Dataframe works as expected with the wheel in this PR as well. Thanks!

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 @abidlabs

if len(value) > 0 and isinstance(value[0], list):
return len(value[0]) == 0
return len(value) == 0
elif isinstance(value, dict):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think the logic for dict is inconsistent. A df is empty if it has no values (even if his has headers). The dict is considered empty only if it doesn't have headers and values.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah great catch thanks

@abidlabs abidlabs merged commit 017ed46 into main Jan 31, 2025
22 checks passed
@abidlabs abidlabs deleted the df-header branch January 31, 2025 21:11
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.

Column names of gr.Dataframe disappear when the rows are empty
4 participants