Skip to content

Commit 629d50c

Browse files
committed
feat(openlabel): add structural LinkML schema for ASAM v1 JSON format
- Add openlabel-v2-schema.yaml: 12 classes, 4 enums, 227 TagTypeEnum values - Generate JSON Schema artifact (openlabel-v2.schema.json) via gen-json-schema - Add sync_tag_type_enum.py script to keep vocabulary in sync with ontology - Add convert_openlabel_v1_to_v2.py script for v1-to-v2 format conversion - Add 19 pytest tests covering schema generation, validation, sync, and converter - Wire pre-commit hook for automatic TagTypeEnum synchronization - Extend Makefile generate target to produce JSON Schema when schema model exists - Document unified modeling strategy in SCHEMA_MODELING.md Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>
1 parent d452ec2 commit 629d50c

9 files changed

Lines changed: 2988 additions & 6 deletions

File tree

.pre-commit-config.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ repos:
1616
types: [python]
1717
pass_filenames: true
1818

19+
- id: sync-tag-type-enum
20+
name: Sync TagTypeEnum to structural schema
21+
entry: python scripts/sync_tag_type_enum.py
22+
language: system
23+
pass_filenames: false
24+
files: ^linkml/openlabel-v2/openlabel-v2\.yaml$
25+
stages: [pre-commit]
26+
1927
- id: generate-linkml
2028
name: Generate LinkML Artifacts
2129
entry: make generate
@@ -51,23 +59,23 @@ repos:
5159
entry: python -m src.tools.utils.registry_updater
5260
language: system
5361
pass_filenames: false
54-
files: ^artifacts/.*\.(owl\.ttl|shacl\.ttl|context\.jsonld)$
62+
files: ^artifacts/.*\.(owl\.ttl|shacl\.ttl|context\.jsonld|schema\.json)$
5563
stages: [pre-commit]
5664

5765
- id: update-properties
5866
name: Update Properties Documentation
5967
entry: python -m src.tools.utils.properties_updater
6068
language: system
6169
pass_filenames: false
62-
files: ^artifacts/.*\.(owl\.ttl|shacl\.ttl|context\.jsonld)$
70+
files: ^artifacts/.*\.(owl\.ttl|shacl\.ttl|context\.jsonld|schema\.json)$
6371
stages: [pre-commit]
6472

6573
- id: update-readme
6674
name: Update README Catalog Table
6775
entry: python -m src.tools.utils.readme_updater
6876
language: system
6977
pass_filenames: false
70-
files: ^artifacts/.*\.(owl\.ttl|shacl\.ttl|context\.jsonld)$
78+
files: ^artifacts/.*\.(owl\.ttl|shacl\.ttl|context\.jsonld|schema\.json)$
7179
stages: [pre-commit]
7280

7381
- repo: https://github.com/pre-commit/pre-commit-hooks

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ endef
6161
GEN_OWL := $(VENV_BIN)/gen-owl
6262
GEN_SHACL := $(VENV_BIN)/gen-shacl
6363
GEN_JSONLD_CONTEXT := $(VENV_BIN)/gen-jsonld-context
64+
GEN_JSON_SCHEMA := $(VENV_BIN)/gen-json-schema
6465

6566
# LinkML domains — add new domains here
6667
LINKML_DOMAINS := openlabel-v2
@@ -211,6 +212,10 @@ _generate_default:
211212
"$(GEN_OWL)" --deterministic --normalize-prefixes --xsd-anyuri-as-iri --no-metadata --default-language en --ontology-uri-suffix "" linkml/$$domain/$$domain.yaml 2>/dev/null | tr -d '\r' | sed -e '$${' -e '/^$$/d' -e '}' > artifacts/$$domain/$$domain.owl.ttl; \
212213
"$(GEN_SHACL)" --deterministic --normalize-prefixes --no-metadata --default-language en --message-template "{name} ({class}): {description} {comments}" linkml/$$domain/$$domain.yaml 2>/dev/null | tr -d '\r' | sed -e '$${' -e '/^$$/d' -e '}' > artifacts/$$domain/$$domain.shacl.ttl; \
213214
"$(GEN_JSONLD_CONTEXT)" --deterministic --normalize-prefixes --no-metadata --exclude-external-imports --xsd-anyuri-as-iri linkml/$$domain/$$domain.yaml 2>/dev/null | tr -d '\r' | sed -e '$${' -e '/^$$/d' -e '}' > artifacts/$$domain/$$domain.context.jsonld; \
215+
if [ -f linkml/$$domain/$$domain-schema.yaml ]; then \
216+
echo " Generating JSON Schema for $$domain..."; \
217+
"$(GEN_JSON_SCHEMA)" linkml/$$domain/$$domain-schema.yaml 2>/dev/null | tr -d '\r' > artifacts/$$domain/$$domain.schema.json; \
218+
fi; \
214219
done
215220
@echo "[OK] Artifacts generated"
216221

@@ -408,7 +413,7 @@ _help_general:
408413
@echo " make format - Format code with ruff"
409414
@echo ""
410415
@echo "LinkML:"
411-
@echo " make generate - Generate OWL/SHACL/context from all OMB LinkML schemas"
416+
@echo " make generate - Generate OWL/SHACL/context/JSON Schema from all OMB LinkML schemas"
412417
@echo " make generate DOMAIN=openlabel-v2 - Generate for a specific OMB domain"
413418
@echo " make generate gx - Build and sync Gaia-X artifacts from service-characteristics"
414419
@echo " make generate help - Show generate subcommands"
@@ -434,7 +439,7 @@ _help_install:
434439

435440
_help_generate:
436441
@echo "Generate subcommands:"
437-
@echo " make generate - Generate OWL/SHACL/context from all OMB LinkML schemas"
442+
@echo " make generate - Generate OWL/SHACL/context/JSON Schema from all OMB LinkML schemas"
438443
@echo " make generate DOMAIN=openlabel-v2 - Generate for a specific OMB domain"
439444
@echo " make generate gx - Build and sync Gaia-X artifacts from service-characteristics"
440445
@echo " make generate gx GX_REF=25.12 - Check out a specific Gaia-X ref before generating"

0 commit comments

Comments
 (0)