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

visual() / threejs issue with Jupyter Lab #338

Open
vukk opened this issue Jan 15, 2021 · 4 comments
Open

visual() / threejs issue with Jupyter Lab #338

vukk opened this issue Jan 15, 2021 · 4 comments

Comments

@vukk
Copy link

vukk commented Jan 15, 2021

The following bug seems to be present when using Jupyter Lab notebooks:
Writing

using Polymake;
p2 = @pm polytope.Polytope{}(POINTS=[1 -1 -1; 1 1 -1; 1 -1 1; 1 1 1; 1 0 0], INPUT_LINEALITY=[0 1 0])
visual(p2)

results in Uncaught ReferenceError: requirejs is not defined in the web console.

Similar issues in other packages, reported elsewhere:

Version information:
JupyterLab Version 3.0.5
Julia 1.5.3
Polymake.jl 0.5.5
Polymake.version() -> v"4.3.0"

Workaround:
ThreeJS works in a classic notebook. Open your notebook as a classic notebook in Jupyter Lab via Help -> Launch Classic Notebook.

@kalmarek
Copy link
Contributor

@vukk thanks for reporting, but reading the discourse thread I couldn't understand what is the underlying problem and if there is something we could do about. Will the issue be resolved in jupyterlab (i.e. upstream?)


As a sidenote you can use

using Polymake
p2 = polytope.Polytope(POINTS=[1 -1 -1; 1 1 -1; 1 -1 1; 1 1 1; 1 0 0], INPUT_LINEALITY=[0 1 0])
visual(p2)

without macro magic ;)

@benlorenz
Copy link
Member

benlorenz commented Jan 16, 2021

The underlying problem is that the normal jupyter interface has RequireJS loaded and we use that to load three.js from within the notebook. But jupyterlab does not have requirejs active and I don't think this will change, it seems to be a different design that we are not compatible with right now.
There does seem to be a pythreejs package that can also be installed for jupyterlab, but that seems rather complicated from a user-perspective in comparison to just running the visual command ....

Maybe you could try installing jupyter-require ? But I don't know if this needs any extra stuff in the notebook to make it work.
Edit: or maybe jupyterlab_requirejs since the jupyter-require repo is archived ...

@vukk
Copy link
Author

vukk commented Jan 16, 2021

The underlying problem is that the normal jupyter interface has RequireJS loaded and we use that to load three.js from within the notebook. But jupyterlab does not have requirejs active and I don't think this will change, it seems to be a different design that we are not compatible with right now.

This is correct. I'd add that the JupyterLab documentation states:

JupyterLab will eventually replace the classic Jupyter Notebook. Throughout this transition, the same notebook document format will be supported by both the classic Notebook and JupyterLab.

The pythreejs package seems to be more for writing custom javascript into your notebook for visualization.

I'm not sure if it is possible right now for you, and how they work within jupyter, but in the long run I'd look into trying to use native ES6 imports

If I was working in frontend/fullstack right now, I'd try to fix this myself. However, I'm unfortunately a bit out of practice and currently deep in the thesis swamp :)

@benlorenz
Copy link
Member

Thanks a lot for the input, we will try look into this but it might take a bit.

If I remember correctly we had plenty of problems getting this to work at all when we started this (and then never really touched it because it was working), but probably things are somewhat better now.
At least it looks like the threejs examples that we need are available as modules now.

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

No branches or pull requests

3 participants