forked from biolink/biolink-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
280 lines (212 loc) · 8.28 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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# All artifacts of the build should be preserved
.SECONDARY:
# It can be fairly expensive to regenerate the various png's in the markdown.
# There are three alternatives:
# 1) make imgflags="-i" -- generate uml images in images subdirectory (default)
# 2) make imgflags="-i --noimages" -- assume uml images already exist and generate links to them
# 3) make imgflags="" -- generate uml images as inline url's
imgflags?=-i
# ----------------------------------------
# TOP LEVEL TARGETS
# ----------------------------------------
all: install tests build
# Build the biolink model python library
python: biolink/model.py
docs: docs/index.md
jekyll-docs: docs/Classes.md
shex: biolink-model.shex biolink-modeln.shex biolink-model.shexj biolink-modeln.shexj
shacl: biolink-model.shacl.ttl
json-schema: json-schema/biolink-model.json
prefix-map: prefix-map/biolink-model-prefix-map.json
build: python docs/index.md gen-golr-views biolink-model.graphql gen-graphviz context.jsonld contextn.jsonld infores \
json-schema/biolink-model.json biolink-model.owl.ttl biolink-model.proto shex shacl biolink-model.ttl \
prefix-map/biolink-model-prefix-map.json gen-pydantic id-prefixes
# TODO: Get this working
build_contrib: contrib_build_monarch contrib_build_translator contrib_build_go
install: env.lock
# ---------------------------------------
# Install package into build environment
# ---------------------------------------
env.lock:
poetry install
cp /dev/null env.lock
# ----------------------------------------
# BUILD/COMPILATION
# ----------------------------------------
# ~~~~~~~~~~~~~~~~~~~~
# Python
# ~~~~~~~~~~~~~~~~~~~~
biolink/model.py: biolink-model.yaml env.lock
mkdir biolink 2>/dev/null || true
poetry run gen-py-classes $< > [email protected] && poetry run python [email protected] && mv [email protected] $@
infores:
poetry run gen-python information-resource.yaml > information_resource.py
# ~~~~~~~~~~~~~~~~~~~~
# DOCS
# ~~~~~~~~~~~~~~~~~~~~
docs/index.md: biolink-model.yaml env.lock
poetry run gen-markdown --dir docs $(imgflags) $<
# ~~~~~~~~~~~~~~~~~~~~
# JEKYLL DOCS
# ~~~~~~~~~~~~~~~~~~~~
docs/Classes.md: biolink-model.yaml env.lock
poetry run python scripts/jekyllmarkdowngen.py --dir jekyll_docs --yaml $<
# ~~~~~~~~~~~~~~~~~~~~
# Solr
# ~~~~~~~~~~~~~~~~~~~~
gen-golr-views: biolink-model.yaml dir-golr-views env.lock
poetry run gen-golr-views -d golr-views $<
# ~~~~~~~~~~~~~~~~~~~~
# pydantic
# ~~~~~~~~~~~~~~~~~~~~
gen-pydantic: biolink-model.yaml dir-pydantic env.lock
poetry run gen-pydantic $< > biolink/pydanticmodel.py
# poetry run gen-pydantic --pydantic_version 1 $< > biolink/pydanticmodel_v1.py
gen-pydantic-v2: biolink-model.yaml dir-pydantic env.lock
poetry run gen-pydantic --pydantic_version 2 $< > biolink/pydanticmodel_v2.py
# poetry run gen-pydantic --pydantic_version 2 $< > biolink/pydanticmodel.py
# ~~~~~~~~~~~~~~~~~~~~
# Graphql
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.graphql: biolink-model.yaml env.lock
poetry run gen-graphql $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# Graphviz
# ~~~~~~~~~~~~~~~~~~~~
gen-graphviz: biolink-model.yaml dir-graphviz env.lock
poetry run gen-graphviz -d graphviz $< -f gv
poetry run gen-graphviz -d graphviz $< -f svg
# ~~~~~~~~~~~~~~~~~~~~
# Java
# ~~~~~~~~~~~~~~~~~~~~
java: json-schema/biolink-model.json dir-java env.lock
jsonschema2pojo --source $< -T JSONSCHEMA -t java
# ~~~~~~~~~~~~~~~~~~~~
# JSON-LD CONTEXT
# ~~~~~~~~~~~~~~~~~~~~
context.jsonld: biolink-model.yaml env.lock
touch $@
poetry run gen-jsonld-context $< > tmp.jsonld && ( poetry run comparefiles tmp.jsonld $@ -c "^\s*\"comments\".*\n" && cp tmp.jsonld $@); rm tmp.jsonld
contextn.jsonld: biolink-model.yaml env.lock
touch $@
poetry run gen-jsonld-context --metauris $< > tmp.jsonld && ( poetry run comparefiles tmp.jsonld $@ -c "^\s*\"comments\".*\n" && cp tmp.jsonld $@); rm tmp.jsonld
# ~~~~~~~~~~~~~~~~~~~~
# JSON-SCHEMA
# ~~~~~~~~~~~~~~~~~~~~
json-schema/biolink-model.json: biolink-model.yaml dir-json-schema env.lock
poetry run gen-json-schema $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# prefix-map
# ~~~~~~~~~~~~~~~~~~~~
prefix-map/biolink-model-prefix-map.json: biolink-model.yaml dir-prefix-map env.lock
poetry run gen-prefix-map $< > $@
id-prefixes:
poetry run gen-python prefix-map/class_prefixes.yaml > scripts/classprefixes.py
cd scripts && poetry run python id_prefixes.py
# ~~~~~~~~~~~~~~~~~~~~
# Ontology
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.owl.ttl: biolink-model.yaml env.lock
poetry run gen-owl --no-metaclasses -o $@ $<
# ~~~~~~~~~~~~~~~~~~~~
# Proto
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.proto: biolink-model.yaml env.lock
poetry run gen-proto $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# RDF
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.ttl: biolink-model.yaml env.lock
poetry run gen-rdf -f ttl --context https://w3id.org/linkml/context.jsonld $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# ShEx
# ~~~~~~~~~~~~~~~~~~~~
biolink-modeel.shex: biolink-model.yaml
poetry run gen-shex $< > $@
biolink-modeln.shex: biolink-model.yaml
touch $@
poetry run gen-shex --metauris $< > $@
biolink-model.shexj: biolink-model.yaml
touch $@
poetry run gen-shex --format json $< > $@
biolink-modeln.shexj: biolink-model.yaml
touch $@
poetry run gen-shex --metauris --format json $< > $@
# ~~~~~~~~~~~~~~~~~~~~
# SHACL
# ~~~~~~~~~~~~~~~~~~~~
biolink-model.shacl.ttl: biolink-model.yaml
poetry run gen-shacl $< > $@
# ----------------------------------------
# Ontology conversion
# ----------------------------------------
# ontology/%.json: ontology/%.ttl
# owltools $< -o -f json $@
# ontology/%.obo: ontology/%.ttl
# owltools $< -o -f obo --no-check $@
# ontology/%.omn: ontology/%.ttl
# owltools $< -o -f omn --prefix '' http://w3id.org/biolink/vocab/ --prefix def http://purl.obolibrary.org/obo/IAO_0000115 $@
# ontology/%.tree: ontology/%.json
# ogr --showdefs -t tree -r $< % > $@
# ontology/%.png: ontology/%.json
# ogr-tree -t png -o $@ -r $< %
# ~~~~~~~~~~~~~~~~~~~~
# Contrib
# ~~~~~~~~~~~~~~~~~~~~
contrib_build_%: contrib-dir-% contrib/%/docs/index.md contrib/%/datamodel.py contrib-golr-% contrib/%/%.graphql \
contrib/%/%.owl contrib/%/schema.json contrib-java-% contrib/%/%.shex contrib/%/%.shacl.ttl
echo
contrib/%/datamodel.py: contrib-dir-% contrib/%.yaml env.lock
poetry run gen-py-classes contrib/$*.yaml > tmp.py && (poetry run comparefiles tmp.py $@ && cp tmp.py $@); rm tmp.py
contrib/%/docs/index.md: contrib/%.yaml
poetry run gen-markdown --dir contrib/$*/docs $<
contrib/%/datamodel.py: contrib/%.yaml
poetry run gen-py-classes contrib/$*.yaml > $@
contrib-golr-%: contrib-dir-% contrib/%.yaml
poetry run gen-golr-views -d contrib/$*/golr-views contrib/$*.yaml
contrib-pydantic-%: contrib-dir-% contrib/%.yaml
poetry run gen-pydantic -d contrib/$*/pydantic contrib/$*.yaml
contrib/%/%.graphql: contrib-dir-% contrib/%.yaml
poetry run gen-graphql contrib/$*.yaml > contrib/$*/$*.graphql
contrib-java-%: contrib-dir-% contrib/%/schema.json
mkdir -p contrib/$*/java
jsonschema2pojo --source contrib/$*/schema.json -T JSONSCHEMA -t contrib/$*/java
contrib/%/schema.json: contrib-dir-% contrib/%.yaml
poetry run gen-json-schema contrib/$*.yaml > $@
contrib/%/%.owl: contrib/%.yaml
poetry run gen-owl -o $@ contrib/$*.yaml
contrib/%/%.shex: contrib-dir-% contrib/%.yaml
poetry run gen-shex contrib/*.yaml > $@
contrib/%/%.shacl.ttl: contrib-dir-% contrib/%.yaml
poetry run gen-shacl contrib/*.yaml > $@
# ----------------------------------------
# TESTS
# ----------------------------------------
test: tests
tests: biolink-model.yaml env.lock pytest # jsonschema_test
poetry run python -m unittest discover -p 'test_*.py'
poetry run codespell
poetry run yamllint -c .yamllint-config biolink-model.yaml
poetry run yamllint -c .yamllint-config infores_catalog.yaml
poetry run python scripts/verify_infores.py
spell:
poetry run codespell
pytest: biolink/model.py
poetry run python $<
# jsonschema_test: json-schema/biolink-model.json
# jsonschema $<
# ----------------------------------------
# CLEAN
# ----------------------------------------
clean:
rm -rf contrib/go contrib/monarch contrib/translator docs/images/* docs/*.md golr-views graphql graphviz java json json-schema ontology proto rdf shex shacl pydantic
rm -f env.lock
rm -rf information_resource.py
poetry --rm
# ----------------------------------------
# UTILS
# ----------------------------------------
dir-%:
mkdir -p $*
contrib-dir-%:
mkdir -p contrib/$*