-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 @gradio/client
always returns the correct data
#8716
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/da4ec7343dbf848047ec3f31d011242fa49727a6/gradio-4.37.2-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@da4ec7343dbf848047ec3f31d011242fa49727a6#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-builds.s3.amazonaws.com/da4ec7343dbf848047ec3f31d011242fa49727a6/gradio-client-1.2.1.tgz |
🦄 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.
|
@@ -187,14 +187,15 @@ export function handle_payload( | |||
|
|||
let updated_payload: unknown[] = []; | |||
let payload_index = 0; | |||
for (let i = 0; i < dependency.inputs.length; i++) { | |||
const input_id = dependency.inputs[i]; | |||
const deps = type === "input" ? dependency.inputs : dependency.outputs; |
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 just need to check which dependencies we care about here and set it accordingly, when handling inputs
we use dependency.inputs
when handling outputs
we use dependency.outputs
.
name: | ||
typeof File !== "undefined" && blob instanceof File | ||
? blob?.name | ||
: undefined |
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 was getting an error about File
not being defined. This check fixes it.
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.
Ah dang, that's a bad bug. Thanks for fixing that @pngwn! Tested and works as expected.
![Screenshot 2024-07-11 at 12 58 47](https://private-user-images.githubusercontent.com/15165908/347807546-465f0480-2f88-494a-8d52-91a555f10b5c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NzA1MDIsIm5iZiI6MTcyNDc3MDIwMiwicGF0aCI6Ii8xNTE2NTkwOC8zNDc4MDc1NDYtNDY1ZjA0ODAtMmY4OC00OTRhLThkNTItOTFhNTU1ZjEwYjVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI3VDE0NTAwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg4YjVlZTM3MWUxMzQ2NWQzYTViZWYzNzU1Y2JkNTcyZGY4ZmVkYjE3YWFiMGYwN2JjZjQyYmMzYTllNzA4MzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.S0jLaf0LRWu_kS3pw-o_QFppfs2m7MsdjDElq8MKmYU)
Description
Closes #8508.
In
handle_payload
which we use to remove state data which is always null, we handle both inputs (request payload) and outputs (response payload) but we were treating everything as if they were inputs. So if there were no input components but there was data returned, it would be removed.Can reproduce fix this script:
Add it to
client/js
astest.js
, runpnpm build
and runnode test.js
.🎯 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