forked from aramis-lab/clinicadl_handbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (46 loc) · 1.61 KB
/
Makefile
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
POETRY ?= poetry
CONDA ?= conda
CONDA_ENV ?= "./env"
PYTHON_SCRIPTS_DIR := src
NOTEBOOKS_DIR := notebooks
BOOK_DIR := jupyter-book
MINIMAL_NOTEBOOK_FILES = $(shell ls $(PYTHON_SCRIPTS_DIR)/*.py | perl -pe "s@$(PYTHON_SCRIPTS_DIR)@$(NOTEBOOKS_DIR)@" | perl -pe "s@\[email protected]@")
.PHONY: help
help: Makefile
@echo "Commands to use ClinicaDL Makefile:"
@sed -n 's/^##//p' $<
## env : Bootstrap an environment
.PHONY: env
env: env.dev
## env.conda : Create a Conda environment
.PHONY: env.conda
env.conda:
@$(CONDA) env create -f environment.yml -p $(CONDA_ENV)
## env.dev : Install with Poetry
.PHONY: env.dev
env.dev:
@$(POETRY) install
## build.notebooks : Build notebooks from source using jupytext
.PHONY: build.notebooks
build.notebooks: $(NOTEBOOKS_DIR)
$(NOTEBOOKS_DIR): $(MINIMAL_NOTEBOOK_FILES)
$(NOTEBOOKS_DIR)/%.ipynb: $(PYTHON_SCRIPTS_DIR)/%.py
@$(POETRY) run jupytext --to notebook $< --output $@
## clean.book : Clean jupyter-book (except for cache)
.PHONY: clean.book
clean.book:
@$(POETRY) run jupyter-book clean $(BOOK_DIR)
## full-clean.book : Full clean of jupyter-bool
.PHONY: full-clean.book
full-clean.book:
@$(RM) -rf $(BOOK_DIR)/_build
## build.book : Build the jupyter-book
.PHONY: build.book
build.book: clean.book
@$(POETRY) run jupyter-book build $(BOOK_DIR)
@$(RM) -rf jupyter-book/_build/html/slides jupyter-book/_build/html/images
@cp -r ./images jupyter-book/_build/html
## sanity-check : Verify if all py files have a correspondent notebook (ipynb file)
.PHONY: sanity-check
sanity-check:
python .build/sanity-check.py $(PYTHON_SCRIPTS_DIR) $(NOTEBOOKS_DIR)