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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+Windows x86-64

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

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.27.1-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.1-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.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.27.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 db3bcd6e9be17a4778de01cff0ce4a4de72a074c28c6247c18d1d620771ffc62
MD5 ef34bc0dab00dcff2959a51210a7d877
BLAKE2b-256 d5a7ac3641f9ac76db512bd36536a139360e21f90a9ab6868c3beb3d95867ab2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 701a9041ef4d4b45750628f8bccbef9cd3210709bf995a96d1623ec20c6dc789
MD5 2b44a77578003755530df8e5049d3a63
BLAKE2b-256 1aa2b385a5a5352b7960ed5f10b20c82e550b8b931d9df69c3028e64843d1fc3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: panproto-0.27.1-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.1-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a6de906ac50705e5229f3da9bfba8212e6b22cf2500417ceb7cbb4dfacb3b3c1
MD5 d49bdf19069d823f68af832c73149866
BLAKE2b-256 3262c4c61f135a669b0a2b17be10ffe1e89cf174d0e0ac209be9face7e84fc39

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.1-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 57a4b6d90727946860af6756c8d21ab68c6ac007aaecfff7c076362521f39756
MD5 e96f56b149e7fc0d2bc5deb16fc2473a
BLAKE2b-256 8cfcabb3975f7dc6a6375efd66c9dba2fd87aad60525d503555a0a59eca1e2ca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.1-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5a32c5c3826cf880e32f94f20922ef51f3b5dcd67ff41c0f617e1e3d766f6bc
MD5 8fd68166238ffebf31303269bd2da8cc
BLAKE2b-256 43f3fdae40edb8d33dcc0cf9ea74b4f3782efdaa1e51d1aa59110ad44774a1d9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.1-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 57ef3a60fd461e9e8f93fd792b6a3067ef95254bcdaf6e75a51b16ff27b34014
MD5 2398ea21c7ab310b49091e5b1b810287
BLAKE2b-256 a0d451030a084d7ad4f4ae6d5cfd3b1bf2c61bd53fd2e9a3d925619715459be4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4b6b60ad32b1250899c518835248ac65602ab00d0bb67474bc139ad6b2e9113
MD5 3c73a84dc465d51ea86368caf77f8319
BLAKE2b-256 d1f4d8f27ab2c748c923f4bdd78afb278e2f1f138c27a1455dab79dabf44b6b9

See more details on using hashes here.

Provenance

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