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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+Windows x86-64

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

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+macOS 11.0+ ARM64

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

Uploaded CPython 3.13+macOS 10.12+ x86-64

panproto-0.24.0-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.24.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.24.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aabb5bc129e60e09356ca8bbcb26b20daccaa5343d8c792f2a9608605bc37f23
MD5 7d5f392ac8dec28b3d5127160c017f11
BLAKE2b-256 a309477e27af525f3601c514634b2992234927451d1ead107be808e19b15ecb8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.24.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6ad86b80046bf1d6247af5d97bd26bd1c012bff190ddcc0e36045921625e5821
MD5 915127690cdbdce49a69549156972df4
BLAKE2b-256 23b0b59d47f5e493455b5a68c90cd5bbcc3d4cf949644f41cda429be2ef4eddb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: panproto-0.24.0-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.24.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 69bb7c536e2edbf390ff908fb7a8c56cd13bc02fef29e59ed967e35d30fa48d3
MD5 c457295e9f8edc90b9dbb5818a1f193a
BLAKE2b-256 015b5a57bb7abfcdf524d6548eaf95fe15ecdd4df0a8321e55fe52dc65054a75

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.24.0-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9e33ef5d1b04b49d689e60150dda843110fcd18790c33183bd492de475a08569
MD5 2864c0c30288e18c6219351fd8a74885
BLAKE2b-256 ee92be8c5639e6206c005af1b664ebf2b62ec2f209297aeed20c6e629c418c56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.24.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b7180322ad5fb4965628890d0d08d0dbb23efa6c4a7a3124865f12962a6e65c
MD5 b1532f5c04efccdf13f9f8dbf9e0f2cc
BLAKE2b-256 8a0279f1d51ee3bc630d9731798a67417915f587c0c36e433022b075495f4c5e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.24.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c5ab098f77a4d74ee3255d09a27e031abc7df3d1f37a75d7e21bcc0d02abd1ec
MD5 17594f0a72b94bf031e6396639d84479
BLAKE2b-256 64e351ca2969abab6f7cafe0969062089b835eb5655b1ed26aec7bb9edeb7552

See more details on using hashes here.

Provenance

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

File details

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

File metadata

File hashes

Hashes for panproto-0.24.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e786df325959a09a9c50c1e8fd9e4c91e6fdedff283957a62b9781104ff01a4
MD5 2f3f54161b528805521557f63add9724
BLAKE2b-256 503e4ea3c227ebd19dd70db2c939d8ce82ca4ac39aaa53bb4838bc0b6ce024bd

See more details on using hashes here.

Provenance

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