BrownDwarf / gollum

A microservice for programmatic access to precomputed synthetic spectral model grids in astronomy
https://gollum-astro.readthedocs.io/
MIT License
20 stars 5 forks source link

Using dashboards #115

Closed DanielAndreasen closed 3 months ago

DanielAndreasen commented 3 months ago

Hi again,

As you might have noticed, I'm not a big jupyter fan. I prefer to run scripts directly from the terminal, but that is not possible with the dashboard (which seems to be the coolest feature); https://gollum-astro.readthedocs.io/en/latest/tutorials/gollum_demo_Sonora_and_BDSS.html.

I was poking around, and it seems there is running some kind of service, and some calls to bokeh. Therefore it does not seem straightforward to make it work like I want. I tried in jupyter-notebook (something I haven't opened for many years, so I might have done something wrong), but couldn't get that to work either. Here are the errors I got:

Processing Teff=2400K|logg=5.50|Z=0.5: 100%|███████████████████████████████████████████████████████████████████████████████████████████| 891/891 [01:03<00:00, 14.04it/s]

594 files not found; grid may not cover given parameter ranges fully

ERROR:tornado.application:Uncaught exception GET /autoload.js?bokeh-autoload-element=a25b0148-cc1f-44d2-90ff-a621dc0a2c73&bokeh-absolute-url=http://localhost:44125&resources=none (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:44125', method='GET', uri='/autoload.js?bokeh-autoload-element=a25b0148-cc1f-44d2-90ff-a621dc0a2c73&bokeh-absolute-url=http://localhost:44125&resources=none', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/tornado/web.py", line 1790, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/server/views/autoload_js_handler.py", line 62, in get
    session = await self.get_session()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/server/views/session_handler.py", line 145, in get_session
    session = await self.application_context.create_session_if_needed(session_id, self.request, token)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/server/contexts.py", line 240, in create_session_if_needed
    self._application.initialize_document(doc)
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/application/application.py", line 190, in initialize_document
    h.modify_document(doc)
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/application/handlers/function.py", line 140, in modify_document
    self._func(doc)
  File "/home/daniel/Documents/programming/astro/gollum/src/gollum/sonora.py", line 515, in create_interact_ui
    fig = figure(
          ^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/plotting/_figure.py", line 196, in __init__
    self._raise_attribute_error_with_matches(name, names | opts.properties())
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/core/has_props.py", line 379, in _raise_attribute_error_with_matches
    raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")
AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
ERROR:tornado.application:Uncaught exception GET /autoload.js?bokeh-autoload-element=a25b0148-cc1f-44d2-90ff-a621dc0a2c73&bokeh-absolute-url=http://localhost:44125&resources=none (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:44125', method='GET', uri='/autoload.js?bokeh-autoload-element=a25b0148-cc1f-44d2-90ff-a621dc0a2c73&bokeh-absolute-url=http://localhost:44125&resources=none', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/tornado/web.py", line 1790, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/server/views/autoload_js_handler.py", line 62, in get
    session = await self.get_session()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/server/views/session_handler.py", line 145, in get_session
    session = await self.application_context.create_session_if_needed(session_id, self.request, token)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/server/contexts.py", line 240, in create_session_if_needed
    self._application.initialize_document(doc)
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/application/application.py", line 190, in initialize_document
    h.modify_document(doc)
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/application/handlers/function.py", line 140, in modify_document
    self._func(doc)
  File "/home/daniel/Documents/programming/astro/gollum/src/gollum/sonora.py", line 515, in create_interact_ui
    fig = figure(
          ^^^^^^^
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/plotting/_figure.py", line 196, in __init__
    self._raise_attribute_error_with_matches(name, names | opts.properties())
  File "/home/daniel/Documents/programming/astro/gollum/.venv/lib/python3.12/site-packages/bokeh/core/has_props.py", line 379, in _raise_attribute_error_with_matches
    raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")
AttributeError: unexpected attribute 'plot_height' to figure, similar attributes are outer_height, height or min_height
ERROR:tornado.access:500 GET /autoload.js?bokeh-autoload-element=a25b0148-cc1f-44d2-90ff-a621dc0a2c73&bokeh-absolute-url=http://localhost:44125&resources=none (127.0.0.1) 63.24ms
ERROR:tornado.access:500 GET /autoload.js?bokeh-autoload-element=a25b0148-cc1f-44d2-90ff-a621dc0a2c73&bokeh-absolute-url=http://localhost:44125&resources=none (127.0.0.1) 63.24ms

This is more than I can debug quickly. I have installed version 3.4.1 of bokeh. Any ideas what is going wrong here?

Review link: https://github.com/openjournals/joss-reviews/issues/6601

Sujay-Shankar commented 3 months ago

Looking at your error, it's throwing it because Sonora's Bobcat dashboard is using an outdated bokeh figure constructor that uses arguments plot_height and plot_width instead of height and width. I fixed this with the Sonora Diamondback dashboard when I tested it, but forgot to do so with Bobcat as well. This error is fixed in the recent commit, I've updated the constructor to use the correct arguments.

With regards to running the dashboard outside of jupyter notebook, I think we never anticipated use cases outside of jupyter so the dashboard as it currently is doesn't say, pop out into its own window and do stuff from there. I think you're right in that bokeh has some functionality that would let one do this, but it would require an overhaul of the way we handle dashboard objects and possibly a new script that bokeh would have to use to pop open a window that non-jupyter users could use. I'll see what I can do about this and get back to you.

DanielAndreasen commented 3 months ago

I will try it again soon, and let you know if it works better now. Unfortunately I do not have much free time these days. Sorry for the late replies.

DanielAndreasen commented 3 months ago

Okay, the dashboard works really well for me now. The only thing missing before you can close this, is to update the notebook. Right now it has an AssertionError in the documentation, which does not happen. So I guess you just have to run the notebook again, and commit it.

Sujay-Shankar commented 3 months ago

Great, I'll rerun that notebook and close that issue when the documentation has been updated.

Sujay-Shankar commented 3 months ago

The notebook has been rerun and committed, just some tiny commits left until the errors are cleaned up in full. To your earlier point, I think that as gollum currently is and has been, the dashboard was something that required jupyter. While I do agree with you and want to make jupyter-less functionality possible, I'd like to put that up in a future version release where we can do the major design overhauls and keep everything clean instead of trying to hack it into the current release. Thoughts?

DanielAndreasen commented 3 months ago

I agree with that. At that point, the review should be over, but feel free to ask me for testing it again.

Sujay-Shankar commented 3 months ago

I've created a standalone issue about it so that it's visible outside of the JOSS review process, so we can safely close this one.