-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (54 loc) · 2.45 KB
/
Makefile
File metadata and controls
79 lines (54 loc) · 2.45 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
SHELL=/bin/bash -o pipefail
BUILD_PRINT = \e[1;34m
END_BUILD_PRINT = \e[0m
ICON_DONE = [✔]
ICON_ERROR = [x]
ICON_WARNING = [!]
ICON_PROGRESS = [-]
LINKML_MODEL_NAME=ere-service-schema
LINKML_MODEL_VERSION=0.1.0
PYTHON_MODEL_PATH=src/ere/models/core.py
SCHEMAS_DIR=resources/schemas
LINKML_MODEL_PATH=$(SCHEMAS_DIR)/$(LINKML_MODEL_NAME)-v$(LINKML_MODEL_VERSION).yaml
JSON_SCHEMA_PATH=$(SCHEMAS_DIR)/$(LINKML_MODEL_NAME)-v$(LINKML_MODEL_VERSION).json
MODEL_DOCS_DIR=docs/schema
MODEL_DOCS_README=$(MODEL_DOCS_DIR)/README.md
## Setup commands
#
# Note that Python, Poetry and Make are a pre-requisites and we don't deal with them here.
#
install:
@ echo "Installing dependencies using Poetry..."
@ poetry sync
## Build commands
#
all: $(PYTHON_MODEL_PATH) $(JSON_SCHEMA_PATH) $(MODEL_DOCS_README)
generate-models: $(PYTHON_MODEL_PATH) $(JSON_SCHEMA_PATH)
generate-doc: $(MODEL_DOCS_README)
.PHONY: all generate-models generate-doc clean clean-doc clean-models install install-dev check-uv
$(PYTHON_MODEL_PATH): $(LINKML_MODEL_PATH)
@ echo "Generating Python service model..."
@ mkdir -p $(dir $(PYTHON_MODEL_PATH))
@ poetry run linkml generate pydantic $(LINKML_MODEL_PATH) > $(PYTHON_MODEL_PATH)
$(JSON_SCHEMA_PATH): $(LINKML_MODEL_PATH)
@ echo "Generating JSON Schema for the ERE service..."
@ mkdir -p $(dir $(JSON_SCHEMA_PATH))
@ poetry run linkml generate json-schema --indent 2 $(LINKML_MODEL_PATH) > $(JSON_SCHEMA_PATH)
$(MODEL_DOCS_README): $(LINKML_MODEL_PATH)
@ echo "Generating documentation for the ERE service Schema..."
# Changing default index name from index.md to README.md, since the github browser automatically shows the latter name
# when entering the MODEL_DOCS_DIR
@ poetry run linkml generate doc $(LINKML_MODEL_PATH) -d $(MODEL_DOCS_DIR) --index-name README
# TODO: Probably we want PNG instead, but it doesn't work yet (https://github.com/linkml/linkml/issues/3009)
@ poetry run linkml generate plantuml -d $(MODEL_DOCS_DIR) --format svg $(LINKML_MODEL_PATH)
# (Brandizi) I've played with it, but the result isn't great (single-class diagrams in each
# class file)
# @ poetry run linkml generate doc -d $(MODEL_DOCS_DIR) --diagram-type plantuml_class_diagram $(LINKML_MODEL_PATH)
clean-models:
@ echo "Cleaning up generated models..."
@ rm -rf $(PYTHON_MODEL_PATH) $(JSON_SCHEMA_PATH)
clean-doc:
@ echo "Cleaning up generated documentation..."
@ rm -rf $(MODEL_DOCS_DIR)/*.md
clean: clean-doc clean-models
@ echo "All generated files cleaned."