twosigma / beakerx

Beaker Extensions for Jupyter Notebook
http://BeakerX.com
Apache License 2.0
2.8k stars 381 forks source link

Installing Beakerx in a Juptyer image #8003

Open tschm opened 5 years ago

tschm commented 5 years ago

I am trying to install Beakerx via conda in a Docker image based on the Jupyter base-notebook image. I have compiled the following Dockerfile for it:

# Use the Jupyter stack
FROM jupyter/base-notebook:f286528a06ac

# This is needed for beakerx
RUN conda config --env --add pinned_packages 'openjdk>8.0.121'

# Install packages such as rise, pandas, ...
RUN conda install -y -c conda-forge tornado=4.5.3 beakerx=1.3.0

This seems to build and runs happily. I can use the TableDisplay and create simple plots. However, as soon as I try this trivial example:

import pandas as pd
from beakerx import *

import datetime

y = pd.Series([8.7, 8, 8.5])
dates = [datetime.date(2015, 2, 4),
         datetime.date(2015, 2, 5),
         datetime.date(2015, 2, 6)]
plot = TimePlot()
plot.add(Line(x=dates, y=y))
plot.add(ConstantLine(x=pd.Timestamp("2015-02-05")))

I get no output unless I comment the last line! The error message I receive when running the Jupyter server is

[IPKernelApp] ERROR | Exception in comm_msg for d2fe16c7d57d4a68bafa6322f1d0cc82
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/beakerx_magics/kernel_magic.py", line 116, in comm_msg
    comm.handle_msg(msg)
  File "/opt/conda/lib/python3.7/site-packages/ipykernel/comm/comm.py", line 159, in handle_msg
    self._msg_callback(msg)
  File "/opt/conda/lib/python3.7/site-packages/beakerx/plot/chart.py", line 264, in _handle_msg
    params = msg['content']['data']['content']
KeyError: 'content'

Is it a crazy idea to install Beaker in a Jupyter image? Shall I avoid this and only use the Beakerx Docker image as a starting point?

Mjboothaus commented 5 years ago

Hi - the ConstantLine() method doesn’t work with time stamps- see the issue I have reported. The documentation on this is a bit opaque.

Currently you need to convert it to a Unix seconds since 1970 to work.

As to your broader question about BeakerX install - I’ll leave to others :) cheers!

Mjboothaus commented 5 years ago

ConstantLine( ) doesn't appear to work with date values within TimePlot( ) #7988

tschm commented 5 years ago

I have not dogged very deep yet. The ConstantLine works with pd.Timestamp but not Dates in the BeakerX docker image. Have you tried experimenting with it in the Binder environment?