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

Fix playground to display errors #8689

Merged
merged 6 commits into from
Jul 5, 2024
Merged

Fix playground to display errors #8689

merged 6 commits into from
Jul 5, 2024

Conversation

whitphx
Copy link
Member

@whitphx whitphx commented Jul 3, 2024

Description

The current Playground doesn't display any error but it makes debugging harder (internal post: https://huggingface.slack.com/archives/C02QZLG8GMN/p1719463130950669).
This PR fixes it.

🎯 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

@whitphx whitphx marked this pull request as draft July 3, 2024 07:00
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 3, 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/240d6fb831ec106fa51715bc880b1554dcc6831b/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@240d6fb831ec106fa51715bc880b1554dcc6831b#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/240d6fb831ec106fa51715bc880b1554dcc6831b/gradio-client-1.2.1.tgz

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 3, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
website minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fix playground to display errors

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.

@whitphx whitphx changed the title Fix playground debounce Fix playground to display errors Jul 3, 2024
timeout = setTimeout(() => {
update(code, requirements);
}, 1000);
debounced_run_code && debounced_run_code(code);
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactoring: when the code is changed, call only run_code without install().

mounted = true;
});

function update(code: string, requirements: string[]) {
Copy link
Member Author

Choose a reason for hiding this comment

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

tbh, I couldn't get why this double function calling could suppress errors, but the problem was fixed as a result of the refactoring.

}

let position = 0.5;

let fullscreen = false;
function make_full_screen() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactoring: This method is not used.

@@ -4,6 +4,6 @@ def greet(name):
return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")

Copy link
Member Author

Choose a reason for hiding this comment

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

nit: This change is not related to the problem, but just formatting the code.

@whitphx
Copy link
Member Author

whitphx commented Jul 3, 2024

@abidlabs @aliabd There might be a discussion that displaying an error during editing the code is annoying and it should be suppressed somehow, but I couldn't find it. Do you remember something? Perhaps we should add some "smarter" error notification that doesn't annoy users?

@whitphx whitphx requested review from pngwn, aliabd and abidlabs and removed request for pngwn and aliabd July 3, 2024 07:32
@whitphx whitphx marked this pull request as ready for review July 3, 2024 07:37
@aliabd
Copy link
Collaborator

aliabd commented Jul 4, 2024

@whitphx I also remember some discussion about this. But I think the delay is enough. It used to be that the code would rerun on every change so it was annoying seeing the syntax errors all the time. But with the delay it's really fine.

I'm open to ideas though

Copy link
Collaborator

@aliabd aliabd left a comment

Choose a reason for hiding this comment

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

Changes look great! thanks @whitphx

@whitphx whitphx merged commit edcd574 into main Jul 5, 2024
8 checks passed
@whitphx whitphx deleted the fix-playground-debounce branch July 5, 2024 07:37
@pngwn pngwn mentioned this pull request Jul 4, 2024
dawoodkhan82 pushed a commit that referenced this pull request Jul 10, 2024
* Fix the Playground on the website to trigger run_code() and install() with debounce and to display errors

* Remove an unused function, make_full_screen()

* Format demo/hello_world/run.py

* Update notebook

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
dawoodkhan82 added a commit that referenced this pull request Jul 11, 2024
* latex fix

* format

* add changeset

* fix demo (#8696)

* Better spacing for codeblocks on docs (#8686)

* styling for codeblocks

* add changeset

* formatting

* add changeset

* changes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Add search to website (#8624)

* Update action.yml (#8702)

* Model3D point cloud and wireframe display modes (#8687)

* display modes

* add changeset

* test fixes

* lint

* Update gradio/components/model3d.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* solid

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix playground to display errors (#8689)

* Fix the Playground on the website to trigger run_code() and install() with debounce and to display errors

* Remove an unused function, make_full_screen()

* Format demo/hello_world/run.py

* Update notebook

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* GRADIO_ALLOWED_PATHS & GRADIO_BLOCKED_PATHS comma separated environme… (#8705)

* GRADIO_ALLOWED_PATHS & GRADIO_BLOCKED_PATHS comma separated environment variables

* GRADIO_ALLOWED_PATHS & GRADIO_BLOCKED_PATHS comma separated environment variables

* add changeset

* Document GRADIO_ALLOWED_PATHS and GRADIO_BLOCKED_PATHS

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Ensure JS client `status_callback` functionality works and improve status messages (#8699)

* * bind handle_space_success
* ensure status callbacks work correctly

* add changeset

* test fixes + refactor

* tweak

* test

* Revert "test"

This reverts commit db1afc4.

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Documents auth in the guides, in the view API page, and also types the Blocks.config object  (#8720)

* auth docs

* changes

* add changeset

* add changeset

* add changeset

* type

* changes

* snippets

* import

* add changeset

* changes

* fix typing

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* remove on mount

* merge

* remove onmount

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
Co-authored-by: cocktailpeanut <121128867+cocktailpeanut@users.noreply.github.com>
Co-authored-by: Hannah <hannahblair@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
Development

Successfully merging this pull request may close these issues.

None yet

3 participants