-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9cc3b5b
Showing
4 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,21 @@ | ||
FROM python:3.7 | ||
RUN pip3 install \ | ||
jhsingle-native-proxy>=0.0.10 \ | ||
voila \ | ||
ipywidgets numpy matplotlib | ||
|
||
# create a user, since we don't want to run as root | ||
RUN useradd -m jovyan | ||
ENV HOME=/home/jovyan | ||
WORKDIR $HOME | ||
USER jovyan | ||
|
||
COPY --chown=jovyan:jovyan entrypoint.sh /home/jovyan | ||
COPY --chown=jovyan:jovyan Presentation.ipynb /home/jovyan | ||
|
||
EXPOSE 8888 | ||
|
||
ENTRYPOINT ["/home/jovyan/entrypoint.sh"] | ||
|
||
CMD ["jhsingle-native-proxy", "--destport", "8505", "voila", "/home/jovyan/Presentation.ipynb", "{--}port={port}", "{--}no-browser", "{--}Voila.base_url={base_url}/", "{--}Voila.server_url=/"] | ||
|
This file contains 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,95 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Sin and Cos Graph demo\n", | ||
"\n", | ||
"Move the slider to change the value of t." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline\n", | ||
"\n", | ||
"from ipywidgets import interact\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"plt.style.use('seaborn-whitegrid')\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def pltsincos(t=0):\n", | ||
"\n", | ||
" fig = plt.figure(figsize=(10,5))\n", | ||
" ax = plt.axes()\n", | ||
"\n", | ||
" x = np.linspace(0, 10, 1000)\n", | ||
" ax.plot(x, np.sin(x*t))\n", | ||
" ax.plot(x, np.cos(x*t))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "243253f82f444084853e648d664bba76", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"interactive(children=(FloatSlider(value=1.0, description='t', max=10.0, min=1.0), Output()), _dom_classes=('wi…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"interact(pltsincos, t=(1,10,0.1));" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains 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,7 @@ | ||
# binderhub-voila-native | ||
|
||
A test Binder repo for [jhsingle-native-proxy](https://github.com/ideonate/jhsingle-native-proxy/) using Voila | ||
|
||
[](https://mybinder.org/v2/gh/danlester/binderhub-voila-native/master) | ||
|
||
Has an entrypoint that strips out port from the 'jupyter notebook' command and then runs Voila on the port provided. |
This file contains 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,39 @@ | ||
#!/bin/bash | ||
|
||
# For a command line such as: | ||
# "/home/jovyan/entrypoint.sh jupyter notebook --ip 0.0.0.0 --port 59537 --NotebookApp.custom_display_url=http://127.0.0.1:59537" | ||
# strip out most args, just pass on the port | ||
|
||
|
||
collect_port=0 | ||
port="8888" | ||
delim='=' | ||
|
||
for var in "$@" | ||
do | ||
echo "$var" | ||
|
||
if [ "$collect_port" == "1" ]; then | ||
echo "Collecting external port $var" | ||
port=$var | ||
collect_port=0 | ||
fi | ||
|
||
splitarg=${var%%$delim*} | ||
|
||
if [ "$splitarg" == "--port" ]; then | ||
if [ ${#splitarg} == ${#var} ]; then | ||
collect_port=1 | ||
else | ||
port=${var#*$delim} | ||
echo "Setting external port $port" | ||
fi | ||
fi | ||
done | ||
|
||
destport=$((port + 1)) | ||
|
||
echo "Using internal port $destport" | ||
|
||
jhsingle-native-proxy --destport $destport --authtype none voila /home/jovyan/Presentation.ipynb {--}port={port} {--}no-browser {--}Voila.base_url={base_url}/ {--}Voila.server_url=/ --port $port | ||
|