| 
 | 1 | +#!/bin/bash  | 
 | 2 | + | 
 | 3 | +set -e  | 
 | 4 | + | 
 | 5 | +python -m pip install .[docs,examples]  | 
 | 6 | + | 
 | 7 | +# Taken from https://github.com/scikit-learn/scikit-learn/blob/22cd233e1932457947e9994285dc7fd4e93881e4/.binder/postBuild  | 
 | 8 | +# under BSD3 license, copyright the scikit-learn contributors  | 
 | 9 | + | 
 | 10 | +# This script is called in a binder context. When this script is called, we are  | 
 | 11 | +# inside a git checkout of the automl/auto-sklearn repo. This script  | 
 | 12 | +# generates notebooks from the auto-sklearn python examples.  | 
 | 13 | + | 
 | 14 | +if [[ ! -f /.dockerenv ]]; then  | 
 | 15 | +    echo "This script was written for repo2docker and is supposed to run inside a docker container."  | 
 | 16 | +    echo "Exiting because this script can delete data if run outside of a docker container."  | 
 | 17 | +    exit 1  | 
 | 18 | +fi  | 
 | 19 | + | 
 | 20 | +# Copy content we need from the auto-sklearn repo  | 
 | 21 | +TMP_CONTENT_DIR=/tmp/auto-sklearn  | 
 | 22 | +mkdir -p $TMP_CONTENT_DIR  | 
 | 23 | +cp -r examples .binder $TMP_CONTENT_DIR  | 
 | 24 | +# delete everything in current directory including dot files and dot folders  | 
 | 25 | +find . -delete  | 
 | 26 | + | 
 | 27 | +# Generate notebooks and remove other files from examples folder  | 
 | 28 | +GENERATED_NOTEBOOKS_DIR=examples  | 
 | 29 | +cp -r $TMP_CONTENT_DIR/examples $GENERATED_NOTEBOOKS_DIR  | 
 | 30 | + | 
 | 31 | +find $GENERATED_NOTEBOOKS_DIR -name 'example_*.py' -exec sphx_glr_python_to_jupyter.py '{}' +  | 
 | 32 | +# Keep __init__.py and custom_metrics.py  | 
 | 33 | +NON_NOTEBOOKS=$(find $GENERATED_NOTEBOOKS_DIR -type f | grep -v '\.ipynb' | grep -v 'init' | grep -v 'custom_metrics')  | 
 | 34 | +rm -f $NON_NOTEBOOKS  | 
 | 35 | + | 
 | 36 | +# Modify path to be consistent by the path given by sphinx-gallery  | 
 | 37 | +mkdir notebooks  | 
 | 38 | +mv $GENERATED_NOTEBOOKS_DIR notebooks/  | 
 | 39 | + | 
 | 40 | +# Put the .binder folder back (may be useful for debugging purposes)  | 
 | 41 | +mv $TMP_CONTENT_DIR/.binder .  | 
 | 42 | +# Final clean up  | 
 | 43 | +rm -rf $TMP_CONTENT_DIR  | 
0 commit comments