|
a |
|
b/makefile |
|
|
1 |
## makefile automates the build and deployment for python projects |
|
|
2 |
|
|
|
3 |
|
|
|
4 |
## Build system |
|
|
5 |
# |
|
|
6 |
PROJ_TYPE = python |
|
|
7 |
PROJ_MODULES = git python-resources python-cli python-doc python-doc-deploy markdown |
|
|
8 |
PY_DEP_POST_DEPS += modeldeps |
|
|
9 |
PY_CLI_ARGS += --config test-resources/config/default.conf |
|
|
10 |
ADD_CLEAN += medcat.log |
|
|
11 |
CLEAN_DEPS += pycleancache cleanexample |
|
|
12 |
|
|
|
13 |
## Project |
|
|
14 |
# |
|
|
15 |
ENTRY_BIN = ./mednlp |
|
|
16 |
TEST_SENT = "John Smith was diagnosed with liver disease while in Chicago." |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
## Includes |
|
|
20 |
# |
|
|
21 |
include ./zenbuild/main.mk |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
## Targets |
|
|
25 |
# |
|
|
26 |
# install models and their dependencies instead of letting the app do it |
|
|
27 |
.PHONY: modeldeps |
|
|
28 |
modeldeps: |
|
|
29 |
$(PIP_BIN) install $(PIP_ARGS) -r \ |
|
|
30 |
resources/requirements/model.txt --no-deps |
|
|
31 |
|
|
|
32 |
# try to reinstall the `nmslib` python package |
|
|
33 |
.PHONY: reinstallnmslib |
|
|
34 |
reinstallnmslib: |
|
|
35 |
@echo "reinstall no binary nmslib for speed and warnings" |
|
|
36 |
pip uninstall -y nmslib || true |
|
|
37 |
pip install --no-binary :all: nmslib |
|
|
38 |
|
|
|
39 |
# test scispacy entity link db |
|
|
40 |
.PHONY: testentlink |
|
|
41 |
testentlink: |
|
|
42 |
make PY_SRC_TEST=test/entlink test |
|
|
43 |
|
|
|
44 |
# test parsing |
|
|
45 |
.PHONY: testparse |
|
|
46 |
testparse: |
|
|
47 |
@$(ENTRY_BIN) show $(PY_CLI_ARGS) $(TEST_SENT) | \ |
|
|
48 |
diff - test-resources/integration/parse.txt || \ |
|
|
49 |
exit 1 |
|
|
50 |
|
|
|
51 |
# not CUIs/results are after defaulting to notebook only MedCAT model |
|
|
52 |
.PHONY: testfeatures |
|
|
53 |
testfeatures: |
|
|
54 |
@$(ENTRY_BIN) features $(PY_CLI_ARGS) \ |
|
|
55 |
--ids pref_name_,loc --medonly $(TEST_SENT) | \ |
|
|
56 |
diff - test-resources/integration/features.csv || \ |
|
|
57 |
exit 1 |
|
|
58 |
|
|
|
59 |
# test CTS (UMLS terminology service) |
|
|
60 |
.PHONY: testclinicaltuis |
|
|
61 |
testclinicaltuis: |
|
|
62 |
@$(ENTRY_BIN) group byname $(PY_CLI_ARGS) -q \ |
|
|
63 |
Anatomy,Devices,Disorders,Drugs,Genes,Living,Objects,Occupations,Phenomena,Physiology,Procedures | \ |
|
|
64 |
diff - test-resources/integration/tuis.txt || \ |
|
|
65 |
exit 1 |
|
|
66 |
|
|
|
67 |
# integration tests |
|
|
68 |
.PHONY: testint |
|
|
69 |
testint: |
|
|
70 |
@example/features/features.py show | \ |
|
|
71 |
diff - test-resources/integration/ex-features.txt || \ |
|
|
72 |
exit 1 |
|
|
73 |
@example/cui2vec/cui2vec.py similarity -t heart 2>&1 | \ |
|
|
74 |
grep -v RuntimeWarning | \ |
|
|
75 |
grep -v 'dists = dot' | \ |
|
|
76 |
diff - test-resources/integration/cui2vec.txt || \ |
|
|
77 |
exit 1 |
|
|
78 |
@example/uts/uts.py | \ |
|
|
79 |
diff - test-resources/integration/uts.txt || \ |
|
|
80 |
exit 1 |
|
|
81 |
|
|
|
82 |
# unit and integration tests |
|
|
83 |
.PHONY: testall |
|
|
84 |
testall: test testentlink testparse testfeatures testclinicaltuis testint |
|
|
85 |
|
|
|
86 |
# remove cached files created by the examples |
|
|
87 |
.PHONY: cleanexample |
|
|
88 |
cleanexample: |
|
|
89 |
rm -fr example/cache |