Skip to content

Commit

Permalink
[MRG] Move binder setup to scikit-learn/scikit-learn repo (scikit-lea…
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve authored and ogrisel committed Aug 28, 2019
1 parent e74e032 commit 9ef4700
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -e

# This script is called in a binder context. When this script is called, we are
# inside a git checkout of the scikit-learn/scikit-learn repo. This script is
# generating notebooks from the scikit-learn python examples.

if [[ ! -f /.dockerenv ]]; then
echo "This script was written for repo2docker and is supposed to run inside a docker container."
echo "Exiting because this script can delete data if run outside of a docker container."
exit 1
fi

# Back up content we need from the scikit-learn repo
TMP_CONTENT_DIR=/tmp/scikit-learn
mkdir -p $TMP_CONTENT_DIR
cp -r examples .binder $TMP_CONTENT_DIR
# delete everything in current directory including dot files and dot folders
find . -delete

# Generate notebooks and remove other files from examples folder
GENERATED_NOTEBOOKS_DIR=.generated-notebooks
cp -r $TMP_CONTENT_DIR/examples $GENERATED_NOTEBOOKS_DIR

find $GENERATED_NOTEBOOKS_DIR -name '*.py' -exec sphx_glr_python_to_jupyter.py '{}' +
NON_NOTEBOOKS=$(find $GENERATED_NOTEBOOKS_DIR -type f | grep -v '\.ipynb')
rm -f $NON_NOTEBOOKS

# Put the .binder folder back (may be useful for debugging purposes)
mv $TMP_CONTENT_DIR/.binder .
# Final clean up
rm -rf $TMP_CONTENT_DIR

# This is for compatibility with binder sphinx-gallery integration: this makes
# sure that the binder links generated by sphinx-gallery are correct even tough
# the repo we use for binder (scikit-learn/scikit-learn) is not the repo of the
# generated doc (scikit-learn/scikit-learn.github.io)
mkdir notebooks
ln -s ../$GENERATED_NOTEBOOKS_DIR notebooks/auto_examples
7 changes: 7 additions & 0 deletions .binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--find-links https://sklearn-nightly.scdn8.secure.raxcdn.com scikit-learn
matplotlib
scikit-image
pandas
sphinx-gallery
scikit-learn>=0.22.dev0

2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
'gallery_dirs': ['auto_examples'],
'binder': {
'org': 'scikit-learn',
'repo': 'binder-examples',
'repo': 'scikit-learn',
'binderhub_url': 'https://mybinder.org',
'branch': binder_branch,
'dependencies': './binder/requirements.txt',
Expand Down

0 comments on commit 9ef4700

Please sign in to comment.