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 JSON component outputs handled properly in postprocess #8292

Merged
merged 7 commits into from
May 15, 2024

Conversation

freddyaboulton
Copy link
Collaborator

Description

  • Makes sure json component outputs do not get moved to cache
  • EventData instances must only reference data in the cache

🎯 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
Copy link
Contributor

gradio-pr-bot commented May 14, 2024

🪼 branch checks and previews

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

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/112cd5daaabd1e61230b266bfd2d44a230dc7ac3/gradio-4.31.2-py3-none-any.whl

Install Gradio Python Client from this PR

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

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented May 14, 2024

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

Ensure JSON component outputs handled properly in postprocess

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.

@freddyaboulton freddyaboulton added v: patch A change that requires a patch release t: fix A change that implements a fix labels May 14, 2024
@freddyaboulton freddyaboulton force-pushed the add-json-data-model-event-data-cache branch from f44e454 to df12767 Compare May 14, 2024 23:24
@freddyaboulton freddyaboulton marked this pull request as ready for review May 15, 2024 15:04
@@ -25,6 +25,8 @@
from pydantic import BaseModel as BaseModelV1
from pydantic import ValidationError, schema_of

JsonValue = Any
Copy link
Member

Choose a reason for hiding this comment

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

We can be more specific no? Something like

Suggested change
JsonValue = Any
JsonValue = Union[Dict, List]

@@ -341,6 +342,24 @@ def move_resource_to_block_cache(
return block.move_resource_to_block_cache(url_or_file_path)


def is_file_obj(data: dict | JsonData):
Copy link
Member

Choose a reason for hiding this comment

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

Is this method only added for type-checking purposes? Because client_utils.is_file_obj already checks to see if data is a dict?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea you're right another brain fart hehe

Comment on lines 98 to 99
if postprocessed_value is None:
assert postprocessed_value is None
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Brainfart - fixed!

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.

Thanks @freddyaboulton for taking care of this! Changes look good to me, left a couple of nits.

@freddyaboulton freddyaboulton force-pushed the add-json-data-model-event-data-cache branch from 8fd0b6b to 112cd5d Compare May 15, 2024 21:27
@freddyaboulton freddyaboulton enabled auto-merge (squash) May 15, 2024 21:28
@freddyaboulton freddyaboulton merged commit ee1e294 into main May 15, 2024
7 checks passed
@freddyaboulton freddyaboulton deleted the add-json-data-model-event-data-cache branch May 15, 2024 21:38
@pngwn pngwn mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: fix A change that implements a fix v: patch A change that requires a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants