-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
117 lines (94 loc) · 3.15 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
#################################################################################
# GLOBALS #
#################################################################################
PROJECT_NAME = scipeds
PYTHON_VERSION = 3.11.10
PYTHON_INTERPRETER = python
#################################################################################
# COMMANDS #
#################################################################################
## 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)"
## Install Python Dependencies
.PHONY: requirements
requirements:
$(PYTHON_INTERPRETER) -m pip install -U pip
$(PYTHON_INTERPRETER) -m pip install -r requirements/dev.txt
## Format source code with ruff
.PHONY: format
format:
ruff format
ruff check --fix
## Lint using ruff (use `make format` to do formatting)
.PHONY: lint
lint:
ruff check
mypy scipeds pipeline
## Build distribution packages
.PHONY: build
build:
python -m build
ls -l dist
## Delete all compiled Python files
.PHONY: clean
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
#################################################################################
# PROJECT RULES #
#################################################################################
## Run tests
.PHONY: test
test:
pytest -v scipeds
## Run pipeline tests
.PHONY: test-pipeline
test-pipeline:
pytest -v pipeline
## Generate test assets
.PHONY: test-assets
test-assets:
python pipeline/db.py write-test-db
## Debug tests
.PHONY: test-debug
test-debug:
pytest -v scipeds --pdb
## Build static version of docs
.PHONY: docs-requirements
docs-requirements:
pip install -r requirements/docs.txt
## Build static version of docs
.PHONY: docs-build
docs-build:
cd docs && mkdocs build --clean
## Serve docs locally
.PHONY: docs-serve
docs-serve:
cd docs && mkdocs serve --clean
## Download raw data files from Cloud Storage
.PHONY: download-raw
download-raw:
python pipeline/download.py download-from-bucket
## Process all raw files, write interims, and create duckdb database
.PHONY: process
process:
python pipeline/completions.py
python pipeline/institutions.py
python pipeline/db.py write-db --overwrite
#################################################################################
# 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)