-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
135 lines (97 loc) · 3.66 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#################################################################################
# GLOBALS #
#################################################################################
PROJECT_NAME = fake-news-classification
PYTHON_VERSION = 3.11
PYTHON_INTERPRETER = python
#################################################################################
# COMMANDS #
#################################################################################
## Install Python Dependencies
.PHONY: requirements
requirements:
$(PYTHON_INTERPRETER) -m pip install -U pip
$(PYTHON_INTERPRETER) -m pip install -r requirements.txt
## Delete all compiled Python files
.PHONY: clean
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
## Lint using flake8 and black (use `make format` to do formatting)
.PHONY: lint
lint:
flake8 fakenews
isort --check --diff --profile black fakenews
black --check --config pyproject.toml fakenews
## Format source code with black
.PHONY: format
format:
black --config pyproject.toml fakenews
## Set up python interpreter environment
.PHONY: create_environment
create_environment:
conda create --name $(PROJECT_NAME) python=$(PYTHON_VERSION) -y
@echo ">>> conda env created. Activate with:\nconda activate $(PROJECT_NAME)"
#################################################################################
# PROJECT RULES #
#################################################################################
## Make Dataset
.PHONY: data
data: requirements
$(PYTHON_INTERPRETER) fakenews/data/make_dataset.py ${ARGS}
## Make Preprocess
.PHONY: preprocess
preprocess:
$(PYTHON_INTERPRETER) fakenews/data/preprocessing.py ${ARGS}
## Make Preprocess
.PHONY: generate
generate:
$(PYTHON_INTERPRETER) fakenews/data/data_generator.py ${ARGS}
## Make Train
.PHONY: train_model
train:
$(PYTHON_INTERPRETER) fakenews/model/train_model.py ${ARGS}
.PHONY: train_distillation
train_distillation:
$(PYTHON_INTERPRETER) fakenews/model/distillation_training.py ${ARGS}
.PHONY: compare_models
compare_models:
$(PYTHON_INTERPRETER) fakenews/inference/distillation.py ${ARGS}
## Make wandb_registry
.PHONY: wandb_registry
wandb_registry:
$(PYTHON_INTERPRETER) fakenews/model/wandb_registry.py ${ARGS}
## Make predict
.PHONY: predict
predict:
$(PYTHON_INTERPRETER) fakenews/model/predict.py ${ARGS}
## Make transform_model
.PHONY: transform_model
transform_model:
$(PYTHON_INTERPRETER) fakenews/model/transform_model.py ${ARGS}
## Make test_apis
.PHONY: test_inference
test_inference:
$(PYTHON_INTERPRETER) -m pytest tests/integrationtests/test_inference.py ${ARGS}
## Make test_apis
.PHONY: test_monitoring
test_monitoring:
$(PYTHON_INTERPRETER) -m pytest tests/integrationtests/test_monitoring.py ${ARGS}
## Make test_load
.PHONY: test_load
test_load:
locust -f $(CURDIR)/tests/performancetests/locustfile.py ${ARGS}
#################################################################################
# Self Documenting Commands #
#################################################################################
.DEFAULT_GOAL := help
define PRINT_HELP_PYSCRIPT
import re, sys; \
lines = '\n'.join([line for line in sys.stdin]); \
matches = re.findall(r'\n## (.*)\n[\s\S]+?\n([a-zA-Z_-]+):', lines); \
print('Available rules:\n'); \
print('\n'.join(['{:25}{}'.format(*reversed(match)) for match in matches]))
endef
export PRINT_HELP_PYSCRIPT
help:
@python -c "${PRINT_HELP_PYSCRIPT}" < $(MAKEFILE_LIST)