-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathMakefile
More file actions
194 lines (133 loc) · 5.66 KB
/
Copy pathMakefile
File metadata and controls
194 lines (133 loc) · 5.66 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
app_name = CoreMS
parameters_path = parameter.json
LIPIDOMICS_SQLITE_URL ?= https://nmdcdemo.emsl.pnnl.gov/lipidomics/parameter_files/202412_lipid_ref.sqlite
LIPIDOMICS_SQLITE_PATH ?= tests/tests_data/lcms/202412_lipid_ref.sqlite
.PHONY: download-lipidomics-db ci-test-source ci-test-notebooks ci-test-all test-pytest-xdist test-notebooks ci-test
# ----------------------------------------------------------------------
# Platform-specific logic
#
# Default path: macOS/Linux/CI use POSIX shell tools.
# Windows path: avoid assuming Bash, WSL, PowerShell, curl, grep, awk,
# dirname, or mkdir -p. Use Python instead.
# ----------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
# Windows: Python fallback
PYTHON ?= python
version := $(shell $(PYTHON) -c "import configparser; c=configparser.ConfigParser(); c.read('.bumpversion.cfg'); print(c['bumpversion']['current_version'].strip())")
stage := $(shell $(PYTHON) -c "import configparser; c=configparser.ConfigParser(); c.read('.bumpversion.cfg'); print(c['bumpversion:part:release']['optional_value'].strip())")
download-lipidomics-db:
@$(PYTHON) -c "from pathlib import Path; from urllib.request import urlretrieve; p = Path(r'$(LIPIDOMICS_SQLITE_PATH)'); p.parent.mkdir(parents=True, exist_ok=True); url = r'$(LIPIDOMICS_SQLITE_URL)'; print(f'LC-MS lipidomics database already exists at {p}') if p.exists() else (print('Downloading LC-MS lipidomics database'), urlretrieve(url, p), print('LC-MS lipidomics database downloaded'))"
else
# macOS/Linux/CI: POSIX shell path
PYTHON ?= python3
version := $(shell grep '^[[:space:]]*current_version[[:space:]]*=' .bumpversion.cfg | head -n 1 | cut -d= -f2 | tr -d ' ')
stage := $(shell awk 'BEGIN{section=0} /^\[bumpversion:part:release\]/{section=1; next} /^\[/{section=0} section && /^[[:space:]]*optional_value[[:space:]]*=/{split($$0,a,"="); gsub(/[[:space:]]/,"",a[2]); print a[2]; exit}' .bumpversion.cfg)
download-lipidomics-db:
@if [ -f "$(LIPIDOMICS_SQLITE_PATH)" ]; then \
echo "LC-MS lipidomics database already exists at $(LIPIDOMICS_SQLITE_PATH)"; \
else \
echo "Downloading LC-MS lipidomics database"; \
mkdir -p "$$(dirname "$(LIPIDOMICS_SQLITE_PATH)")"; \
curl --retry 3 --retry-delay 5 --connect-timeout 30 --max-time 300 -L -o "$(LIPIDOMICS_SQLITE_PATH)" "$(LIPIDOMICS_SQLITE_URL)"; \
echo "LC-MS lipidomics database downloaded"; \
fi
endif
cpu:
pyprof2calltree -k -i $(file)
mem:
mprof run --multiprocess $(script)
mprof plot
major:
@bumpversion major --allow-dirty
@$(MAKE) docu
minor:
@bumpversion minor --allow-dirty
@$(MAKE) docu
patch:
@bumpversion patch --allow-dirty
@$(MAKE) docu
pypi_test:
@rm -rf build dist *.egg-info
@python3 -m build
@twine upload --repository testpypi dist/*
pypi:
@rm -rf build dist *.egg-info
@python3 -m build
@twine upload dist/*
tag:
@git tag -a $(version).$(stage) -m "version $(version).$(stage)"
@git push origin $(version).$(stage)
@echo tagged $(version).$(stage) and pushed
build-image-local:
@echo corems:$(version)
@docker build -t corems:$(version) .
build-image:
@echo corilo/corems:$(version)
@docker build -t corilo/corems:$(version) .
build-image-mac:
@echo corilo/corems:$(version)
@docker build --platform linux/amd64 -t corilo/corems:$(version) .
build-image-mac-local:
@echo corems:$(version)
@docker build --platform linux/amd64 -t corems:$(version) .
push-image:
@docker push corilo/corems:$(version)
@docker image tag corilo/corems:$(version) corilo/corems:latest
@docker push corilo/corems:latest
image-run-mac:
@docker run -it --platform linux/amd64 corilo/corems:$(version)
image-run-mac-local:
@docker run -it --platform linux/amd64 corems:$(version)
image-run:
@docker run -it corilo/corems:$(version)
image-run-local:
@docker run -it corems:$(version)
db-up:
@docker-compose up -d
db-down:
@docker-compose down
db-logs:
@docker-compose logs -f
db-connect:
@docker exec -it molformdb psql -U postgres
docu:
pdoc --output-dir docs --docformat numpy corems
SKIP_LIPIDOMICS_DB ?= 0
SKIP_MOLECULAR_DB ?= 0
ci-test-source:
@$(PYTHON) -V
@$(PYTHON) -m pip install --upgrade pip
@$(PYTHON) -m pip install -e ".[dev]"
@skip_flags=""; \
if [ "$(SKIP_LIPIDOMICS_DB)" = "1" ]; then \
echo "Skipping lipidomics DB download (SKIP_LIPIDOMICS_DB=1)"; \
skip_flags="$$skip_flags --skip-lipidomics-db"; \
else \
$(MAKE) download-lipidomics-db LIPIDOMICS_SQLITE_PATH="$(LIPIDOMICS_SQLITE_PATH)"; \
fi; \
if [ "$(SKIP_MOLECULAR_DB)" = "1" ]; then \
echo "Skipping molecular formula database tests (SKIP_MOLECULAR_DB=1)"; \
skip_flags="$$skip_flags --skip-molecular-db"; \
fi; \
PYTHONNET_RUNTIME=coreclr COREMS_LIPIDOMICS_SQLITE_PATH="$(LIPIDOMICS_SQLITE_PATH)" \
$(PYTHON) -m pytest --cache-clear -p no:warnings -n 4 --dist=loadfile --no-cov $$skip_flags
ci-test-notebooks:
@$(PYTHON) -V
@$(PYTHON) -m pip install --upgrade pip
@$(PYTHON) -m pip install -e ".[dev]"
@$(PYTHON) -m pip install --no-cache-dir jupyter nbconvert
@if [ "$(SKIP_LIPIDOMICS_DB)" = "1" ]; then \
echo "Skipping lipidomics DB download (SKIP_LIPIDOMICS_DB=1)"; \
PYTHONNET_RUNTIME=coreclr $(PYTHON) examples/test_notebooks.py; \
else \
$(MAKE) download-lipidomics-db LIPIDOMICS_SQLITE_PATH="$(LIPIDOMICS_SQLITE_PATH)"; \
PYTHONNET_RUNTIME=coreclr COREMS_LIPIDOMICS_SQLITE_PATH="$(LIPIDOMICS_SQLITE_PATH)" \
$(PYTHON) examples/test_notebooks.py; \
fi
ci-test-all: ci-test-source ci-test-notebooks
test-pytest-xdist: download-lipidomics-db
pytest -n auto --no-cov --cache-clear -p no:warnings
test-notebooks: download-lipidomics-db
python3 -m pip install --no-cache-dir jupyter nbconvert
cd examples && python3 test_notebooks.py
ci-test: test-pytest-xdist test-notebooks