-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix issue with head
param when adding more than one script tag
#6639
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
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/9c28267ffd0b06be3aba3d957a04ae6a16d7d2b2/gradio-4.8.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@9c28267ffd0b06be3aba3d957a04ae6a16d7d2b2#subdirectory=client/python" |
🦄 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.
|
@dawoodkhan82 I can confirm that both scripts are added now. However, they are not actually run. For example, in this app: import gradio as gr
head = """
<script>console.log('hello')</script>
<script>console.log('world')</script>
"""
with gr.Blocks(head=head) as demo:
pass
demo.launch() the console log is empty. Is there a way to force the scripts to run after they have been added to the page? |
@abidlabs Trying to debug, not sure what changed. |
@dawoodkhan82 just fyi I think this was the case before as well -- the script would not get executed |
Based on this part of the original issue:
|
The script being added later shouldn't stop it from being executed. |
Fixed, realized I was pushing to the wrong branch... |
Also, now it works when trying to call an external
|
I took a pass and I wasn't able to get the external script loading to work. @dawoodkhan82 is looking into it! 🙏 |
Beautiful! Works for me. The original code I shared works as well as loading js from an external PR. Here's what I tried: import gradio as gr
import os
head = """
<script type="text/javascript" src="/file=test.js"></script>
<script>console.log('hello')</script>
""".format(path)
with gr.Blocks(head=head) as demo:
pass
demo.launch(allowed_paths=["test.js"]) Here's
|
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.
Awesome stuff @dawoodkhan82
@abidlabs Thanks for the review! |
merging ahead of the release |
Description
Fixes issue with
head
param when adding more than one script tag.Closes: #6426
🎯 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