-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
🪼 branch checks and previews
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" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
f44e454
to
df12767
Compare
@@ -25,6 +25,8 @@ | |||
from pydantic import BaseModel as BaseModelV1 | |||
from pydantic import ValidationError, schema_of | |||
|
|||
JsonValue = Any |
There was a problem hiding this comment.
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
JsonValue = Any | |
JsonValue = Union[Dict, List] |
gradio/processing_utils.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
test/components/test_json.py
Outdated
if postprocessed_value is None: | ||
assert postprocessed_value is None |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brainfart - fixed!
There was a problem hiding this 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.
8fd0b6b
to
112cd5d
Compare
Description
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
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
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh