-
-
Notifications
You must be signed in to change notification settings - Fork 499
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
Add JupyterLite build and instructions #4122
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4122 +/- ##
==========================================
- Coverage 83.57% 74.54% -9.03%
==========================================
Files 223 224 +1
Lines 33300 33355 +55
==========================================
- Hits 27829 24866 -2963
- Misses 5471 8489 +3018
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
I could not get the notebook to run. Even after I updated the first cell to
import piplite
await piplite.install(['panel', 'altair', 'pyodide_http'])
import pyodide_http
pyodide_http.patch_all() # Patch all libraries
Getting this traceback:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In [9], line 33
24 query = ' & '.join(
25 f'{crange[0]:.3f} <= `{col}` <= {crange[1]:.3f}'
26 for col, crange in selection.items()
27 )
28 return pn.pane.DataFrame(df.query(query), width=600)
30 pn.Column(
31 'Select points on the plot and watch the linked table update.',
32 sizing_mode='stretch_width'
---> 33 ).servable()
35 pn.Row(
36 vega_pane,
37 pn.Column(
(...)
40 )
41 )
File /lib/python3.10/site-packages/panel/viewable.py:382, in ServableMixin.servable(self, title, location, area, target)
380 elif state._is_pyodide:
381 from .io.pyodide import _get_pyscript_target, write
--> 382 target = target or _get_pyscript_target()
383 if target is not None:
384 asyncio.create_task(write(target, self))
File /lib/python3.10/site-packages/panel/io/pyodide.py:258, in _get_pyscript_target()
256 return sys.stdout._out # type: ignore
257 else:
--> 258 raise ValueError("Could not determine target node to write to.")
ValueError: Could not determine target node to write to.
I got the notebook to run with the following: import piplite
await piplite.install(['panel', 'altair', 'pyodide_http'])
import pyodide_http
pyodide_http.patch_all() import panel as pn
pn.extension('vega', comms="default") # comms will be fixed in this PR import altair as alt
import pandas as pd
import bokeh.models.sources
bokeh.models.sources.pd = pd
df = pd.read_json("https://raw.githubusercontent.com/vega/vega/master/docs/data/penguins.json")
brush = alt.selection_interval(name='brush') # selection of type "interval"
chart = alt.Chart(df).mark_point().encode(
x=alt.X('Beak Length (mm):Q', scale=alt.Scale(zero=False)),
y=alt.Y('Beak Depth (mm):Q', scale=alt.Scale(zero=False)),
color=alt.condition(brush, 'Species:N', alt.value('lightgray'))
).properties(
width=250,
height=250
).add_selection(
brush
)
vega_pane = pn.pane.Vega(chart, debounce=10)
def filtered_table(selection):
if selection is None:
return '## No selection'
query = ' & '.join(
f'{crange[0]:.3f} <= `{col}` <= {crange[1]:.3f}'
for col, crange in selection.items()
)
return pn.pane.DataFrame(df.query(query), width=600)
pn.Column(
'Select points on the plot and watch the linked table update.',
sizing_mode='stretch_width'
)# .servable() <- Does not work if this is served.
pn.Row(
vega_pane,
pn.Column(
pn.bind(filtered_table, vega_pane.selection.param.brush),
scroll=True, width=650, height=300
)
) |
Instructions for building the Jupyterlite are as follows: python ./scripts/build_pyodide_wheels.py lite/pypi
python ./scripts/generate_panelite_content.py
jupyter lite build --lite-dir lite --output-dir lite/dist |
Will we always have to make a special build to support Panel? Or will it be supported in default build of Jupyter lite some day? |
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.
It sounds pretty complicated still!
Unless we can convince Jupyterlite folks to add |
9c265f9
to
498ae09
Compare
Some more comments:
I like the idea of the script folder and want it to be used more and not necessarily limited to python files. Like why not have a python ./scripts/build_pyodide_wheels.py lite/pypi
python ./scripts/generate_panelite_content.py
jupyter lite build --lite-dir lite --output-dir lite/dist Maybe in a future PR, a more selective list of imports can be done per notebook for the |
|
Hasn't been redeployed in over 6 months. That said it works fine as long as you don't try to install ipywidgets (OR pin ipywidgets<8) |
Fixes #3605
Fixes #4110