-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (54 loc) · 2.2 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
.PHONY: clean data jupyter lint requirements venv
#################################################################################
# GLOBALS #
#################################################################################
PROJECT_NAME = tailor
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
VENV_DIR = $(PROJECT_DIR)/env
JUPYTER_DIR = $(VENV_DIR)/share/jupyter
PYTHON_INTERPRETER = $(VENV_DIR)/bin/python3
PIP = $(VENV_DIR)/bin/pip
IPYTHON = $(VENV_DIR)/bin/ipython
JUPYTER = $(VENV_DIR)/bin/jupyter
NOTEBOOK_DIR = $(PROJECT_DIR)/notebooks
#################################################################################
# COMMANDS #
#################################################################################
## Install Python Dependencies
requirements: venv
$(PIP) install -U pip setuptools wheel
$(PIP) install -r requirements.txt
## Make Dataset
data:
@$(PYTHON_INTERPRETER) src/$(PROJECT_NAME)/data/make_dataset.py
## Delete all compiled Python files
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
## Lint using flake8
lint:
@$(PYTHON_INTERPRETER) -m flake8 --config=$(PROJECT_DIR)/.flake8 src
# Launch jupyter server and create custom kernel if necessary
jupyter:
ifeq ($(wildcard $(JUPYTER_DIR)/kernels/$(PROJECT_NAME)/*),)
@echo "Creating custom kernel..."
@$(IPYTHON) kernel install --sys-prefix --name=$(PROJECT_NAME)
endif
ifeq ($(wildcard $(JUPYTER_DIR)/nbextensions/table_beautifier/*),)
@echo "Installing jupyter notebook extensions..."
@$(JUPYTER) contrib nbextension install --sys-prefix
@$(JUPYTER) nbextensions_configurator enable --sys-prefix
endif
@echo "Running jupyter notebook in background..."
@JUPYTER_CONFIG_DIR=$(NOTEBOOK_DIR) $(JUPYTER) notebook --notebook-dir=$(NOTEBOOK_DIR)
# Generate plots
plots:
@echo "Creating plots..."
@$(PYTHON_INTERPRETER) src/$(PROJECT_NAME)/visualization/visualize.py
## Install virtual environment
venv:
ifeq ($(wildcard $(VENV_DIR)/*),)
@echo "Did not find $(VENV_DIR), creating..."
mkdir -p $(VENV_DIR)
python3 -m venv $(VENV_DIR)
endif