spacetelescope / jdaviz

JWST astronomical data analysis tools in the Jupyter platform
https://jdaviz.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
141 stars 74 forks source link

bqplot + glue plotting issue #13

Closed nmearl closed 5 years ago

nmearl commented 5 years ago

Currently, there's an issue with rendering bqplots that are provided by the glue interface. While normal bqplots render fine in the desktop and web page environments, when utilizing glue to generate the plots as part of the ipywidgets "application", the rendering is mangled with various errors in the browser console.

Screen Shot 2019-05-20 at 11 52 36 AM
astrofrog commented 5 years ago

One issue that might be confusing things is that ipyastroimage (now bqplot-image-gl) and the scatter viewer in glue-jupyter both depend on the latest developer version of bqplot (but your app uses the latest stable version). To keep things simple, I'd recommend trying the following widget code:

[
    "filename = '/Users/tom/Projects/STScI/jdaviz/examples/manga-7495-12704-LOGCUBE_fixed.fits'",
    "from glue_jupyter import jglue",
    "app = jglue()",
    "data = app.load_data(filename)[0]",
    "",
    "app.profile1d(data=data)"
]

and if that still doesn't work,

[
    "filename = '/Users/tom/Projects/STScI/jdaviz/examples/manga-7495-12704-LOGCUBE_fixed.fits'",
    "from glue_jupyter import jglue",
    "app = jglue()",
    "data = app.load_data(filename)[0]",
    "",
    "app.profile1d(data=data, widget='matplotlib')"
]

to use the Matplotlib widget.

I was unable to run this locally to debug, as I ran into the following error:

Uncaught ReferenceError: require is not defined
    at (index):16

but if you can provide advice on how to solve that, I can investigate further.

nmearl commented 5 years ago

Uncaught ReferenceError: require is not defined at (index):16

Can be ignored -- it's only used when the website is wrapped in electron and show not effect the normal website operation. If you'd rather not see the error, you can comment out line 16 of the index.html file.

astrofrog commented 5 years ago

For some reason I'm getting the following error when running yarn run build:

ERROR in ./node_modules/bqplot-image-gl/lib/imagegl.js
Module not found: Error: Can't resolve 'raw-loader' in '/home/tom/Projects/STScI/jdaviz/web/node_modules/bqplot-image-gl/lib'
 @ ./node_modules/bqplot-image-gl/lib/imagegl.js 113:36-88
 @ ./node_modules/bqplot-image-gl/lib/index.js
 @ ./dist/manager.js
 @ ./dist/index.js

ERROR in ./node_modules/bqplot-image-gl/lib/imagegl.js
Module not found: Error: Can't resolve 'raw-loader' in '/home/tom/Projects/STScI/jdaviz/web/node_modules/bqplot-image-gl/lib'
 @ ./node_modules/bqplot-image-gl/lib/imagegl.js 112:34-84
 @ ./node_modules/bqplot-image-gl/lib/index.js
 @ ./dist/manager.js
 @ ./dist/index.js
error Command failed with exit code 2.

any idea what this could be caused by? (I updated the code locally to use bqplot-image-gl instead of ipyastroimage)

nmearl commented 5 years ago

Module not found: Error: Can't resolve 'raw-loader' in '/home/tom/Projects/STScI/jdaviz/web/node_modules/bqplot-image-gl/lib'

This suggests that the raw-loader isn't in the dependencies section of the bqplot-image-gl package.json (as opposed to the devDependencies).

nmearl commented 5 years ago

@astrofrog and I were able to get a test version of the plots in glue-jupyter to run. It is quite the setup, and he correctly pointed out that the dev versions of the bqplot libraries are absolutely required as well as the new (and npm-installable) bqplot-image-gl library.

Currently, the setup looks like this:

  1. Clone and install the bqplot python package.
  2. cd to the bqplot/js directory and run an npm install.
  3. cd to jdaviz/web.
  4. Install the dev version of the bqplot node package: yarn add /path/to/bqplot/js.
  5. Run yarn run build then yarn run host.
  6. In another terminal, startup a jupyter kernel with python -m notebook --no-browser --NotebookApp.allow_origin="*" --NotebookApp.disable_check_xsrf=True --NotebookApp.token=''
  7. Go to the web address printed after the yarn run host command.
  8. Profit.
eteq commented 5 years ago

Glad to hear it @nmearl!

Just to be clear though: once release versions of all this stuff are out its only really 6-8 that are necessary, right?

stscijgbot commented 5 years ago

This ticket is now being tracked at DATJPP-85

stscijgbot commented 5 years ago

This ticket is now being tracked at DATJPP-100

stscijgbot commented 5 years ago

This ticket is now being tracked at DATJPP-108

nmearl commented 5 years ago

@eteq That's right (also note that current install instructions can be found here).

nmearl commented 5 years ago

Also, it now works, so closing. 😛