-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
63 lines (49 loc) · 1.91 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
.DEFAULT_GOAL := help
DATA_DIR ?= ./data
SCRIPTS_DIR ?= ./scripts
ECR_REGISTRY ?= 652601739724.dkr.ecr.ap-southeast-2.amazonaws.com
WORKFLOW_IMAGE ?= $(ECR_REGISTRY)/climate_assessment
SR15_EMISSIONS_SCRAPER = $(SCRIPTS_DIR)/get_test_sr15_data.py
SR15_EMISSIONS_DIR = $(DATA_DIR)/sr15
SR15_EMISSIONS_FILE = $(SR15_EMISSIONS_DIR)/sr15_test_data.csv
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([0-9a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
.PHONY: help
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
.PHONY: test
test: ## run all the tests
poetry run pytest src tests -r a -v --doctest-modules --cov=src
.PHONY: checks
checks: ## run all the linting checks of the codebase
@echo "=== pre-commit ==="; poetry run pre-commit run --all-files || echo "--- pre-commit failed ---" >&2; \
echo "======"
.PHONY: docs
docs: ## build the docs
poetry run sphinx-build -T -b html doc doc/build/html
sr15-test-data: $(DATA_DIR) $(SR15_EMISSIONS_SCRAPER) ## download test SR1.5 emissions data
mkdir -p $(SR15_EMISSIONS_DIR)
poetry run python $(SR15_EMISSIONS_SCRAPER) $(SR15_EMISSIONS_FILE)
$(DATA_DIR):
mkdir -p $(DATA_DIR)
.PHONY: virtual-environment
virtual-environment: ## update virtual environment, create a new one if it doesn't already exist
poetry lock --no-update
# Put virtual environments in the project
poetry config virtualenvs.in-project true
poetry install --all-extras
poetry run pre-commit install
# Also export a requirements.txt file
poetry export -f requirements.txt --output requirements.txt
.PHONY: build_and_push_image
build_and_push_image: ## build and push docker image
docker build -f Dockerfile.workflow -t $(WORKFLOW_IMAGE) .
aws ecr get-login-password | docker login --username AWS --password-stdin $(ECR_REGISTRY)
docker push $(WORKFLOW_IMAGE)