-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
270 lines (204 loc) · 6.61 KB
/
Copy pathJustfile
File metadata and controls
270 lines (204 loc) · 6.61 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
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
# Justfile command runner for humans. Agents shoujld ignore this file.
domains_module := "src/ontology/domain"
schema_path := domains_module / "schema"
export_path := "export"
docs_path := "docs"
default:
just --list
#### Maintenance
# check foir key leaks before pushing
check-secure:
gitleaks git -v
gitleaks dir -v
######
# Database Commands
#
# Delete the project database
[group('database maintenance')]
wipe-db:
-@rm .data/ontology.{db,db-shm,db-wal}
# Delete the test database
[group('database maintenance')]
wipe-testdb:
@rm src/ontology/.data/ontology.db
# Run properly-configured alembic
[group('database maintenance')]
migrate msg:
cd src/ontology; alembic revision --autogenerate -m {{ msg }}
#git add ./src/ontology/database/migrations/versions
# Remove existing migrations files; next step is to run `just migrate`
[group('database maintenance')]
wipe-migrations:
@echo DANGER
mv ./src/ontology/database/migrations/versions ./src/ontology/database/migrations/versions.bak
rm -rf "./src/ontology/database/migrations/versions
###
# Frontend commands (FEAT-015 ontology-browser)
#
# Run the frontend dev server
[group('development')]
front-dev:
@cd apps/ontology-browser && pnpm dev
# Run the frontend build
[group('frontend')]
front-build:
@cd apps/ontology-browser && pnpm build
[group('code quality')]
front-lint:
@cd apps/ontology-browser && pnpm lint
[group('code quality')]
front-typecheck:
@cd apps/ontology-browser && pnpm typecheck
[group('test suite')]
front-test:
@cd apps/ontology-browser && pnpm test
[group('frontend')]
front-install:
@cd apps/ontology-browser && pnpm install
[group('frontend')]
front-generate-types:
@cd apps/ontology-browser && pnpm generate:api-types
[group('frontend')]
front-ci-fixme:
@cd apps/ontology-browser && pnpm lint && pnpm typecheck && pnpm test && pnpm build
######
# API Dev server
#
# Start API server for development
[group('development')]
api-dev:
@uv run python tools/serve.py --host 0.0.0.0 --port 8000
######
# Python
#
# Python: Test changes only
[group('test suite')]
test-changed:
@uv run pytest --testmon -s src/ontology
# Python: Reset testmon db
[group('test suite')]
test-reset:
@uv run pytest --testmon-nocollect -s src/ontology
# Python: Test suite
[group('test suite')]
test:
@uv run pytest -s src/ontology
# Python quality checks
[group('code quality')]
check:
@uv run ruff format
@uv run ruff check . --fix
#@uv run basedpyright
#@python tools/check_stubs.py
######
# Docs
#
# List all registered API routes
[group('documentation')]
routes:
#!/usr/bin/env -S uv run python3
from ontology.api import app
print('\nRegistered Routes:')
print('-' * 80)
for route in app.routes:
if hasattr(route, 'methods'):
methods = ', '.join(sorted(route.methods))
print(f"{methods:20} {route.path:50} [{route.name}]")
print('-' * 80)
# Add examples to existing OpenAPI spec
[group('documentation')]
openapi-examples:
@uv run scripts/add-openapi-examples.py
# Validate OpenAPI spec
[group('documentation')]
validate-openapi:
@uv run python -c "import json; json.load(open('docs/api/openapi.json'))" && echo "OpenAPI spec is valid JSON"
# Generate OpenAPI specifications with examples
[group('documentation')]
openapi:
@python scripts/gen-openapi-spec.py
@uv run scripts/add-openapi-examples.py
# Generate OpenAPI base spec only (no examples)
[group('documentation')]
openapi-base:
@python scripts/gen-openapi-spec.py
######
# LinkML schema-related commands
#
schema_yaml := schema_path / "lifeos.yaml"
schema_python := domains_module / "schema_dataclasses.py"
schema_pydantic := domains_module / "schema_models.py"
database_models := domains_module / "database_models.py"
schema_ddl := export_path / "lifeos.ddl"
sample_database := export_path / 'lifeos-sample.db'
schema_owl := docs_path / "lifeos.ttl"
schema_json := docs_path / "lifeos-schema.json"
schema_erd := docs_path / "lifeos-erd.md"
test_file_pydantic := "src/ontology/domains/tests/test_data/container-sample-flat.yaml"
test_file_python := "src/ontology/domains/tests/test_data/container-sample.yaml"
# Validate linkml schema
[group('linkml')]
linkml-validate-schema:
# Attempt to generate jsonschema, if this fails there is something wrong with the yaml
gen-json-schema {{ schema_yaml }} -v
[group('linkml')]
linkml-validate: linkml-validate-schema
# Validate using external instance test data to populate the container;
# this test data was generated by feeding the jsonschema output from the above command to a language model
linkml-validate -s {{ schema_yaml }} --target-class Self -D {{ test_file_pydantic }}
## Code and schema artifact Generation
# Build pydantic models from LinkML models for the ontology with a wrapping container
[group('linkml')]
linkml-pydantic:
gen-pydantic --meta full {{ schema_yaml }} > {{ schema_pydantic }}
# Build python dataclasses from LinkML models for the ontology with a wrapping container
[group('linkml')]
linkml-dataclasses:
gen-python {{ schema_yaml }} > {{ schema_python }}
# Generate declarative SQLAlchemy models
[group('linkml')]
linkml-sqla: linkml-ddl
gen-sqla {{ schema_yaml }} > {{ database_models }}
# Generate SQLite DDL
[group('linkml')]
linkml-ddl:
uv run patches/gen-sqltables-patched.py {{ schema_yaml }} > {{ schema_ddl }}
# Schema definition generators
#
# Build a turtle OWL file
[group('linkml')]
linkml-owl:
gen-owl {{ schema_yaml }} --metadata-profile 'linkml' > {{ schema_owl }}
# generate json-schema for other tools
[group('linkml')]
linkml-jsonschema:
gen-json-schema {{ schema_yaml }} > {{ schema_json }}
# Generate JSON-LD for debugging
[group('linkml')]
linkml-jsonld:
#!/usr/bin/env bash
for f in ./src/ontology/domains/schema/*.yaml; do
gen-jsonld-context --no-metadata "${f}" > $(basename $f .yaml)-1.json
done
# Generate a Mermaid ER diagram (Markdown file) ./erd.md
[group('linkml')]
linkml-erd:
linkml generate erdiagram {{ schema_yaml }} > {{ schema_erd }}
#cp erd.md ~/Documents/pkm-vault/
[group('linkml')]
linkml-sqldump:
linkml-sqldb dump -s {{ schema_yaml }} --target-class Self --db {{ sample_database }} {{ test_file_python }}
######
# Unused
#
# Installer
[group('agent tools')]
install:
@uv sync --group dev
# Retrieve context using our tool
getcontext:
@uv run python tools/build_git_collector_files.py
makehtml:
uvx --from mdtree-mermaid@0.8 mdtree src/ontology/topics/README.md > topics.html
makemermaid:
npx -p @mermaid-js/mermaid-cli mmdc -i src/ontology/topics/README.template.md -o src/ontology/topics/README.md -a src/ontology/topics/images/