Commit 37cafc8
committed
feat(generators): add --deterministic flag for reproducible output
Add a --deterministic flag to OWL, SHACL, and JSON-LD generators that
produces byte-identical output across invocations, eliminating spurious
diffs in version-controlled artifacts.
Deterministic Turtle serialization (deterministic_turtle):
- W3C RDFC-1.0 canonicalization via pyoxigraph (standard-compliant)
- Weisfeiler-Lehman structural hashing for diff-stable blank node IDs
(_:b<hash>) instead of sequential (_:c14nN)
- Sorted prefix declarations and triple blocks
Collection sorting (gated behind --deterministic):
- owl:oneOf, sh:in, sh:ignoredProperties items sorted when flag is set
- Preserves existing behaviour by default
deterministic_json:
- Recursive deep-sort for JSON-LD context output
pyoxigraph >= 0.4.0 is imported lazily and only when --deterministic is
used. Not a core dependency — avoids conflict with morph-kgc. Tests skip
gracefully when pyoxigraph >= 0.4.0 is unavailable.
Signed-off-by: jdsika <carlo.van-driesten@bmw.de>1 parent 8b7bfa4 commit 37cafc8
7 files changed
Lines changed: 1124 additions & 9 deletions
File tree
- packages/linkml/src/linkml
- generators
- utils
- tests/linkml/test_generators
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
192 | 194 | | |
193 | 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 | + | |
194 | 248 | | |
195 | 249 | | |
196 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
271 | 278 | | |
272 | 279 | | |
273 | 280 | | |
| |||
998 | 1005 | | |
999 | 1006 | | |
1000 | 1007 | | |
1001 | | - | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
1002 | 1012 | | |
1003 | 1013 | | |
1004 | 1014 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
309 | 315 | | |
310 | 316 | | |
311 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
312 | 321 | | |
313 | 322 | | |
314 | 323 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 324 | + | |
319 | 325 | | |
320 | 326 | | |
321 | 327 | | |
| |||
469 | 475 | | |
470 | 476 | | |
471 | 477 | | |
472 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
473 | 482 | | |
474 | 483 | | |
475 | 484 | | |
| |||
0 commit comments