hatchet / hatchet

Analyze graph/hierarchical performance data using pandas dataframes
https://hatchet.readthedocs.io
MIT License
107 stars 37 forks source link

add support for interactive visualizations in jupyter-lab #361

Closed lastephey closed 1 year ago

lastephey commented 3 years ago

Dear Hatchet developers,

We discovered in Issue #360 that the roundtrip-based interactive visualizations work in classic/legacy Jupyter notebook but do not currently work in Jupyer-lab. I observed this same behavior on my laptop and also at NERSC.

In classic Jupyter, this cell produces the expected output:

gf = ht.GraphFrame.from_literal(lit_graph)
%loadVisualization roundtrip_path lit_graph

But in Jupyter-lab, the same cell executes but nothing is displayed.

I would appreciate it if you could add support for interactive Hatchet visualizations Jupyter-lab (the default at NERSC).

If you need additional information please let me know.

Thank you very much, Laurie

ilumsden commented 3 years ago

I can replicate this same issue on my personal desktop (in Windows through WSL). My first thought is that this could be due to some type of settings. Some default behaviors in JupyterLab are different from Jupyter Notebook. I'm looking at that right now.

I also seem to recall reading somewhere that there's some weird incompatibilities between JupyterLab and some IPython behavior (which RoundTrip seems to rely heavily on). I can't seem to find it again, though, so I might be remembering wrong.

ilumsden commented 3 years ago

Hm... From the Chrome Developer Tools, I'm seeing a lot of TypeErrors being raised from something called "jlab_core" (likely JupyterLab) when the loadVisualization cell is run. That's not what I expected. I'm looking at this to see if it could help.

ilumsden commented 3 years ago

I believe I've found the problem. It comes from the first few lines of roundtripTree.js:

(function (element) {
    require(['https://d3js.org/d3.v4.min.js'], function (d3) {
        var cleanTree = argList[0].replace(/'/g, '"');

        var forestData = JSON.parse(cleanTree);

The issue here comes down to the use of requirejs. From this thread on the Jupyter Discourse Form, Jupyter Notebook makes requirejs available on the page, but JupyterLab doesn't. It looks like the recommended way to resolve this on JupyterLab is to make a JupyterLab extension, but I don't know if that's how we'd want to go about this.

lastephey commented 1 year ago

Thanks for your help. Closing in the spirit of Closember.