binder support

This commit is contained in:
Thomas Schmelzer
2020-05-01 21:02:04 +02:00
committed by robertmartin8
parent 4ae6aa0cc5
commit 34c8efb8e6
12 changed files with 13952 additions and 12 deletions

View File

@@ -5,9 +5,11 @@
!pypfopt
!tests
#!setup.py
#!README.md
!setup.py
!README.md
!requirements.txt
!binder
!cookbook
**/__pycache__
**/*.pyc

2
.env Normal file
View File

@@ -0,0 +1,2 @@
PORT=9020
WORK=/home/jovyan/work

View File

@@ -4,6 +4,10 @@ PROJECT_VERSION := $(shell python setup.py --version)
SHELL := /bin/bash
PACKAGE := pypfopt
# needed to get the ${PORT} environment variable
include .env
export
.PHONY: help build test tag pypi
@@ -19,7 +23,9 @@ help:
@echo "make tag"
@echo " Make a tag on Github."
jupyter:
echo "http://localhost:${PORT}/lab"
docker-compose up jupyter
build:
docker-compose build pypfopt

21
binder/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM jupyter/base-notebook:lab-1.2.5 as jupyter
# File Author / Maintainer
# MAINTAINER Thomas Schmelzer "thomas.schmelzer@gmail.com"
# copy the config file
COPY ./binder/jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config.py
# copy the package over and install it
COPY --chown=jovyan:users . /tmp/pyportfolioopt
RUN conda install -y -c conda-forge --file /tmp/pyportfolioopt/requirements.txt && \
conda clean -y --all && \
pip install --no-cache-dir /tmp/pyportfolioopt && \
rm -rf /tmp/pyportfolioopt && \
jupyter labextension install @jupyter-widgets/jupyterlab-manager && \
jupyter labextension install beakerx-jupyterlab && \
jupyter lab build
# hardcoded parameters!? see https://github.com/moby/moby/issues/35018
COPY --chown=jovyan:users ./cookbook $HOME/work

View File

@@ -0,0 +1,7 @@
c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.token = ''
c.NotebookApp.password = ''
c.NotebookApp.notebook_dir = "/home/jovyan/work"

View File

@@ -68,7 +68,7 @@
}
],
"source": [
"df = pd.read_csv(\"stock_prices.csv\", parse_dates=True, index_col=\"date\")\n",
"df = pd.read_csv(\"data/stock_prices.csv\", parse_dates=True, index_col=\"date\")\n",
"past_df, future_df = df.iloc[:-250], df.iloc[-250:]\n",
"future_cov = risk_models.sample_cov(future_df)\n",
"\n",
@@ -278,9 +278,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat_minor": 4
}

View File

@@ -1557,7 +1557,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.7.6"
}
},
"nbformat": 4,

View File

@@ -1160,9 +1160,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat_minor": 4
}

View File

@@ -955,7 +955,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.7.6"
}
},
"nbformat": 4,

6766
cookbook/data/spy_prices.csv Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -5,3 +5,12 @@ services:
context: .
dockerfile: Dockerfile
target: builder
jupyter:
build:
context: .
dockerfile: ./binder/Dockerfile
volumes:
- ./cookbook:${WORK}
ports:
- ${PORT}:8888