Skip to content

Commit

Permalink
Added shell for accessing odbc to supply data to Jupyter. Fixed a few…
Browse files Browse the repository at this point in the history
… issues by pulling in newer versions of rpy2 and ipywidgets.

1) Added freetds to allow access to database instances using odbc.
2) Create a shell .odbc.ini file that can be filled out to access a database instance.
3) Updated the version of rpy2 since the %R and %%R magic wouldn't work from the Python kernels so that R can be used in cells within a Python sheet.
4) Updated ipywidgets so that the widgets can be used within a Python3 sheet. Without this update it wouldn't show the controls in a Python3 sheet after running the sheet
5) Pinned the conda to jpeg 8 since the ggplot2 graphs wouldn't showup in R sheets.  See jupyter#210
  • Loading branch information
Andrew Stern committed Jun 23, 2016
1 parent 1d398b5 commit 4d5e2cc
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion datascience-notebook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
fonts-dejavu \
gfortran \
unixodbc-dev \
libtool-bin \
autoconf \
automake \
gcc && apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -24,6 +28,8 @@ RUN apt-get update && \
USER jovyan

# R packages including IRKernel which gets installed globally.
# Note that there is a bug with rpy2 where the %R and %%R don't work.
# We need an newer version not yet available on conda to fix this so uninstall and install new version at end.
RUN conda config --add channels r && \
conda install --quiet --yes \
'rpy2=2.7*' \
Expand All @@ -43,8 +49,13 @@ RUN conda config --add channels r && \
'r-nycflights13=0.1*' \
'r-caret=6.0*' \
'r-rcurl=1.95*' \
'r-dbi=*' \
'r-scales=*' \
'r-randomforest=4.6*' && conda clean -tipsy

# Install additional non-conda R packages
RUN R -e 'install.packages(c("ggthemes", "RODBC", "sendmailR", "tis"), repos="http://cran.utstat.utoronto.ca/")'

# Install IJulia packages as jovyan and then move the kernelspec out
# to the system share location. Avoids problems with runtime UID change not
# taking effect properly on the .local folder in the jovyan home dir.
Expand All @@ -56,4 +67,55 @@ RUN julia -e 'Pkg.add("IJulia")' && \
# Show Julia where conda libraries are
# Add essential packages
RUN echo 'push!(Sys.DL_LOAD_PATH, "/opt/conda/lib")' > /home/$NB_USER/.juliarc.jl && \
julia -e 'Pkg.add("Gadfly")' && julia -e 'Pkg.add("RDatasets")' && julia -F -e 'Pkg.add("HDF5")'
julia -e 'Pkg.add("Gadfly")' && julia -e 'Pkg.add("RDatasets")' && julia -F -e 'Pkg.add("HDF5")'

# Fix the graphing issue with ggplot2
# from: https://github.com/jupyter/docker-stacks/issues/210
RUN echo "jpeg 8*" >> /opt/conda/conda-meta/pinned
RUN conda update --all -y

# Add odbc drivers to the install
RUN cd /home/jovyan && \
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz && \
tar xvzf freetds-patched.tar.gz && \
cd /home/jovyan/freetds-1.00.6 && \
./configure --prefix=/home/jovyan/odbcdriver && \
make && \
make install

# Add ODBC configuration file
RUN echo "[ODBC Data Sources]" >> ~/.odbc.ini && \
echo "SQL_DB = Sample Database Configuration" >> ~/.odbc.ini && \
echo "" >> ~/.odbc.ini && \
echo "[Default]" >> ~/.odbc.ini && \
echo "" >> ~/.odbc.ini && \
echo "[SQL_DB]" >> ~/.odbc.ini && \
echo "Description = Sample Database Configuration" >> ~/.odbc.ini && \
echo "Driver = /home/jovyan/odbcdriver/lib/libtdsodbc.so" >> ~/.odbc.ini && \
echo "Trace = No" >> ~/.odbc.ini && \
echo "TraceFile = /home/jovyan/prodms.log" >> ~/.odbc.ini && \
echo "Server = MachineIPAddress >> ~/.odbc.ini && \
echo "Host = MachineHostName >> ~/.odbc.ini && \
echo "Port = MachineDBPort" >> ~/.odbc.ini && \
echo "Database = DatabaseInstanceName" >> ~/.odbc.ini && \
echo "UID = DatabaseUserName" >> ~/.odbc.ini && \
echo "PWD = DatabasePassword >> ~/.odbc.ini && \
echo "Protocol =" >> ~/.odbc.ini && \
echo "ReadOnly = No" >> ~/.odbc.ini && \
echo "RowVersioning = No" >> ~/.odbc.ini && \
echo "ShowSystemTables = No" >> ~/.odbc.ini && \
echo "ShowOidColumn = No" >> ~/.odbc.ini && \
echo "FakeOidIndex = No" >> ~/.odbc.ini && \
echo "ConnSettings =" >> ~/.odbc.ini && \
echo "TDS_Version = 7.0" >> ~/.odbc.ini
# Fix the version of rpy2 since the 2.7 is broken. See note above
RUN conda uninstall rpy2 && \
conda install -c bioconda rpy2=2.7.8
# Fix the ipywidgets since the base image has an older version of ipywidgets.
# This older version works with the Python2 instance but not the Python3 instance.
# Installing a newer version allows the widgets to work with both Python versions.
RUN conda uninstall ipywidgets && \
conda install -c conda-forge ipywidgets=5.1.5

0 comments on commit 4d5e2cc

Please sign in to comment.