This repository was archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 249
Adding a Python 3 Kernel to Datalab. #1344
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4b275e7
Adding a Python 3 Kernel to Datalab.
1cfa4e1
Merge branch 'master' into chmeyers-python3
chmeyers 8e4b7a5
Fix merge error.
a73d5cd
Changes based on review comments.
98d7bce
Fixing minimum toolbar width.
5faff47
Fixing build error.
a04de2e
Merge branch 'master' into chmeyers-python3
chmeyers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# Copyright 2015 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM debian:jessie | ||
MAINTAINER Google Cloud DataLab | ||
|
||
# Container configuration | ||
EXPOSE 8080 | ||
|
||
# Path configuration | ||
ENV PATH $PATH:/tools/node/bin:/tools/google-cloud-sdk/bin | ||
ENV PYTHONPATH /env/python | ||
|
||
# Setup OS and core packages | ||
RUN echo "deb-src http://ftp.us.debian.org/debian testing main" >> /etc/apt/sources.list && \ | ||
apt-get update -y && \ | ||
apt-get install --no-install-recommends -y -q python unzip ca-certificates build-essential \ | ||
libatlas-base-dev liblapack-dev gfortran libpng-dev libfreetype6-dev libxft-dev libxml2-dev \ | ||
python-dev python-setuptools python-zmq openssh-client wget curl git pkg-config zip && \ | ||
easy_install pip && \ | ||
mkdir -p /tools && \ | ||
|
||
# Save GPL source packages | ||
mkdir -p /srcs && \ | ||
cd /srcs && \ | ||
apt-get source -d wget git python-zmq ca-certificates pkg-config libpng-dev && \ | ||
wget --progress=dot:mega https://mirrors.kernel.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2 && \ | ||
cd / && \ | ||
|
||
# Setup Python packages. Rebuilding numpy/scipy is expensive so we move this early | ||
# to reduce the chance that prior steps can cause changes requiring a rebuild. | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir numpy==1.11.2 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir pandas==0.19.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir scipy==0.18.0 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir scikit-learn==0.17.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir sympy==0.7.6.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir statsmodels==0.6.1 && \ | ||
|
||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir tornado==4.4.2 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir pyzmq==16.0.2 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir jinja2==2.8 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir jsonschema==2.5.1 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir python-dateutil==2.5.0 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir pytz==2016.7 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir pandocfilters==1.3.0 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir pygments==2.1.3 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir argparse==1.2.1 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir mock==2.0.0 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir requests==2.9.1 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir oauth2client==2.2.0 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir httplib2==0.9.2 \ | ||
--upgrade-strategy only-if-needed --no-cache-dir futures==3.0.5 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir matplotlib==1.5.3 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir ggplot==0.6.8 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir seaborn==0.7.0 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir PyYAML==3.11 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir six==1.10.0 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir ipywidgets==6.0.0 && \ | ||
# Install notebook after ipywidgets, and keep it pinned to 4.2.3, higher versions may | ||
# not work well with datalab. For example, kernel gateway doesn't work with 4.3.0 notebook | ||
# (https://github.com/googledatalab/datalab/issues/1083) | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir notebook==4.2.3 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir ipykernel==4.5.2 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir future==0.15.2 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir psutil==4.3.0 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir google-api-python-client==1.5.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir plotly==1.12.5 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir nltk==3.2.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir bs4==0.0.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir crcmod==1.7 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir pillow==3.4.1 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir google-cloud-dataflow==0.6.0 && \ | ||
find /usr/local/lib/python2.7 -type d -name tests | xargs rm -rf && \ | ||
|
||
|
||
# Setup Node.js using LTS 6.10 | ||
mkdir -p /tools/node && \ | ||
wget -nv https://nodejs.org/dist/v6.10.0/node-v6.10.0-linux-x64.tar.gz -O node.tar.gz && \ | ||
tar xzf node.tar.gz -C /tools/node --strip-components=1 && \ | ||
rm node.tar.gz && \ | ||
|
||
# Setup Google Cloud SDK | ||
# Also apply workaround for gsutil failure brought by this version of Google Cloud. | ||
# (https://code.google.com/p/google-cloud-sdk/issues/detail?id=538) in final step. | ||
wget -nv https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.zip && \ | ||
unzip -qq google-cloud-sdk.zip -d tools && \ | ||
rm google-cloud-sdk.zip && \ | ||
tools/google-cloud-sdk/install.sh --usage-reporting=false \ | ||
--path-update=false --bash-completion=false \ | ||
--disable-installation-options && \ | ||
tools/google-cloud-sdk/bin/gcloud -q components update \ | ||
gcloud core bq gsutil compute preview alpha beta && \ | ||
# disable the gcloud update message | ||
tools/google-cloud-sdk/bin/gcloud config set component_manager/disable_update_check true && \ | ||
touch /tools/google-cloud-sdk/lib/third_party/google.py && \ | ||
|
||
# Add some unchanging bits - specifically node modules (that need to be kept in sync | ||
# with packages.json manually, but help save build time, by preincluding them in an | ||
# earlier layer). | ||
# Note: ws is now over 1.0 but using that gives issues so leaving at 0.4.2 for now. | ||
/tools/node/bin/npm install \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] && \ | ||
cd / && \ | ||
/tools/node/bin/npm install -g forever && \ | ||
|
||
# Clean up | ||
apt-get purge -y build-essential bzip2 cpp cpp-4.9 python-setuptools pkg-config libfreetype6-dev && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm -rf /var/lib/dpkg/info/* && \ | ||
rm -rf /tmp/* && \ | ||
rm -rf /root/.cache/* && \ | ||
rm -rf /usr/share/locale/* && \ | ||
rm -rf /usr/share/i18n/locales/* && \ | ||
cd / | ||
|
||
# Install tf-transform | ||
RUN pip install -U --upgrade-strategy only-if-needed --no-cache-dir tensorflow-transform==0.1.7 | ||
|
||
# Install TensorFlow | ||
# Setting protobuf to 3.1.0 to workaround a tensorflow 1.0 issue in tcmalloc | ||
RUN pip install -U --upgrade-strategy only-if-needed --no-cache-dir tensorflow==1.0 && \ | ||
pip install -U --upgrade-strategy only-if-needed --no-cache-dir protobuf==3.1.0 | ||
|
||
ADD config/ipython.py /etc/ipython/ipython_config.py | ||
ADD config/nbconvert.py /etc/jupyter/jupyter_notebook_config.py | ||
|
||
# Directory "py" may be empty and in that case it will git clone pydatalab from repo | ||
ADD pydatalab /datalab/lib/pydatalab | ||
ADD nbconvert /datalab/nbconvert | ||
|
||
# Do IPython configuration and install build artifacts | ||
# Then link stuff needed for nbconvert to a location where Jinja will find it. | ||
# I'd prefer to just use absolute path in Jinja imports but those don't work. | ||
RUN ipython profile create default && \ | ||
jupyter notebook --generate-config && \ | ||
if [ -d /datalab/lib/pydatalab/.git ]; then \ | ||
echo "use local lib"; \ | ||
else \ | ||
git clone https://github.com/googledatalab/pydatalab.git /datalab/lib/pydatalab; \ | ||
fi && \ | ||
cd /datalab/lib/pydatalab && \ | ||
/tools/node/bin/npm install -g typescript && \ | ||
tsc --module amd --noImplicitAny --outdir datalab/notebook/static datalab/notebook/static/*.ts && \ | ||
tsc --module amd --noImplicitAny --outdir google/datalab/notebook/static google/datalab/notebook/static/*.ts && \ | ||
/tools/node/bin/npm uninstall -g typescript && \ | ||
pip install --upgrade-strategy only-if-needed --no-cache-dir . && \ | ||
pip install --upgrade-strategy only-if-needed /datalab/lib/pydatalab/solutionbox/image_classification/. && \ | ||
pip install --upgrade-strategy only-if-needed /datalab/lib/pydatalab/solutionbox/structured_data/. && \ | ||
jupyter nbextension install --py datalab.notebook && \ | ||
jupyter nbextension install --py google.datalab.notebook && \ | ||
jupyter nbextension enable --py widgetsnbextension && \ | ||
rm datalab/notebook/static/*.js google/datalab/notebook/static/*.js && \ | ||
mkdir -p /datalab/nbconvert && \ | ||
cp -R /usr/local/share/jupyter/nbextensions/gcpdatalab/* /datalab/nbconvert && \ | ||
ln -s /usr/local/lib/python2.7/dist-packages/notebook/static/custom/custom.css /datalab/nbconvert/custom.css && \ | ||
cd / | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes here from the original Dockerfile, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is just a branch.