|
1 | 1 | default: build |
2 | 2 |
|
| 3 | +SHELL := /bin/bash |
| 4 | + |
3 | 5 | TUTORIALS_MAIN_BRANCH ?= main |
4 | | -MODIFIED := $(shell python .github/get_modified_tutorials.py --main-branch $(TUTORIALS_MAIN_BRANCH)) |
| 6 | + |
| 7 | +# paths to the individual notebooks that have been modified |
| 8 | +MODIFIED_NOTEBOOKS := $(shell python .github/get_modified_tutorials.py --main-branch $(TUTORIALS_MAIN_BRANCH)) |
| 9 | +# paths to the individual requirements.txt files in the directories in which 1+ notebooks have been modified |
| 10 | +MODIFIED_RQT_PATHS := $(foreach var,$(MODIFIED_NOTEBOOKS),$(addsuffix requirements.txt,$(dir $(var)))) |
| 11 | + |
| 12 | +ALL_NOTEBOOKS := $(shell python .github/get_modified_tutorials.py --main-branch $(TUTORIALS_MAIN_BRANCH) --return_all true) |
| 13 | +ALL_RQT_PATHS := $(foreach var,$(ALL_NOTEBOOKS),$(addsuffix requirements.txt,$(dir $(var)))) |
5 | 14 |
|
6 | 15 | FLAGS = --flatten --build-path=. -v |
7 | | -CONVERTFLAGS = --make-index --preprocessors=nbconvert.preprocessors.ExtractOutputPreprocessor --index-template=templates/index.tpl |
| 16 | +CONVERTFLAGS = --make-index --preprocessors=nbconvert.preprocessors.ExtractOutputPreprocessor --index-template=templates/index.tpl --overwrite |
8 | 17 |
|
9 | 18 | init: |
10 | 19 | python -m pip install -U -r requirements-dev.txt |
11 | | - pre-commit install |
12 | | - |
13 | | -build: envcheck execute convert |
14 | | -buildall: envcheck executeall convertall |
15 | 20 |
|
16 | | -envcheck: |
17 | | - python -c "import pkg_resources; pkg_resources.require(open('requirements.txt', mode='r')); print('Your environment is all set!')" |
| 21 | +build: convert |
| 22 | +buildall: convertall |
18 | 23 |
|
19 | 24 | execute: |
20 | | - nbcollection execute --timeout=600 ${FLAGS} ${MODIFIED} |
| 25 | + i=0; \ |
| 26 | + _paths=($(MODIFIED_RQT_PATHS)); \ |
| 27 | + for notebook in ${MODIFIED_NOTEBOOKS}; do \ |
| 28 | + echo Installing requirements from $${_paths[i]}; \ |
| 29 | + python -m pip install --force-reinstall -r $${_paths[i]} > /dev/null; \ |
| 30 | + nbcollection execute --timeout=600 ${FLAGS} $$notebook; \ |
| 31 | + i=$$((i+1)); \ |
| 32 | + done |
21 | 33 |
|
22 | 34 | convert: |
23 | | - nbcollection convert ${CONVERTFLAGS} ${FLAGS} ${MODIFIED} |
| 35 | + i=0; \ |
| 36 | + _paths=($(MODIFIED_RQT_PATHS)); \ |
| 37 | + for notebook in ${MODIFIED_NOTEBOOKS}; do \ |
| 38 | + echo Installing requirements from $${_paths[i]}; \ |
| 39 | + python -m pip install --force-reinstall -r $${_paths[i]} > /dev/null; \ |
| 40 | + nbcollection convert ${CONVERTFLAGS} ${FLAGS} $$notebook; \ |
| 41 | + i=$$((i+1)); \ |
| 42 | + done |
24 | 43 |
|
25 | 44 | executeall: |
26 | | - nbcollection execute --timeout=600 ${FLAGS} tutorials |
| 45 | + i=0; \ |
| 46 | + _paths=(${ALL_RQT_PATHS}); \ |
| 47 | + for notebook in ${ALL_NOTEBOOKS}; do \ |
| 48 | + echo Installing requirements from $${_paths[i]}; \ |
| 49 | + python -m pip install --force-reinstall -r $${_paths[i]} > /dev/null; \ |
| 50 | + nbcollection execute --timeout=600 ${FLAGS} $$notebook; \ |
| 51 | + i=$$((i+1)); \ |
| 52 | + done |
27 | 53 |
|
28 | 54 | convertall: |
29 | | - nbcollection convert ${CONVERTFLAGS} ${FLAGS} tutorials |
| 55 | + i=0; \ |
| 56 | + _paths=($(ALL_RQT_PATHS)); \ |
| 57 | + for notebook in ${ALL_NOTEBOOKS}; do \ |
| 58 | + echo Installing requirements from $${_paths[i]}; \ |
| 59 | + python -m pip install --force-reinstall -r $${_paths[i]} > /dev/null; \ |
| 60 | + nbcollection convert ${CONVERTFLAGS} ${FLAGS} $$notebook; \ |
| 61 | + i=$$((i+1)); \ |
| 62 | + done |
30 | 63 |
|
31 | 64 | clean: |
32 | 65 | rm -rf _build |
|
0 commit comments