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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

panproto-0.25.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (6.2 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

panproto-0.25.1-cp313-abi3-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.13+Windows x86-64

panproto-0.25.1-cp313-abi3-manylinux_2_28_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

panproto-0.25.1-cp313-abi3-macosx_11_0_arm64.whl (5.7 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.25.1-cp313-abi3-macosx_10_12_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

panproto-0.25.1-cp311-cp311-manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

File details

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

File metadata

File hashes

Hashes for panproto-0.25.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 30c1335b163bba6ab25a68592170028c6ae441afb79f99f386ee5e47ff7260e8
MD5 b52853c8c6ef4f82f3eaa44c635989e3
BLAKE2b-256 0a428267e8bdfb73a0564d47bc86e5707414a2c89c805e1b4c104dc16cc67aed

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.25.1-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.25.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.25.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9fc249f3a918be6184ac3104a6ae02c2b97b62980157a65ba4f2ce4341ec4945
MD5 3adb37925d242b6bf8e308d39a52bf7b
BLAKE2b-256 3fe7bb51b89efc548cea3ac02a1b61c8644bda045b1f433d66972d79d38556b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.25.1-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.25.1-cp313-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for panproto-0.25.1-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e089702d9a8b6c9c1cd90ff8c38af5a13ea98ad01c069e3265d2aab789c1fcc4
MD5 e0948f539e84bffe2b381c8ee70582e8
BLAKE2b-256 005e23d36b8db26f2bf71742e4b20d2c2d04ea495b1623ddddd09ef175f507a7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.1-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 56e46a51edaab3b2b9bd7cd0fd135e9c7995697c86ae7f66f6691485a0a120c5
MD5 a44e79ca2e7d1a70bfcba3f2751c4a7d
BLAKE2b-256 52d0e82bcaef9e3ef23b4bb3dab6b4a8e213b366a749288fbc12507bb40b0ca0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.1-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57ea5cf0c3e33f31d08e6cb00cc5687361b2dc59801f379f4b39fa229afceb3c
MD5 2e5ff9cd2852ec38feb4df42a62f8318
BLAKE2b-256 b009f159e51f179ef93d8c14577c3d9f4639eb7b5ae222edb79902093f2bc9f0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.1-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 030b001a121a142eda7bf41a3e246c18f2746432dfad7a70c822ab194a138ca0
MD5 97938c69f0507b31232a67a9a8b06ba3
BLAKE2b-256 e7db623521d545be9a06e6583c7e7a56643640153f7d3152c1f6f728fe220d25

See more details on using hashes here.

Provenance

The following attestation bundles were made for panproto-0.25.1-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.25.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for panproto-0.25.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6fa01b3eabcd9025c6df34cdf73a91da1e8554e23f70f7b18f29568e2a18ab99
MD5 768be4bd42501056b0710ba3f455a0bb
BLAKE2b-256 83a298e1d918e177bd7ebc26a70188e6b508a9932441d413a8da64c5f8bca690

See more details on using hashes here.

Provenance

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