Skip to main content

gemara-python

What This Is

gemara-python provides generated Pydantic v2 models for Gemara v1 documents. Use it to load, validate, and work with Gemara JSON or YAML in Python.

How to Install

pip install gemara-python

Getting Started

from gemara.v1 import ControlCatalog, Lexicon, load

doc = load("catalog.yaml")  # dispatches on metadata.type

match doc:
    case ControlCatalog():
        print(len(doc.controls or []))
    case Lexicon():
        print(len(doc.terms))

load accepts a file path or open file. Use loads for JSON or YAML text and bytes. Both return the model selected by metadata.type.

When the expected document type is already known, load it directly from the model to receive that concrete type without dispatching:

from gemara.v1 import GuidanceCatalog

guidance = GuidanceCatalog.from_file("guidance.yaml")

from_file accepts a file path or open file. from_text accepts JSON or YAML text and bytes. Both validate the input as the selected document model.

Reference

  • DOCUMENT_TYPES contains the supported document models.
  • GemaraDocument is the union type returned by load and loads.
  • Catalog documents share the Catalog base and log documents share Log, so isinstance(doc, Catalog) or isinstance(doc, Log) narrows a dispatched document to its category.
  • SCHEMA_VERSION is the Gemara release used to generate the models
  • __version__ is the installed gemara-python distribution version.
  • Invalid input raises GemaraError, UnknownDocumentTypeError, or pydantic.ValidationError.
  • load and from_file also propagate filesystem and stream I/O exceptions.

Compatibility

Changes within Gemara v1 are additive, so these models read every v1.x document, including ones written against a minor newer than SCHEMA_VERSION. Properties they do not recognize are accepted and dropped rather than carried onto the model.

Known limitations

These models are a structural validator, not a full Gemara validator. CUE enforces cross-field semantics — uniqueness via hidden _unique* fields, referential integrity via comprehensions -- that cannot survive projection into JSON Schema.

What still applies: required fields, enums, patterns, and length bounds. If you need full validation, run cue vet against the Gemara schemas.

License

Apache-2.0.

Release files for gemara-python 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gemara-python 0.1.0
File Size Uploaded
gemara_python-0.1.0.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gemara-python 0.1.0
File Interpreter ABI Platform
gemara_python-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.1 kB

Release files / gemara_python-0.1.0.tar.gz

Download URL gemara_python-0.1.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
75e18a9f31c4480baebc9c5bdee5b02256ab399c1979fc0a9d9e5133e987fea3
BLAKE2b-256 checksum
How to use checksums
1119cb88a180d89272184dd1f78dd0b2c83bc0c565b7f22f8ad3b7a29f07743f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / gemara_python-0.1.0-py3-none-any.whl

Download URL gemara_python-0.1.0-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48512374a664af41ba98056d4554bf494581836230fb37b9f8a99b9063bf4634
BLAKE2b-256 checksum
How to use checksums
3ef2efa1c8d9f00ec88e7f2f714e5e345e00b72e20dd2795ff80de0d6202afc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page