Skip to main content

Schema migration engine grounded in generalized algebraic theories

Project description

panproto

PyPI Python MIT

Native Python bindings for panproto, a schema migration engine grounded in generalized algebraic theories. Built with PyO3 for zero-overhead access to the Rust core.

Requires Python 3.13+.

Installation

pip install panproto

Quick start

import panproto as pp

# List all 76+ built-in protocols
protocols = pp.list_builtin_protocols()

# Build a schema using the fluent builder
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()

# Auto-generate a lens between two schema versions
lens = pp.auto_generate_lens(old_schema, new_schema, protocol)
view, complement = lens.get(instance)
restored = lens.put(view, complement)

# Diff two schemas and classify changes
diff = pp.diff_schemas(old_schema, new_schema)
report = pp.diff_and_classify(old_schema, new_schema, protocol)

# Build and compile migrations
mig_builder = pp.MigrationBuilder()
mig_builder.map_vertex("post:body.text", "post:body.content")
migration = mig_builder.build()
compiled = pp.compile_migration(old_schema, new_schema, migration)

# Parse and emit data across protocols
io = pp.IoRegistry()
schema = io.parse_schema("json-schema", json_schema_str)
output = io.emit_schema("json-schema", schema)

# GAT operations
theory = pp.create_theory("MyTheory", sorts, operations, equations)
colimit = pp.colimit_theories(theory_a, theory_b, shared)

# Schematic version control
repo = pp.VcsRepository.init("/path/to/repo")
repo.add(schema)
repo.commit("add post schema", "author")

API overview

Schema and protocols

Function / Class Description
list_builtin_protocols() List all 76+ built-in protocol names
get_builtin_protocol(name) Get a protocol definition by name
define_protocol(...) Define a custom protocol
SchemaBuilder(protocol) Fluent schema construction (vertex, edge, constraint, hyper_edge)
Schema Immutable schema with vertex/edge/constraint access
Protocol Protocol definition with edge rules and feature flags

Migration and lenses

Function / Class Description
auto_generate_lens(src, tgt, protocol) Auto-generate a bidirectional lens between schemas
Lens Lens with get(instance) and put(view, complement)
Complement Data discarded during get, needed by put
MigrationBuilder Build migrations with vertex/edge mappings
compile_migration(src, tgt, migration) Compile a migration for application
compose_migrations(m1, m2) Compose two migrations sequentially
check_existence(src, tgt, migration, protocol) Validate migration existence conditions

Breaking change detection

Function / Class Description
diff_schemas(old, new) Structural diff between two schemas
diff_and_classify(old, new, protocol) Diff with breaking/non-breaking classification
SchemaDiff Diff result with added/removed/changed elements
CompatReport Compatibility report with breaking change details

Instance I/O

Function / Class Description
Instance W-type instance with from_json, to_json, validate
IoRegistry Parse/emit schemas and instances across all protocols

GAT engine

Function / Class Description
create_theory(name, sorts, ops, eqs) Create a GAT theory
Theory Theory with sort/operation/equation access
colimit_theories(t1, t2, shared) Compute theory pushout
check_morphism(morphism, domain, codomain) Verify a theory morphism
Model Model of a theory with carrier sets

Version control

Function / Class Description
VcsRepository.init(path) Initialize a panproto repository
VcsRepository.open(path) Open an existing repository
repo.add(schema) Stage a schema
repo.commit(message, author) Create a commit
repo.branch(name) Create a branch
repo.merge(branch, author) Merge a branch

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.27.2-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (6.3 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

panproto-0.27.2-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (6.3 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

panproto-0.27.2-cp313-abi3-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.13+Windows x86-64

panproto-0.27.2-cp313-abi3-manylinux_2_28_aarch64.whl (6.3 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

panproto-0.27.2-cp313-abi3-macosx_11_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.27.2-cp313-abi3-macosx_10_12_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

panproto-0.27.2-cp311-cp311-manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

File details

Details for the file panproto-0.27.2-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.27.2-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ab2e115d295a2b1aea1162fdcdc29892b3cb4e161264f7b1802530ddd084d645
MD5 5edf3f6d4b02fb6273e4b416780dda72
BLAKE2b-256 5f1ac68b9bbd56e6f5a78c4693d4b25a85aca86a06eb14545153ac994285832d

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-pp310-pypy310_pp73-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.27.2-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.27.2-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6c78feda888abb40d5583ef613baae42f221294dd6cd5e425bec9d53995754dd
MD5 f1173f215ef815ab764b2b52141bb9f0
BLAKE2b-256 b88159abf557768ee7645a123bb46d9c0dc3bab52fc87199283b1a8e35222769

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-pp39-pypy39_pp73-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.27.2-cp313-abi3-win_amd64.whl.

File metadata

  • Download URL: panproto-0.27.2-cp313-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.7 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.27.2-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0620c09f4c28ed9d12e72be21944a35ff5facb96f6eafa2ccb7efcd48b683e48
MD5 a036bf89ba20f76e8dc83329a51234ae
BLAKE2b-256 293ba5c00d8240d20e6d566e7094272b64128b33fb149fea853525455eb0690f

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-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.27.2-cp313-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.27.2-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 019eed82d8ae526990cb6148f0ec4703d5c089ccc79d3a7c4cba61915468d479
MD5 a9c15612abcff3a84207151bf8999e5e
BLAKE2b-256 e2b04ccce4338f194c48f1b02e683de7b937a6725170380215db915b48005ff6

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-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.27.2-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panproto-0.27.2-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec68b0415746c6150d23869746f23a0fbcc0e739476774fc92cfd477ce70ca9b
MD5 3e4de874362734bfeb9586c85ccf7860
BLAKE2b-256 9892b9ac351dc2f7965570a934e4c3c6dcf4c5ab41a4c0f463ed4ed4b6e270c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-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.27.2-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for panproto-0.27.2-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 95d355ca71cde7c4c36f1041480d9cf6dfa8eb72ada2d7949421ef35061f51b0
MD5 5f8dd548219af0dc2fd68f98f1613b99
BLAKE2b-256 7fe3b15b85878d9cad83f79f42dcc60e697d9458abbea0c54f6ee4b8a79bbc44

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-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.

File details

Details for the file panproto-0.27.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for panproto-0.27.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d953dfbf681c6ac9748acad8bd75ccf0588455824bac1cbecf4ee52c5d291872
MD5 a4d3b2014d38d6e722df6170b8b28e68
BLAKE2b-256 bda4596469e011f4d30ea4b879d5b035472a84016b1c04d69381a8b49f31cb57

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.27.2-cp311-cp311-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.

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