-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
89 lines (62 loc) · 1.95 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
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
# BranchedGP Makefile
#
# We use this makefile to collect commonly used commands in one location.
# A "rule" or a "command" is defined via:
#
# rule:
# <shell commands for this 'rule'>
#
# Invoke by running `make rule`. See also https://www.gnu.org/software/make/.
####################
# Common constants #
####################
TEST_PATH=testing
TEST_REQUIREMENTS=test_requirements.txt
NOTEBOOK_PATH=notebooks
PACKAGE_PATH=BranchedGP
ALL_CODE_PATHS=$(TEST_PATH) $(NOTEBOOK_PATH) $(PACKAGE_PATH)
##################################
# Virtual environment management #
##################################
install:
pip install -r $(TEST_REQUIREMENTS)
pip install -e .
freeze_requirements:
pip freeze > $(TEST_REQUIREMENTS)
#############################
# Jupyter notebook commands #
#############################
jupyter_server:
jupyter notebook $(NOTEBOOK_PATH)
sync_notebooks:
jupytext --sync $(NOTEBOOK_PATH)/*.ipynb
pair_notebooks:
jupytext --set-formats ipynb,py:percent $(NOTEBOOK_PATH)/*.ipynb
check_notebooks_synced:
jupytext --test-strict -x $(NOTEBOOK_PATH)/*.ipynb --to py:percent
#############################################
# Commands for making sure code doesn't rot #
#############################################
test:
pytest $(TEST_PATH)
check_black:
black --check $(ALL_CODE_PATHS)
check_isort:
isort --diff $(ALL_CODE_PATHS)
check_format: check_black check_isort
isort_code:
isort $(PACKAGE_PATH) $(TEST_PATH)
isort_notebooks:
jupytext --pipe 'isort - --treat-comment-as-code "# %%" --float-to-top' $(NOTEBOOK_PATH)/*.ipynb
black_code:
black $(PACKAGE_PATH) $(TEST_PATH)
black_notebooks:
jupytext --sync --pipe black $(NOTEBOOK_PATH)/*.ipynb
format: isort_code black_code isort_notebooks black_notebooks
lint_code:
flake8 --config .flake8_code $(PACKAGE_PATH) $(TEST_PATH)
lint_notebooks:
flake8 --config .flake8_notebooks $(NOTEBOOK_PATH)
mypy:
mypy --ignore-missing-imports $(ALL_CODE_PATHS)
static_checks: mypy lint_code lint_notebooks