-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
138 lines (115 loc) · 3.39 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
136
137
138
# This ensures that we can call `make <target>` even if `<target>` exists as a file or
# directory.
.PHONY: notebook docs data train
# Exports all variables defined in the makefile available to scripts
.EXPORT_ALL_VARIABLES:
# Create .env file if it does not already exist
ifeq (,$(wildcard .env))
$(shell touch .env)
endif
# Includes environment variables from the .env file
include .env
# Set gRPC environment variables, which prevents some errors with the `grpcio` package
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
install-poetry:
@echo "Installing poetry..."
@pipx install poetry==1.2.0
@$(eval include ${HOME}/.poetry/env)
uninstall-poetry:
@echo "Uninstalling poetry..."
@pipx uninstall poetry
install:
@echo "Installing..."
@if [ "$(shell which poetry)" = "" ]; then \
$(MAKE) install-poetry; \
fi
@if [ "$(shell which gpg)" = "" ]; then \
echo "GPG not installed, so an error will occur. Install GPG on MacOS with "\
"`brew install gnupg` or on Ubuntu with `apt install gnupg` and run "\
"`make install` again."; \
fi
@$(MAKE) setup-poetry
@$(MAKE) setup-environment-variables
@$(MAKE) setup-git
setup-poetry:
@poetry env use python3 && poetry install
setup-environment-variables:
@poetry run python3 -m src.scripts.fix_dot_env_file
setup-git:
@git init
@git config --local user.name ${GIT_NAME}
@git config --local user.email ${GIT_EMAIL}
@if [ ${GPG_KEY_ID} = "" ]; then \
echo "No GPG key ID specified. Skipping GPG signing."; \
git config --local commit.gpgsign false; \
else \
echo "Signing with GPG key ID ${GPG_KEY_ID}..."; \
echo 'If you get the "failed to sign the data" error when committing, try running `export GPG_TTY=$$(tty)`.'; \
git config --local commit.gpgsign true; \
git config --local user.signingkey ${GPG_KEY_ID}; \
fi
@poetry run pre-commit install
docs:
@poetry run pdoc --docformat google src/scandinli -o docs
@echo "Saved documentation."
view-docs:
@echo "Viewing API documentation..."
@uname=$$(uname); \
case $${uname} in \
(*Linux*) openCmd='xdg-open'; ;; \
(*Darwin*) openCmd='open'; ;; \
(*CYGWIN*) openCmd='cygstart'; ;; \
(*) echo 'Error: Unsupported platform: $${uname}'; exit 2; ;; \
esac; \
"$${openCmd}" docs/scandinli.html
bump-major:
@poetry run python -m src.scripts.versioning --major
@echo "Bumped major version!"
bump-minor:
@poetry run python -m src.scripts.versioning --minor
@echo "Bumped minor version!"
bump-patch:
@poetry run python -m src.scripts.versioning --patch
@echo "Bumped patch version!"
publish:
@if [ ${PYPI_API_TOKEN} = "" ]; then \
echo "No PyPI API token specified in the '.env' file, so cannot publish."; \
else \
echo "Publishing to PyPI..."; \
poetry publish --build --username "__token__" --password ${PYPI_API_TOKEN}; \
fi
@echo "Published!"
publish-major: bump-major publish
publish-minor: bump-minor publish
publish-patch: bump-patch publish
test:
@poetry run pytest && readme-cov
tree:
@tree -a \
-I .git \
-I .mypy_cache \
-I .env \
-I .venv \
-I poetry.lock \
-I .ipynb_checkpoints \
-I dist \
-I .gitkeep \
-I docs \
-I .pytest_cache \
-I outputs \
-I .DS_Store \
-I .cache \
-I raw \
-I processed \
-I final \
-I models--* \
-I checkpoint-* \
-I .coverage* \
-I .DS_Store \
-I __pycache__ \
.
data:
@poetry run python src/scripts/build_data.py
train:
@poetry run python src/scripts/train.py