forked from linkml/linkml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (103 loc) · 3.98 KB
/
Makefile
File metadata and controls
130 lines (103 loc) · 3.98 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
VERSION = $(shell git tag | tail -1)
SPECIFICATION.pdf: SPECIFICATION.md
pandoc $< -o $@
# for now we only have one example
all-examples: all-examples-organization
# for each example schema, make all derived schema products, and derived serializations for the example data file
all-examples-%: examples/%.py examples/%.schema.json examples/%.shex examples/%.graphql examples/%.graphql examples/%.shex examples/%.proto examples/%.shex examples/%.valid examples/%-data.nt
echo done
#RUN=pipenv run
RUN=uv run
lint-fix:
$(RUN) tox -e format
format: lint-fix
test:
$(RUN) pytest
# Metamodel compatibility: download latest metamodel from linkml-model
LINKML_MODEL_BRANCH ?= main
LINKML_MODEL_REPO = https://github.com/linkml/linkml-model.git
METAMODEL_DIR = tests/linkml/test_metamodel_compat/input/metamodel
download-metamodel:
rm -rf temp/linkml-model
git clone --depth 1 --branch $(LINKML_MODEL_BRANCH) $(LINKML_MODEL_REPO) temp/linkml-model
rm -f $(METAMODEL_DIR)/*.yaml
cp temp/linkml-model/linkml_model/model/schema/*.yaml $(METAMODEL_DIR)/
sed -i.bak '/^#.*- linkml:/d' $(METAMODEL_DIR)/*.yaml
sed -i.bak 's/- linkml:\([a-zA-Z_]*\)/- \1/g' $(METAMODEL_DIR)/*.yaml
rm -f $(METAMODEL_DIR)/*.bak
rm -rf temp/linkml-model
test-metamodel:
mkdir -p temp
$(RUN) pytest tests/linkml/test_metamodel_compat/ --with-slow -v 2>&1 | tee temp/test_output.txt
## Example schema products
examples/%.py: examples/%.yaml
$(RUN) gen-py-classes $< > $@ && $(RUN) python -m examples.$*
examples/%.shex: examples/%.yaml
$(RUN) gen-shex $< > $@
examples/%.schema.json: examples/%.yaml
$(RUN) gen-json-schema -t $* $< > $@
examples/%.context.jsonld: examples/%.yaml
$(RUN) gen-jsonld-context -t $* $< > $@
examples/%.graphql: examples/%.yaml
$(RUN) gen-graphql $< > $@
examples/%.context.jsonld: examples/%.yaml
$(RUN) gen-jsonld-context $< > $@
examples/%.jsonld: examples/%.yaml
$(RUN) gen-jsonld $< > $@
examples/%.shex: examples/%.yaml
$(RUN) gen-shex $< > $@
examples/%.proto: examples/%.yaml
$(RUN) gen-proto $< > $@
examples/%.owl: examples/%.yaml
$(RUN) gen-owl $< > $@
examples/%.ttl: examples/%.yaml
$(RUN) gen-rdf $< > $@
examples/%-docs: examples/%.yaml
$(RUN) gen-doc $< -d $@
## Example instance data products
examples/%.valid: examples/%-data.json examples/%.schema.json
jsonschema -i $^
examples/%-data.jsonld: examples/%-data.json examples/%.context.jsonld
jq -s '.[0] * .[1]' $^ > $@
examples/%-data.nt: examples/%-data.jsonld
riot $< > $@
linkml/workspaces/datamodel/workspaces.py: linkml/workspaces/datamodel/workspaces.yaml
$(RUN) gen-python $< > $@.tmp && mv $@.tmp $@
linkml/linter/config/datamodel/config.py: linkml/linter/config/datamodel/config.yaml
$(RUN) gen-python $< > $@.tmp && mv $@.tmp $@
TUTORIALS = 01 02 03 04 05 06 07 08 09 10
test-tutorials: $(patsubst %, test-tutorial-%, $(TUTORIALS))
test-tutorial-%: docs/intro/tutorial%.md
$(RUN) python -m linkml.utils.execute_tutorial -d /tmp/tutorial $<
build-generator-dashboard:
$(RUN) pytest tests/linkml/test_compliance/ --with-output -q
$(RUN) python scripts/generate_dashboard.py
docs:
cd docs && $(RUN) make html
################################################
#### Commands for building the Docker image ####
################################################
IM=linkml/linkml
docker-build-no-cache:
@docker build --no-cache -t $(IM):$(VERSION) . \
&& docker tag $(IM):$(VERSION) $(IM):latest
docker-build:
@docker build -t $(IM):$(VERSION) . \
&& docker tag $(IM):$(VERSION) $(IM):latest
docker-build-use-cache-dev:
@docker build -t $(DEV):$(VERSION) . \
&& docker tag $(DEV):$(VERSION) $(DEV):latest
docker-clean:
docker kill $(IM) || echo not running ;
docker rm $(IM) || echo not made
docker-publish-no-build:
@docker push $(IM):$(VERSION) \
&& docker push $(IM):latest
docker-publish-dev-no-build:
@docker push $(DEV):$(VERSION) \
&& docker push $(DEV):latest
docker-publish: docker-build
@docker push $(IM):$(VERSION) \
&& docker push $(IM):latest
docker-run:
@docker run -v $(PWD):/work -w /work -ti $(IM):$(VERSION)