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

Render With Panel work with Different Kernels/Conda Environments in JupyterLab #3436

Closed
iwalmsley opened this issue Apr 20, 2022 · 12 comments
Closed
Labels
type: enhancement Minor feature or improvement to an existing feature

Comments

@iwalmsley
Copy link

Hi there, thanks very much for the software, very much enjoying using it.

Is your feature request related to a problem? Please describe.

In my team we make heavy use of Conda environments, hence although we have a shared JupyterLab image which includes panel, I might be working in a Conda environment with contains a number of custom packages, however when I select "Render with Panel", this uses the base environment of Jupyter, hence fails to load, e.g;

import intake
import panel as pn

pn.extension()
col = pn.Column(
  '#Title',
)
col.servable()

Which works fine when I run the cell gives the following when I select render;

ModuleNotFoundError: No module named 'intake'
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/bokeh/application/handlers/code_runner.py", line 231, in run
    exec(self._code, module.__dict__)
  File "/data/notebooks/jupyterlab-juliatest/wrf-panel-app/Untitled.ipynb", line 7, in <module>
    "metadata": {},
ModuleNotFoundError: No module named 'intake'

This is frustrating as although I can quite easily run the cells and simulate using it, it's much nicer to render the entire app in a separate panel.

Describe the solution you'd like

It'd be great if the Conda environment active in the current Kernel was used to render the panel app. I do understand that panel itself would need to be installed in the environment as well which does make things a bit confusing.

@philippjfr
Copy link
Member

Thanks for the issue, I do not believe this to be possible to be honest. The "Preview" component works using a jupyter serverextension which by design has to run in the same environment as the Jupyter server.

@iwalmsley
Copy link
Author

Thanks a lot for the response, closing the request as not possible!

@philippjfr
Copy link
Member

Honestly it does seem like it worth investigating. Maybe just maybe the server extension could determine the kernel set in the kernelspec of the notebook and somehow launch it and then execute the app in that context. So let's keep it open for now in case someone gets a chance to get investigate further.

@philippjfr philippjfr reopened this Apr 20, 2022
@philippjfr philippjfr added the type: enhancement Minor feature or improvement to an existing feature label Apr 21, 2022
@tlvu
Copy link
Contributor

tlvu commented Apr 22, 2022

I have a reproducible runtime environment on Binder here https://mybinder.org/v2/gh/Ouranosinc/PAVICS-e2e-workflow-tests/47ef7b0c668acc84cb9c1c7cedc2f135aa54dd3a.

Very similar problem, the green icon "Render with Panel" do not work with the notebook TEST-panel-servable.ipynb that is absolutely trivial:

import panel as pn
pn.panel('# Ceci est un test').servable()

That same trivial notebook work fine under the Panel launcher (https://github.com/holoviz/jupyter-panel-proxy), try it on my Binder link above.

@iwalmsley
Copy link
Author

iwalmsley commented Apr 29, 2022

One thing I have noticed is that this seems to render fine when using the Render with Voila equivalent button for the voila project, however it's not interactive.

@tlvu
Copy link
Contributor

tlvu commented Apr 29, 2022

"Render with Panel" green button works fine for me know. Updating here in case this helps someone.

There was 2 issues found: I had package handcalcs that somehow was interfering with the button (#3440 (comment)), then there was a regression with root_dir support that my PR #3469 fixed.

My JupyterLab and Panel were not installed in the base Conda env, to answer the original concern in this issue about getting it working outside of the base conda env.

My JupyterLab image is launched by JupyterHub this way https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/blob/c74ad1e5c2844aa0e16726c0bdfbabf972122f12/docker/Dockerfile#L105 maybe it could provide some hint.

@iwalmsley
Copy link
Author

@tlvu Can I confirm when you say the JupyterLab and Panel were not installed in the base Conda env, did they still share the same conda environment themselves?

This issue above is relating to a problem whereby JupyterLab and the active kernel than runs panel are in different conda environments, so would be interested if this is working for you.

@tlvu
Copy link
Contributor

tlvu commented May 27, 2022

@tlvu Can I confirm when you say the JupyterLab and Panel were not installed in the base Conda env, did they still share the same conda environment themselves?

This issue above is relating to a problem whereby JupyterLab and the active kernel than runs panel are in different conda environments, so would be interested if this is working for you.

@iwalmsley

I confirm JupyterLab and Panel are both not installed in the base Conda env. In my case, they are both installed in the birdy conda env https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/blob/f8e5141bb85698ddc1ec62953494cc9701872571/docker/environment.yml#L2

@markqiu
Copy link

markqiu commented Aug 16, 2022

I've the same environment list tlvu and with the same problem.

@MarcSkovMadsen
Copy link
Collaborator

It might be worth investigating how the Voila Jupyter preview handles this or reach out to the Jupyter folks to hear their thoughts on this.

@philippjfr
Copy link
Member

It might be worth investigating how the Voila Jupyter preview handles this or reach out to the Jupyter folks to hear their thoughts on this.

They can just piggyback on the existing Jupyter kernel infrastructure, i.e. grab the desired kernel from the notebook metadata and ask Jupyter to run the notebook in that kernel. I suppose we could try to do the same although I've never tried running a whole Panel application in a kernel.

@MarcSkovMadsen
Copy link
Collaborator

I don't even know what a kernel really is :-) And why its called a kernel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants