-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Refactoring <gradio-lite /> component making the code simpler and fixing a Playground mode bug #8693
Conversation
… and manages <Index /> and <Playground />
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/7f99573c9f3382bde55778decaf6e8ccc9a72330/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@7f99573c9f3382bde55778decaf6e8ccc9a72330#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-builds.s3.amazonaws.com/7f99573c9f3382bde55778decaf6e8ccc9a72330/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.
|
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 @whitphx! Tested everything and it all works great.
I had tried to do something like this when I first created the playground element, but I couldn't figure it out. I didn't know you could run the worker_proxy methods (like runPythonCode) inside the svelte file, so I thought I'd have to send them back to the index.ts. Anyway, this is much cleaner!
Sweet, thanks guys! Going to merge this in so that we can do the release tomorrow :) |
Description
Closes: #7942
Currently, the
<Index />
and the<Playground />
components are instantiated at the top level like this:gradio/js/app/src/lite/index.ts
Line 219 in a92c3e8
gradio/js/app/src/lite/index.ts
Line 198 in a92c3e8
However, it makes the code complex and also causes the problem of #7942 because
<Playground />
is recreated upon everyrun_code()
andrun_file()
.This PR fixes it.
<LiteIndex />
that handles both<Index />
and<Playground />
.<Playground />
instance mounted across multiple runs, which solves Undo/redo don't work on the Lite Playground after rerunning #7942 .<Index />
from<Playground />
by using slots API. This became possible due to the change above, as the slots API is available inside components, but can't be used from thenew Playground()
-style usage.