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

ihaskell-hvega with JupyterLab 2 #141

Open
jamesdbrock opened this issue Apr 27, 2020 · 9 comments
Open

ihaskell-hvega with JupyterLab 2 #141

jamesdbrock opened this issue Apr 27, 2020 · 9 comments

Comments

@jamesdbrock
Copy link

jamesdbrock commented Apr 27, 2020

Hi @DougBurke ,ihaskell-hvega seems to have stopped working since I upgraded https://github.com/jamesdbrock/ihaskell-notebook to JuptyerLab 2. I can't find any errors at build time or runtime on backend or frontend, it just fails to render vlShow commands in the notebook.

Before I start looking into this, can you tell me if ihaskell-hvega is known to work, or known to not work, with JupyterLab 2? Have you tried it?

@jamesdbrock
Copy link
Author

This may be relevant:

https://jupyterlab.readthedocs.io/en/stable/getting_started/changelog.html#v2-0-0

v2.0.0

  • Removed the vega 4 and vega-lite 2 renderers (vega 5 and vega-lite 4 is included in JupyterLab by default). These legacy renderers may be available via custom extensions (#7650, #7523, #7658)

@jamesdbrock
Copy link
Author

jamesdbrock commented Apr 27, 2020

config = "requirejs({paths:{vg:" <> jsname "vega" "3.2.1"

<> ",vl:" <> jsname "vega-lite" "2.3.0"

@jamesdbrock
Copy link
Author

Oh this looks suspicious.

https://github.com/vega/vega/releases/tag/v5.0.0

  • As a consequence of the two changes above, versions of Vega-Lite prior to v3 will not work with Vega v5. Please adjust your versions accordingly.

That might be the culprit.

@DougBurke
Copy link
Owner

DougBurke commented Apr 27, 2020

The current Jupyter Lab and notebook interaction in ihaskell-hvega is less than ideal.

notebook

Jupyter notebooks use the standard IHaskell IHaskellDisplay class to add in the JS code to display the visualization - this is https://github.com/DougBurke/hvega/blob/master/ihaskell-hvega/src/IHaskell/Display/Hvega.hs#L97

The problem with this is that is pulls in old versions of the libraries - e.g. VegaEmbed 3.5.2 - and so won't work correctly with more-modern features. When I last tried to update these versions I ended up with JS problems. I forget now the details, but I think it involved the auto-loading done by require. I haven't had the energy to track this down further, since I was hoping that Jupyter Lab would resolve this without me having to do any work.

EDITED TO ADD I believe this problem has been resolved with the ihaskell-hvega-0.3.0.0 release.

lab

Since I have a IHaskellDisplay set up for Jupyter notebook, I used the vlShow "trick" for the lab interface to convert the VegaLite type into a new type that I could add a IHaskellDisplay instance for. The aim is that at some point we can flip this so that the lab interface is the default and notebook users would have to use something like vlShow, but that's not important right now!

The problem with this interface - that is https://github.com/DougBurke/hvega/blob/master/ihaskell-hvega/src/IHaskell/Display/Hvega.hs#L158 and also introduced in #12 - is that it relies on the IHaskell vegalite function which - in version 0.10.0.2 - maps to an old version of the mimetype - e.g. https://github.com/gibiansky/IHaskell/blob/master/ipython-kernel/src/IHaskell/IPython/Types.hs#L808 shows application/vnd.vegalite.v2+json

** EDITED TO ADD MORE CONTENT**

There is an update to allow a custom mimetype - see IHaskell/IHaskell#1089 - which has now been released in IHaskell, but it unfortunately does not help (it sends the data as a JSON string rather than a JSON object). We are working on this, but more eyes are always helpful: IHaskell/IHaskell#1173

There is also an added wrinkle (as noted in the JupyterLab discussion) that the supported version for VegaLite depends on whether you have v2 or an older version. I believe you can add support for newer (or older?) mimetypes, but that is getting beyond where I have time/energy to track things.

@DougBurke
Copy link
Owner

@jamesdbrock - I just wanted to get the above written down for reference (and if anyone can provide help for these ;-)

How do you install IHaskell? From stack/cabal, hackage, JupyterWIth, nix, ...?

@jamesdbrock
Copy link
Author

Thanks for writing this all down! My project https://github.com/jamesdbrock/ihaskell-notebook installs IHaskell and hvega from Github, so it would pick up the update with custom mimetype as soon as it was pushed.

@DougBurke
Copy link
Owner

Sorry. Due to personal reasons my time is very limited at the momemt

@jamesdbrock
Copy link
Author

Hi, it looks like you spent some time on this.

68564ba

Thank you very much Doug, all the IHaskell users are very grateful to you.

@DougBurke
Copy link
Owner

So, for referece, the ihaskell-hvega-0.3.0.0 release should now support Vega-Lite v4 when using the jupyter notebook interface.

It's still a mess if you use jupyter lab.

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

2 participants