Skip to content

Commit

Permalink
Merge pull request #1206 from quantopian/sprint-prep
Browse files Browse the repository at this point in the history
cleanup for sprint
  • Loading branch information
llllllllll committed May 17, 2016
2 parents 2d596dc + 56c7c08 commit fd814d1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
41 changes: 13 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,50 @@
# Dockerfile for an image with the currently checked out version of zipline installed. To build:
#
# docker build -t quantopian/zipline .
#
#
# To run the container:
#
# docker run -v=/path/to/your/notebooks:/projects -p 8888:8888/tcp --name zipline -it quantopian/zipline
# docker run -v /path/to/your/notebooks:/projects -v ~/.zipline:/root/.zipline -p 8888:8888/tcp --name zipline -it quantopian/zipline
#
# To access Jupyter when running docker locally (you may need to add NAT rules):
#
# https://127.0.0.1
#
# default password is jupyter. to provide another, see:
# http://jupyter-notebook.readthedocs.org/en/latest/public_server.html#preparing-a-hashed-password
#
#
# once generated, you can pass the new value via `docker run --env` the first time
# you start the container.
#
#
# You can also run an algo using the docker exec command. For example:
#
# docker exec -it zipline run_algo.py -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 \
# --symbols XOP -o /projects/result.pickle
# docker exec -it zipline zipline run -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 /projects/result.pickle
#
# For developers who want to access source inside the zipline container, try running this from
# within the root of the zipline source tree:
#
# docker run -v=/path/to/your/notebooks:/projects -v=`pwd`:/zipline -p 443:8888/tcp \
# --name zipline -it quantopian/zipline
#

FROM python:2.7

#
# set up environment
#
#
ENV PROJECT_DIR=/projects \
NOTEBOOK_PORT=8888 \
SSL_CERT_PEM=/root/.jupyter/jupyter.pem \
SSL_CERT_KEY=/root/.jupyter/jupyter.key \
PW_HASH="u'sha1:31cb67870a35:1a2321318481f00b0efdf3d1f71af523d3ffc505'" \
CONFIG_PATH=/root/.jupyter/jupyter_notebook_config.py

#
#
# install TA-Lib and other prerequisites
#
#

RUN mkdir ${PROJECT_DIR} \
&& apt-get -y update \
&& apt-get -y install libfreetype6-dev libpng-dev libopenblas-dev liblapack-dev gfortran \
&& curl -L http://downloads.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz | tar xvz
&& curl -L http://downloads.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz | tar xvz

#
# build and install zipline from source. install TA-Lib after to ensure
# numpy is available.
#
#

WORKDIR /ta-lib

Expand All @@ -73,10 +65,10 @@ RUN pip install numpy==1.9.2 \

ADD ./etc/docker_cmd.sh /

#
#
# make port available. /zipline is made a volume
# for developer testing.
#
#
EXPOSE ${NOTEBOOK_PORT}

#
Expand All @@ -85,14 +77,7 @@ EXPOSE ${NOTEBOOK_PORT}

ADD . /zipline
WORKDIR /zipline
RUN python setup.py install

#
# clean up the build artifacts and recreate the folder for
# developer mount
#

RUN rm -rf /zipline && mkdir /zipline
RUN pip install -e .

#
# start the jupyter server
Expand Down
6 changes: 3 additions & 3 deletions etc/docker_cmd.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

#
#
# generate configuration, cert, and password if this is the first run
#
#
if [ ! -f /var/tmp/zipline_init ] ; then
jupyter notebook --generate-config
if [ ! -f ${SSL_CERT_PEM} ] ; then
Expand All @@ -12,7 +12,7 @@ if [ ! -f /var/tmp/zipline_init ] ; then
fi
echo "c.NotebookApp.password = ${PW_HASH}" >> ${CONFIG_PATH}
touch /var/tmp/zipline_init
fi
fi

jupyter notebook -y --no-browser --notebook-dir=${PROJECT_DIR} \
--certfile=${SSL_CERT_PEM} --keyfile=${SSL_CERT_KEY} --ip='*' \
Expand Down
1 change: 1 addition & 0 deletions zipline/data/bundles/quandl.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def download_with_progress(url, chunk_size, **progress_kwargs):
data.write(chunk)
pbar.update(len(chunk))

data.seek(0)
return data


Expand Down
14 changes: 14 additions & 0 deletions zipline/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ def ensure_directory_containing(path):
ensure_directory(os.path.dirname(path))


def ensure_file(path):
"""
Ensure that a file exists. This will create any parent directories needed
and create an empty file if it does not exists.
Parameters
----------
path : str
The file path to ensure exists.
"""
ensure_directory_containing(path)
open(path, 'a+').close() # touch the file


def last_modified_time(path):
"""
Get the last modified time of path as a Timestamp.
Expand Down
2 changes: 1 addition & 1 deletion zipline/utils/run_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def load_extensions(default, extensions, strict, environ, reload=False):
"""
if default:
default_extension_path = pth.default_extension(environ=environ)
open(default_extension_path, 'a+').close() # touch the file
pth.ensure_file(default_extension_path)
# put the default extension first so other extensions can depend on
# the order they are loaded
extensions = concatv([default_extension_path], extensions)
Expand Down

0 comments on commit fd814d1

Please sign in to comment.