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 kwargs are always in sync across the whole application #7963

Merged
merged 5 commits into from Apr 8, 2024

Conversation

pngwn
Copy link
Member

@pngwn pngwn commented Apr 8, 2024

Description

Closes #7786. Closes #7895.

The issue was not present in dev mode but was present in the built files. So we weren't noticing this behaviour day to day in development.

The root cause, seems to be that the list of props that we were using to listen for changes wasn't the same in dev + build. I'm not 100% why really, its a little confusing but I have confirmed that the approach in this PR works for all modes.

I still need to look at the test, but I need to create a failing test from main first. Will update shortly but the code is good for review.

To test you can use the blocks_flipper demo. This does not behave itself on main but works correctly in dev. You can also use the repro in #7895 as it is the same issue.

Be sure to build the frontend locally and visit port 7860 and not the dev port (9876).

Update

I've update the test. The test was opening the accordion, clicking the slider and then checking that accordion text was on the page. The issue here is that for a brief moment after changing the slider value this is true, so sometimes this was passing (sometime it was failing too but we have retries on).

I've switched it out for a test that opens the accordion, changes the slider value then enters text into the textbox and waits for the server response + state update. This guarantees that the UI state has fully settled before asserting on the accordion contents.

This test passes on this branch but it fails consistently on main.

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Apr 8, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/cdc6cf6b6bcb11f3348969795fb52912ed31ec92/gradio-4.25.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Apr 8, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

ensure kwargs are always in sync across the whole application

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.

@pngwn pngwn marked this pull request as ready for review April 8, 2024 15:16
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.

Can confirm this fixes the bug @pngwn ! Can this demo be added to 2e2 tests?

@@ -28,9 +28,7 @@
construct(_target, args: Record<string, any>[]) {
//@ts-ignore
const instance = new _target(...args);
const props = Object.getOwnPropertyNames(instance).filter(
(s) => !s.startsWith("$")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What was the purpose of the $ guard?

Copy link
Member Author

Choose a reason for hiding this comment

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

In addition to the prop names, there are also some internal svelte things (methods mostly) that start with $. Was always a little hacky.

@pngwn
Copy link
Member Author

pngwn commented Apr 8, 2024

@freddyaboulton Which demo? The blocks flipper is the original test case here and is in the e2e tests, or do you mean the streaming one?

@freddyaboulton
Copy link
Collaborator

Oh weird I didn't know we already had a test! I guess toBeVisible is not the right playwright assertion to use? The test should not be passing right?

@freddyaboulton
Copy link
Collaborator

Good to merge, we can take a look at the test later.

@pngwn
Copy link
Member Author

pngwn commented Apr 8, 2024

I updated that test so that it does / would fail consistently on main. The assertion was okay, its just that the test was running faster than the UI could update. This is why it was flakey. Funnily enough the flake was the 'correct' behaviour.

I've updated the test. The test was opening the accordion, clicking the slider and then checking that accordion text was on the page. The issue here is that for a brief moment after changing the slider value, this is true. So sometimes this was passing (sometimes it was failing too but we have retries on).

I've switched it out for a test that opens the accordion, changes the slider value then enters text into the textbox and waits for the server response + state update. This guarantees that the UI state has fully settled before asserting on the accordion contents.

This test passes on this branch but it fails consistently on main.

@pngwn pngwn merged commit 1eb4c20 into main Apr 8, 2024
8 checks passed
@pngwn pngwn deleted the 7786-accordion branch April 8, 2024 17:12
@pngwn pngwn mentioned this pull request Apr 8, 2024
@freddyaboulton
Copy link
Collaborator

Nice thanks @pngwn !

freddyaboulton pushed a commit that referenced this pull request Apr 11, 2024
* ensure kwargs are always in sync across the whole application

* add changeset

* fix test

* update accordion test

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants