Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ src := "src"
dest := "project"
pymodel := src / schema_name / "datamodel"
source_schema_path := source_schema_dir / schema_name + ".yaml"
clinical_schema_name := schema_name + "_clinical"
clinical_schema_path := source_schema_dir / clinical_schema_name + ".yaml"
docdir := "docs/elements" # Directory for generated documentation
merged_schema_path := "docs/schema" / schema_name + ".yaml"

Expand Down Expand Up @@ -105,13 +107,17 @@ testdoc: gen-doc _serve
gen-python:
uv run gen-project -d {{pymodel}} -I python {{source_schema_path}}
uv run gen-pydantic {{gen_pydantic_args}} {{source_schema_path}} > {{pymodel}}/{{schema_name}}_pydantic.py
uv run gen-python {{clinical_schema_path}} > {{pymodel}}/{{clinical_schema_name}}.py
uv run gen-pydantic {{gen_pydantic_args}} {{clinical_schema_path}} > {{pymodel}}/{{clinical_schema_name}}_pydantic.py

# Generate project files including Python data model
[group('model development')]
gen-project:
uv run gen-project {{config_yaml}} -d {{dest}} {{source_schema_path}}
mv {{dest}}/*.py {{pymodel}}
uv run gen-pydantic {{gen_pydantic_args}} {{source_schema_path}} > {{pymodel}}/{{schema_name}}_pydantic.py
uv run gen-python {{clinical_schema_path}} > {{pymodel}}/{{clinical_schema_name}}.py
uv run gen-pydantic {{gen_pydantic_args}} {{clinical_schema_path}} > {{pymodel}}/{{clinical_schema_name}}_pydantic.py
uv run gen-java {{gen_java_args}} --output-directory {{dest}}/java/ {{source_schema_path}}
@if [ ! ${{gen_owl_args}} ]; then \
mkdir -p {{dest}}/owl && \
Expand Down Expand Up @@ -185,17 +191,40 @@ _test-schema:
_test-python: gen-python
uv run python -m pytest

# Run example tests
_test-examples: _ensure_examples_output
uv run linkml-run-examples \
--input-formats json \
--input-formats yaml \
--output-formats json \
--output-formats yaml \
--counter-example-input-directory tests/data/invalid \
--input-directory tests/data/valid \
--output-directory examples/output \
--schema {{source_schema_path}} > examples/output/README.md
# Validate example data files against the clinical schema
_test-examples:
#!{{shebang}}
import subprocess, sys, pathlib
schema = "{{clinical_schema_path}}"
failed = False
# Valid examples – must pass validation
for f in sorted(pathlib.Path("tests/data/valid").glob("*.yaml")):
cls = f.stem.split("-")[0]
r = subprocess.run(
["uv", "run", "linkml-validate", "-s", schema, "-C", cls, str(f)],
capture_output=True, text=True,
)
if r.returncode != 0:
print(f"FAIL (expected valid): {f}\n{r.stdout}{r.stderr}")
failed = True
else:
print(f"OK (valid): {f}")
# Invalid examples – must fail validation
for f in sorted(pathlib.Path("tests/data/invalid").glob("*.yaml")):
if f.name == ".gitkeep":
continue
cls = f.stem.split("-")[0]
r = subprocess.run(
["uv", "run", "linkml-validate", "-s", schema, "-C", cls, str(f)],
capture_output=True, text=True,
)
if r.returncode == 0:
print(f"FAIL (expected invalid): {f}")
failed = True
else:
print(f"OK (invalid): {f}")
if failed:
sys.exit(1)

# Generate merged model
_gen-yaml:
Expand Down Expand Up @@ -240,10 +269,6 @@ _clean_project:
else:
d.unlink()

_ensure_examples_output: # Ensure a clean examples/output directory exists
-mkdir -p examples/output
-rm -rf examples/output/*.*

# ============== Include project-specific recipes ==============

import "project.justfile"
Loading
Loading