-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (52 loc) · 1.72 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
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
VENV = .venv
PYTHON3 = python3.9
RAW_WEATHER_DAT = https://raw.githubusercontent.com/mind-gym/mg-interviews-challenges/master/3-data-munging/weather.dat
RAW_FOOTBALL_DAT = https://raw.githubusercontent.com/mind-gym/mg-interviews-challenges/master/3-data-munging/football.dat
WEATHER_DAT = weather.dat
FOOTBALL_DAT = football.dat
WEATHER_CLEAN = weather.clean
FOOTBALL_CLEAN = football.clean
.PHONY : help clean clean-hard venv download-data prepare-data jupyter install
## help : provides help
help : Makefile
@sed -n 's/^##//p' $<
## clean : removes sentinel files
clean:
rm -f .sentinel*
rm -f $(WEATHER_DAT)
rm -f $(WEATHER_CLEAN)
rm -f $(FOOTBALL_DAT)
rm -f $(FOOTBALL_CLEAN)
## clean-hard : removes sentinel files and venv
clean-hard: clean
rm -rf $(VENV)
## venv : installs virtual environment
venv: .sentinel.venv
## download-data: downloads data
download-data: $(FOOTBALL_DAT) $(WEATHER_DAT)
## prepare-data : prepares data
prepare-data: download-data
@./prepare-data.sh $(FOOTBALL_DAT) > $(FOOTBALL_CLEAN)
./prepare-data.sh $(WEATHER_DAT) > $(WEATHER_CLEAN)
## jupyter : launch jupyter notebook
jupyter: venv
@$(VENV)/bin/jupyter-notebook
## install : sets up virtual environment, downloads raw data, and fire jupyter notebook
install: venv prepare-data jupyter
# private targets
$(FOOTBALL_DAT):
@wget $(RAW_FOOTBALL_DAT) -O $@
$(WEATHER_DAT):
@wget $(RAW_WEATHER_DAT) -O $@
.sentinel.venv: requirements.txt
@if [ ! -f $(VENV)/bin/pip ]; then
$(PYTHON3) -m venv $(VENV)
fi
$(VENV)/bin/pip install -U -r requirements.txt
touch $@