inif.schema

JSON Schema export and validation for INIF documents.

Helpers that derive the JSON Schema from the Pydantic models and validate arbitrary dicts against it. The schema documents conventional Token extras (logprob, logit_lens) under $defs.TokenExtras for downstream validators.

Schema

get_schema

Return the inif JSON schema, with conventional Token extras documented.

The Token model permits arbitrary extra fields. TokenExtras is embedded under $defs purely as documentation of well-known names (logprob, logit_lens) so external validators, UIs, and viewers know what to expect. Repeated token labels live in Sample.annotations.

def get_schema() -> dict

write_schema

Write the INIF JSON schema to path.

Parent directories are created if they don’t exist. The file is written with two-space indentation and a trailing newline.

def write_schema(path: str | Path) -> None
path str | Path

Destination file path.

validate

Validate a JSON-shaped dict against the INIF schema.

Runs the same Pydantic validators as :func:load but discards the parsed object. Raises pydantic.ValidationError on failure.

def validate(data: dict) -> None
data dict

The dict to validate.