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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+Windows x86-64

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

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.27.0-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.0-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.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.27.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6de994d46f12692ca4158e1e39814ad0bf55f84c38bcc24f2af963dcd4f7bde2
MD5 8d70afea0134a4098b08f07c2c4efec6
BLAKE2b-256 339d217dfc31b6f03051acc61a3cd817aed88759b84390be81052f64901265f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc8748344dd2aa13301c00e4912bc15fbb0124155a6159ba05557bca39f3d247
MD5 8b5537ff4bcc28ebe43fdcf7b9d06e77
BLAKE2b-256 4acf0ee6887b9c23d4dd56e53e7809ccedbaecdd3e901321598674bf4f397547

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: panproto-0.27.0-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.7

File hashes

Hashes for panproto-0.27.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fcd1d86c67421a91698eef4284cb0b52a04a5e380310e7686e05df357cb4a660
MD5 11a8d503ee800c89f2f18b6ddb0f4180
BLAKE2b-256 a427cda2ba5138490a18863b777b1f8a3c18553f9afdf58ce4a71b9025e663bf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.0-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 92033b442ce8cf232a845e9e2fc372222ee33935d5b0179e3c788fc0558e0ad5
MD5 7b44513b11e12f7d3956588f4323657f
BLAKE2b-256 16aa7714d90bdead873734712e28c6d30c659827ef1abc35341f1e23c34931b7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 680ecc1900cf6c790c9378374e662707857a246edf03ea461f42397f91774335
MD5 718515fdfaacd8a60d507285563f696e
BLAKE2b-256 27be88a18885e106c1b24f66074b5e114dc0f4816f2e5806af5dbe75413e04fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1d9f241dcfa6f44e407df03ef4f6c8d6c7a22e836270c599b01ad88a8c6f497c
MD5 824ea72e10c20208a6da86e1a147b3a3
BLAKE2b-256 4f690a90881ecbd7a70a97c76440f7f2fd440f27a468750a6d6ae9b4e7e047fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.27.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4fae0b08fade138dad02b6e2956a44e8eeeabbb89e108bcc3c5b2f340eadb117
MD5 b2cb9ef665908adafc1c219182b70cc3
BLAKE2b-256 0b1829646c6fd0f8cbd39fadf930a56cf36416140a6bab5270872349754f65d3

See more details on using hashes here.

Provenance

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