Skip to content

Commit

Permalink
Integrate dask-labextension into binder deployment (dask#38)
Browse files Browse the repository at this point in the history
* update versions
* move .images to images
* Add postBuild script and JupyterLab workspace
* add Welcome file
* add dask-horizontal logo image

Work done with @ian-r-rose
  • Loading branch information
mrocklin authored Sep 9, 2018
1 parent a054d6e commit 852a0dd
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 11 deletions.
29 changes: 29 additions & 0 deletions Welcome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

<img src="images/dask-horizontal.svg" width="50%" align="right">

Welcome To Dask Examples
========================

This is a live session from which you can run example notebooks showing how to use Dask.

A file browser listing example notebooks is available to the left. There are overview notebooks about topics like arrays, dataframes, and machine learning at the top-level, as well as more focused notebooks within sub-directories.

Dask dashboard plots are available to the right. These will activate when you
run the cells in your Jupyter notebooks that create a Dask `Client` (these are already written for you).

To get started, double click on a notebook on the left, like `dataframes.ipynb`, and start running through the Jupyter notebook cells.

Learn More
----------

Links are available within each notebook for additional documentation on that topic.

For more information about Dask in general please visit [dask.pydata.org](https://dask.pydata.org).

For more information about these examples please visit [github.com/dask/dask-examples](https://github.com/dask/dask-examples)


Where is this running?
----------------------

This session is running on [mybinder.org](https://mybinder.org), a service designed and maintained by the Jupyter community, generously funded by the Gordon and Betty Moore Foundation, and currently running on Google Cloud Platform.
2 changes: 1 addition & 1 deletion array.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Dask Arrays\n",
"\n",
"<img src=\".images/dask-array-black-text.svg\" \n",
"<img src=\"images/dask-array-black-text.svg\" \n",
" align=\"right\"\n",
" alt=\"Dask arrays are blocked numpy arrays\">\n",
" \n",
Expand Down
13 changes: 7 additions & 6 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
channels:
- defaults
- conda-forge
dependencies:
- bokeh=0.12
- dask==0.18.2
- dask-ml==0.9.0
- distributed==1.22.1
- bokeh=0.13
- dask=0.19.1
- dask-ml=0.9.0
- distributed=1.23.1
- jupyterlab=0.34
- nodejs=8.9
- numpy
- pandas
- pyarrow==0.9.0
- pyarrow==0.10.0
- scikit-learn
- matplotlib
- nbserverproxy
Expand Down
93 changes: 93 additions & 0 deletions binder/jupyterlab-workspace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"data": {
"layout-restorer:data": {
"main": {
"dock": {
"type": "split-area",
"orientation": "horizontal",
"sizes": [
0.5,
0.5
],
"children": [
{
"type": "tab-area",
"currentIndex": 0,
"widgets": [
"application-mimedocuments:Welcome.md:Markdown Preview"
]
},
{
"type": "split-area",
"orientation": "vertical",
"sizes": [
0.67,
0.33
],
"children": [
{
"type": "tab-area",
"currentIndex": 0,
"widgets": [
"dask-dashboard-launcher:individual-task-stream"
]
},
{
"type": "tab-area",
"currentIndex": 0,
"widgets": [
"dask-dashboard-launcher:individual-progress"
]
}
]
}
]
},
"mode": "multiple-document",
"current": "application-mimedocuments:Welcome.md:Markdown Preview"
},
"left": {
"collapsed": false,
"current": "filebrowser",
"widgets": [
"filebrowser",
"running-sessions",
"dask-dashboard-launcher",
"command-palette",
"tab-manager"
]
},
"right": {
"collapsed": true,
"widgets": []
}
},
"file-browser-filebrowser:cwd": {
"path": ""
},
"dask-dashboard-launcher:individual-task-stream": {
"data": {
"route": "individual-task-stream",
"label": "Task Stream"
}
},
"dask-dashboard-launcher:individual-progress": {
"data": {
"route": "individual-progress",
"label": "Progress"
}
},
"dask-dashboard-launcher": {
"url": "DASK_DASHBOARD_URL"
},
"application-mimedocuments:Welcome.md:Markdown Preview": {
"data": {
"path": "Welcome.md",
"factory": "Markdown Preview"
}
}
},
"metadata": {
"id": "/lab"
}
}
12 changes: 12 additions & 0 deletions binder/make_workspace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os, shutil
from jupyterlab_launcher.workspaces_handler import _slug

service_path = os.environ.get('JUPYTERHUB_SERVICE_PREFIX')
home = os.environ.get('HOME')
workspace_path = service_path.strip('/') + '/lab' if service_path else '/lab'
filename = _slug(workspace_path, '') + '.jupyterlab-workspace'
shutil.copy(
'./binder/jupyterlab-workspace.json',
f'{home}/.jupyter/lab/workspaces/{filename}'
)

4 changes: 4 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Install the JupyterLab dask-labextension
jupyter labextension install dask-labextension
12 changes: 12 additions & 0 deletions binder/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Replace DASK_DASHBOARD_URL with the proxy location
sed -i -e "s|DASK_DASHBOARD_URL|/user/${JUPYTERHUB_USER}/proxy/8787|g" binder/jupyterlab-workspace.json

# Copy into the workspaces directory
# NOTE: this relies on internal path logic to the JupyterLab workspaces handler.
# As soon as a CLI becomes available for this, we should use that.
mkdir -p ${HOME}/.jupyter/lab/workspaces
python ./binder/make_workspace.py

exec "$@"
4 changes: 2 additions & 2 deletions dataframe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Dask DataFrames\n",
"\n",
"<img src=\".images/dask-dataframe.svg\" \n",
"<img src=\"images/dask-dataframe.svg\" \n",
" align=\"right\"\n",
" width=\"20%\"\n",
" alt=\"Dask dataframes are blocked Pandas dataframes\">\n",
Expand Down Expand Up @@ -356,7 +356,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.4"
}
},
"nbformat": 4,
Expand Down
File renamed without changes
File renamed without changes
28 changes: 28 additions & 0 deletions images/dask-horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion machine-learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"source": [
"## Distributed Training\n",
"\n",
"<img src=\".images/scikit-learn-logo-notext.png\"/> <img src=\".images/joblib_logo.svg\" width=\"20%\"/> \n",
"<img src=\"images/scikit-learn-logo-notext.png\"/> <img src=\"images/joblib_logo.svg\" width=\"20%\"/> \n",
"\n",
"Scikit-learn uses [joblib](http://joblib.readthedocs.io/) for single-machine parallelism. This lets you train most estimators (anything that accepts an `n_jobs` parameter) using all the cores of your laptop or workstation.\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"source": [
"## Distributed Training\n",
"\n",
"<img src=\".images/scikit-learn-logo-notext.png\"/> <img src=\".images/joblib_logo.svg\" width=\"20%\"/> \n",
"<img src=\"images/scikit-learn-logo-notext.png\"/> <img src=\"images/joblib_logo.svg\" width=\"20%\"/> \n",
"\n",
"Scikit-learn uses [joblib](http://joblib.readthedocs.io/) for single-machine parallelism. This lets you train most estimators (anything that accepts an `n_jobs` parameter) using all the cores of your laptop or workstation.\n",
"\n",
Expand Down

0 comments on commit 852a0dd

Please sign in to comment.