forked from epwalsh/nlp-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (80 loc) · 2.25 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
90
91
92
93
94
95
debug = 0
test = nlpete scripts
COVERAGE := $(addprefix --cov=, $(test))
PYTHONPATH = allennlp
DATADIR = data
DATASETS := $(wildcard $(DATADIR)/*.tar.gz)
EXPERIMENTDIR = experiments
EXPERIMENTS := $(wildcard $(EXPERIMENTDIR)/**/*.json)
BENCHMARKDIR = scripts/benchmarking
BENCHMARKS := $(wildcard $(BENCHMARKDIR)/*.py)
#
# Training commands.
#
.PHONY : train
train :
ifeq ($(debug),0)
@./scripts/training/train.sh
else
@echo "<=== Debug mode ===>"
@CUDA_LAUNCH_BLOCKING=1 ./scripts/training/train.sh
endif
.PHONY : tensorboard
tensorboard :
@TB_PORT=$(port) TB_LOGDIR=$(logdir) ./scripts/training/tensorboard.sh
.PHONY : vocab
vocab :
@./scripts/training/make_vocab.sh
# Need this to force targets to build, even when the target file exists.
.PHONY : phony-target
$(DATADIR)/%.tar.gz : phony-target
@if ! [ -d $(patsubst %.tar.gz,%,$@) ]; then \
echo "Extracting $@ to $(patsubst %.tar.gz,%,$@)"; \
mkdir -p $(patsubst %.tar.gz,%,$@) && tar xzfv $@ -C $(patsubst %.tar.gz,%,$@) --strip-components 1; \
fi
$(EXPERIMENTDIR)/%.json : phony-target
./scripts/training/train.sh $@
#
# Testing commands.
#
.PHONY : typecheck
typecheck :
@echo "Typechecks: mypy"
@PYTHONPATH=$(PYTHONPATH) mypy $(test) --ignore-missing-imports
.PHONY : lint
lint :
@echo "Lint: pydocstyle"
@pydocstyle --config=.pydocstyle $(test)
@echo "Lint: pylint"
@PYTHONPATH=$(PYTHONPATH) pylint --rcfile=.pylintrc -f colorized $(test)
.PHONY : unit-test
unit-test :
@echo "Unit tests: pytest"
ifneq ($(findstring test,$(test)),)
PYTHONPATH=$(PYTHONPATH) python -m pytest -v --color=yes $(test)
else
PYTHONPATH=$(PYTHONPATH) python -m pytest -v --cov-config .coveragerc $(COVERAGE) --color=yes $(test)
endif
.PHONY : check-scripts
check-scripts :
./scripts/checks/run_all.sh \
./scripts/checks/check_requirements.sh \
./scripts/checks/check_links.py \
./scripts/checks/check_whitespace.sh \
$(BENCHMARKS)
.PHONY : test
test : typecheck lint unit-test
#
# Git helpers.
#
.PHONY: create-branch
create-branch :
ifneq ($(issue),)
git checkout -b ISSUE-$(issue)
git push --set-upstream origin ISSUE-$(issue)
else ifneq ($(name),)
git checkout -b $(name)
git push --set-upstream origin $(name)
else
$(error must supply 'issue' or 'name' parameter)
endif