Skip to main content

Automatic schema migration and version control for 51 schema languages and 248 programming languages

Project description

panproto

PyPI Python MIT

Native Python bindings for panproto. Define schemas, detect breaking changes, and automatically convert data between schema versions. Supports 51 schema languages (OpenAPI, ATProto, Protobuf, JSON Schema, and more) and can parse source code in 248 programming languages via tree-sitter.

Built with PyO3 for direct access to the Rust engine (no WASM, no subprocess). Requires Python 3.13+.

Installation

pip install panproto

Quick start

import panproto as pp

# Build two versions of a schema
builder = pp.SchemaBuilder("atproto")
builder.vertex("post", "record", nsid="app.bsky.feed.post")
builder.vertex("post:body", "object")
builder.vertex("post:body.text", "string")
builder.edge("post", "post:body", "record-schema")
builder.edge("post:body", "post:body.text", "prop", name="text")
builder.constraint("post:body.text", "maxLength", "3000")
old_schema = builder.build()

# ... build new_schema similarly, with renamed fields ...

# Check whether the change is breaking
report = pp.diff_and_classify(old_schema, new_schema, protocol)
print(report.compatible)        # True or False
print(report.report_text())     # human-readable summary

# Auto-generate a bidirectional converter.
# Returns (lens, alignment_quality, coerce_proposals); the last is empty
# unless `stringency="exploratory"` is passed.
lens, quality, coerce_proposals = pp.auto_generate_lens(old_schema, new_schema, protocol)
view, complement = lens.get(instance)
restored = lens.put(view, complement)

# Parse and emit data in any supported format
io = pp.IoRegistry()
schema = io.parse_schema("json-schema", json_schema_str)
output = io.emit_schema("json-schema", schema)

# Version control
repo = pp.VcsRepository.init("/path/to/repo")
repo.add(schema)
repo.commit("add post schema", "your-name")
repo.branch("feature")
repo.merge("feature", "your-name")

API overview

Schema and protocols

Function / Class What it does
list_builtin_protocols() List all 76+ built-in protocol names.
get_builtin_protocol(name) Load a protocol definition by name.
define_protocol(...) Define a custom protocol.
SchemaBuilder(protocol) Build schemas with vertex(), edge(), constraint(), then build().
Schema An immutable schema with vertex, edge, and constraint accessors.
Protocol A schema language definition with edge rules and feature flags.

Breaking change detection

Function / Class What it does
diff_schemas(old, new) Compute a structural diff between two schemas.
diff_and_classify(old, new, protocol) Diff and classify changes as breaking or non-breaking.
SchemaDiff The diff result: added, removed, and changed elements.
CompatReport Compatibility report with details on each breaking change.

Migration and lenses

Function / Class What it does
auto_generate_lens(src, tgt, protocol) Generate a bidirectional converter between two schemas.
Lens A converter with get(instance) (forward) and put(view, complement) (backward).
Complement The data dropped during forward conversion, needed for lossless backward conversion.
MigrationBuilder Build a migration by specifying vertex and edge mappings.
compile_migration(src, tgt, migration) Compile a migration for application.
compose_migrations(m1, m2) Chain two migrations into one.
check_existence(src, tgt, migration, protocol) Validate that a migration is well-formed.

Data I/O

Function / Class What it does
Instance A data record with from_json(), to_json(), and validate().
IoRegistry Parse and emit schemas and data in any of the 76+ supported formats.

Theory engine

Function / Class What it does
create_theory(name, sorts, ops, eqs) Define a custom schema language theory.
Theory A theory with sort, operation, and equation accessors.
colimit_theories(t1, t2, shared) Combine two theories into one.
check_morphism(morphism, domain, codomain) Validate a structure-preserving map between theories.
Model A concrete model of a theory.

Version control

Function / Class What it does
VcsRepository.init(path) Initialize a new panproto repository.
VcsRepository.open(path) Open an existing repository.
repo.add(schema) Stage a schema for commit.
repo.commit(message, author) Create a new commit.
repo.branch(name) Create a branch.
repo.merge(branch, author) Merge a branch into the current one.

Documentation

Full documentation at panproto.dev.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

panproto-0.35.0-cp313-abi3-win_amd64.whl (5.5 MB view details)

Uploaded CPython 3.13+Windows x86-64

panproto-0.35.0-cp313-abi3-manylinux_2_28_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ x86-64

panproto-0.35.0-cp313-abi3-manylinux_2_28_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

panproto-0.35.0-cp313-abi3-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.35.0-cp313-abi3-macosx_10_12_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

File details

Details for the file panproto-0.35.0-cp313-abi3-win_amd64.whl.

File metadata

  • Download URL: panproto-0.35.0-cp313-abi3-win_amd64.whl
  • Upload date:
  • Size: 5.5 MB
  • Tags: CPython 3.13+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for panproto-0.35.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5f3fd9e3e8eef0f40581e026e831c1e85e8dfab3426b91f1ec7fb6c86f850276
MD5 5a259b378daf882e74a32d52d9bc1e17
BLAKE2b-256 9e3f80aab05479ab5a1aefe41b31ae020ebefc5877c95f4ab1063aa5b006591f

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.35.0-cp313-abi3-win_amd64.whl:

Publisher: python-wheels.yml on panproto/panproto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panproto-0.35.0-cp313-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for panproto-0.35.0-cp313-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61bfa8bba49caa91390a62dfd74ea6884e1d7a677048e37d4f4154f718756016
MD5 28d4af0071a4cd6f0c1d0410e30a2a18
BLAKE2b-256 8e2e3c909e36b55809609326446d8ffce2eb9982c9a009b35ec60d9c80b1eef5

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.35.0-cp313-abi3-manylinux_2_28_x86_64.whl:

Publisher: python-wheels.yml on panproto/panproto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panproto-0.35.0-cp313-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.35.0-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5347de3d38fa3a19417a0d389f3a296923f4aa1c56a671cc2671f58c78ac42b6
MD5 707e965ff2f9bc9d763fa85cdc8cb37d
BLAKE2b-256 816de50fdaba58c86f4c6d000620e1ac45218e1a152758a9d2af199237da0855

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.35.0-cp313-abi3-manylinux_2_28_aarch64.whl:

Publisher: python-wheels.yml on panproto/panproto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panproto-0.35.0-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panproto-0.35.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 124632c8facb6ac34a67c9d1a30e09a30b374371abd9abc1be5f105d10a0083a
MD5 1438d9fea2b0f247bb614ab3684099fc
BLAKE2b-256 a6d1f57e6af2256ba5a4613e6b3527f7ff10a777f6b3216e4e79f28ab9f0519f

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.35.0-cp313-abi3-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on panproto/panproto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panproto-0.35.0-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for panproto-0.35.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a3445b5993e55df4eb07065726d85be94fc66e56c9e24eeb15108eeb9dbbe7b4
MD5 a82d416b2a59a0ed27cb5a2eef67b047
BLAKE2b-256 be4ede94473d5f6c45c10313e53f3723477c063e6661a0eb471a03c9025113a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.35.0-cp313-abi3-macosx_10_12_x86_64.whl:

Publisher: python-wheels.yml on panproto/panproto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page