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 local bundled paths for template resources #1891

Merged

Conversation

AjayThorve
Copy link
Contributor

While #1821 was partially resolved thanks to #1830 , the template resources were still not loading due to the same path issues. This PR aims to resolve those. Testing in a jupyter_server_proxy env and jupyterlab without proxy seems to work for the changes proposed.

This allows the following example to work:

import panel as pn
import numpy as np
import holoviews as hv

pn.extension()
react = pn.template.ReactTemplate(title='React Template')

pn.config.sizing_mode = 'stretch_both'

xs = np.linspace(0, np.pi)
freq = pn.widgets.FloatSlider(name="Frequency", start=0, end=10, value=2)
phase = pn.widgets.FloatSlider(name="Phase", start=0, end=np.pi)

@pn.depends(freq=freq, phase=phase)
def sine(freq, phase):
    return hv.Curve((xs, np.sin(xs*freq+phase))).opts(
        responsive=True, min_height=400)

@pn.depends(freq=freq, phase=phase)
def cosine(freq, phase):
    return hv.Curve((xs, np.cos(xs*freq+phase))).opts(
        responsive=True, min_height=400)

react.sidebar.append(freq)
react.sidebar.append(phase)

# Unlike other templates the `ReactTemplate.main` area acts like a GridSpec 
react.main[:4, :6] = pn.Card(hv.DynamicMap(sine), title='Sine')
react.main[:4, 6:] = pn.Card(hv.DynamicMap(cosine), title='Cosine')

react.show(port=5000) # go to localhost:5000
# OR
react.show(websocket_origin="localhost:8888", port=5000) # and then go to localhost:8888/proxy/5000/

cc @philippjfr

@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #1891 (a0aeec4) into master (316ebbc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1891   +/-   ##
=======================================
  Coverage   85.10%   85.10%           
=======================================
  Files         152      152           
  Lines       18814    18815    +1     
=======================================
+ Hits        16011    16012    +1     
  Misses       2803     2803           
Impacted Files Coverage Δ
panel/template/base.py 72.77% <100.00%> (+0.07%) ⬆️
panel/util.py 83.47% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 316ebbc...a0aeec4. Read the comment docs.

panel/template/base.py Outdated Show resolved Hide resolved
@philippjfr philippjfr merged commit 8d91eff into holoviz:master Jan 12, 2021
@philippjfr
Copy link
Member

Thanks @AjayThorve. Will get a dev release out tomorrow and may release 0.10.3 with some backported fixes including this one.

philippjfr pushed a commit that referenced this pull request Jan 14, 2021
* fix local bundled paths for template resources

* replace app_url with state.base_url
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.

2 participants