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

Playground exclude unavailable packages #9998

Merged
merged 6 commits into from
Dec 2, 2024

Conversation

whitphx
Copy link
Member

@whitphx whitphx commented Nov 19, 2024

Description

LLM can generate an app that imports Python standard libraries and the LLM-based requirement list generator can add even these package names, which causes the following error.

PythonError: Traceback (most recent call last):
File "/lib/python3.12/site-packages/micropip/_commands/install.py", line 146, in install
raise ValueError(
ValueError: Can't find a pure Python 3 wheel for: 'random'
See: https://pyodide.org/en/stable/usage/faq.html#why-can-t-micropip-find-a-pure-python-wheel-for-a-package

This PR fixes it by checking if the package exists on PyPI and removing unavailable ones from the generated requirements.

Example:
https://87fa2dfb.gradio-website.pages.dev/playground?demo=Hello_World&code=IyBTYW1wbGUgR3JhZGlvIGFwcCB1c2luZyB0aGUgcmFuZG9tIHBhY2thZ2UKaW1wb3J0IGdyYWRpbyBhcyBncgppbXBvcnQgcmFuZG9tCgojIERlZmluZSBhIGZ1bmN0aW9uIHRoYXQgZ2VuZXJhdGVzIGEgcmFuZG9tIGdyZWV0aW5nCmRlZiByYW5kb21fZ3JlZXQobmFtZSk6CiAgICBncmVldGluZ3MgPSBbIkhlbGxvIiwgIkhpIiwgIkhleSIsICJHcmVldGluZ3MiXQogICAgcmV0dXJuIGYie3JhbmRvbS5jaG9pY2UoZ3JlZXRpbmdzKX0ge25hbWV9ISIKCiMgQ3JlYXRlIGEgR3JhZGlvIGludGVyZmFjZSB0aGF0IHRha2VzIGEgdGV4dGJveCBpbnB1dCwgcnVucyBpdCB0aHJvdWdoIHRoZSByYW5kb21fZ3JlZXQgZnVuY3Rpb24sIGFuZCByZXR1cm5zIG91dHB1dCB0byBhIHRleHRib3guCmRlbW8gPSBnci5JbnRlcmZhY2UoZm49cmFuZG9tX2dyZWV0LCBpbnB1dHM9InRleHRib3giLCBvdXRwdXRzPSJ0ZXh0Ym94IikKCiMgTGF1bmNoIHRoZSBpbnRlcmZhY2UuCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICBkZW1vLmxhdW5jaChzaG93X2Vycm9yPVRydWUp&reqs=

The prompt that generated the example app above:

Sample app using the random package

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Nov 19, 2024

🪼 branch checks and previews

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

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/0afa4717dbf457ad06494959f3528273fde9ddf2/gradio-5.7.1-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/0afa4717dbf457ad06494959f3528273fde9ddf2/gradio-client-1.8.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/0afa4717dbf457ad06494959f3528273fde9ddf2/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Nov 19, 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.

Playground exclude unavailable packages

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 requested review from abidlabs, aliabd and pngwn November 19, 2024 15:08
@whitphx whitphx marked this pull request as ready for review November 19, 2024 15:09
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.

Looks great @whitphx! just need to fix the workerurl

Comment on lines 23 to 24
// const workerUrl = "https://playground-worker.pages.dev/api/generate";
const workerUrl = "http://localhost:5174/api/generate";
Copy link
Collaborator

Choose a reason for hiding this comment

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

you forgot to switch them back

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops

Comment on lines 23 to 24
// const workerUrl = "https://playground-worker.pages.dev/api/generate";
const workerUrl = "http://localhost:5174/api/generate";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// const workerUrl = "https://playground-worker.pages.dev/api/generate";
const workerUrl = "http://localhost:5174/api/generate";
const workerUrl = "https://playground-worker.pages.dev/api/generate";
// const workerUrl = "http://localhost:5174/api/generate";

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

@whitphx whitphx requested a review from aliabd November 30, 2024 00:41
@whitphx
Copy link
Member Author

whitphx commented Nov 30, 2024

@aliabd Thanks, I updated the PR.

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.

Great everything lgtm! thanks @whitphx

@whitphx whitphx enabled auto-merge (squash) December 2, 2024 01:36
@whitphx whitphx merged commit 6cc13f5 into main Dec 2, 2024
23 of 24 checks passed
@whitphx whitphx deleted the playground-exclude-unavailable-packages branch December 2, 2024 01:37
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.

3 participants