-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_notebooks.sh
More file actions
executable file
·111 lines (94 loc) · 3.2 KB
/
convert_notebooks.sh
File metadata and controls
executable file
·111 lines (94 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# run this from the the top-level directory
# it creates there a notebooks/ and _solved/solutions/ dir
# that get automatically copied to the correct places
if [ "$#" -ne 1 ]; then
echo "You must enter exactly one command line argument for the course edition"
exit 1
fi
export COURSE_DIR="DS-python-data-analysis-$1"
echo "Preparing course materials for $COURSE_DIR"
echo ""
echo "-- Creating temporary directory to generate course materials"
mkdir temp_course_setup
pushd temp_course_setup
# cloning repositories to make sure we start with a clean state
echo ""
echo "-- Cloning repositories"
git clone --depth 1 https://github.com/plovercode/DS-python-data-analysis.git $COURSE_DIR
git clone --depth 1 https://github.com/plovercode/course-python-data.git course-python-data-clean
# copying all necessary files to the course directory
echo ""
echo "-- Copying files to $COURSE_DIR"
cp course-python-data-clean/notebooks/*.ipynb $COURSE_DIR/_solved/
cp course-python-data-clean/notebooks/python_intro/*.ipynb $COURSE_DIR/_solved/python_intro/
cp course-python-data-clean/notebooks/data/ $COURSE_DIR/notebooks/ -r
cp course-python-data-clean/img/ $COURSE_DIR/ -r
cp course-python-data-clean/environment.yml $COURSE_DIR/
cp course-python-data-clean/check_environment.py $COURSE_DIR/
# converting notebooks with solutions to student notebooks
echo ""
echo "-- Converting notebooks"
pushd $COURSE_DIR/
declare -a arr=(
#"00-jupyter_introduction.ipynb"
#"01-basic.ipynb"
#"02-control_flow.ipynb"
#"03-functions.ipynb"
#"04-reusing_code.ipynb"
#"05-numpy.ipynb"
#"python_rehearsal"
"00-jupyter_introduction.ipynb"
"pandas_01_data_structures.ipynb"
"pandas_02_basic_operations.ipynb"
"pandas_03a_selecting_data.ipynb"
"pandas_03b_indexing.ipynb"
"pandas_04_time_series_data.ipynb"
"pandas_05_groupby_operations.ipynb"
"pandas_06_data_cleaning.ipynb"
"pandas_07_missing_values.ipynb"
"pandas_08_reshaping_data.ipynb"
"pandas_09_combining_datasets.ipynb"
"visualization_01_matplotlib.ipynb"
"visualization_02_seaborn.ipynb"
"visualization_03_landscape.ipynb"
"case1_bike_count.ipynb"
"case2_observations.ipynb"
"case3_bacterial_resistance_lab_experiment"
"case4_air_quality_processing.ipynb"
"case4_air_quality_analysis.ipynb"
)
cd _solved
mkdir ./notebooks
for i in "${arr[@]}"
do
echo "---- Converting " "$i"
jupyter nbconvert --to=notebook --config ../../../nbconvert_config.py --output "notebooks/$i" "$i"
done
echo ""
echo "-- Copying converted notebooks and solutions"
cp -r notebooks/. ../notebooks
cp -r _solutions/. ../notebooks/_solutions
rm -r notebooks/
rm -r _solutions/
cd ..
# clear output from solved notebooks
jupyter nbconvert --clear-output _solved/*.ipynb
popd
popd
echo ""
echo "-- Moving $COURSE_DIR to top-level directory and cleaning up temporary files"
mv ./temp_course_setup/$COURSE_DIR/ ../../$COURSE_DIR
rm -rf temp_course_setup/
echo ""
echo "-- Committing changes"
cd ../../$COURSE_DIR
git checkout -b update-$1
git commit -am "$1 edition - update materials"
echo ""
echo "-- Course materials are ready in:"
echo ""
echo " cd $(pwd)"
echo ""
echo " Remember to push the changes to GitHub:"
echo ""
echo " git push origin HEAD:update-$1"