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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+Windows x86-64

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

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.25.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.25.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.25.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for panproto-0.25.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9218d6513e8ad70f85018116c4ca3f28073cd392c20a84195536659668490019
MD5 74da5da2dc3b408aab8ab3b8bad6368f
BLAKE2b-256 406983137f6696100c6334fe264072fb3b8e497f6a82d02baa52b42aba357dd4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c195bda79e347bca2d436572297da24d8bd6423748b4982f8104b70528a6d2f8
MD5 3761354296258830487090f4663b48d4
BLAKE2b-256 fb0bc561818a630a66cb07b92a4536259c0601afc91536883a982425fce6d1b9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: panproto-0.25.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.25.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1da212766fc3df0d02cdde9166626210f385054dbf467eeba700b9e76719b949
MD5 789d1e8253e7c9b3d7772e861cab37a6
BLAKE2b-256 bc970bb988ad43f9bb852ab85e62cb6a5fcc523a9928ed8198afc3e010da6f63

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.0-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d41c55276170548c7686c6d89a2d7894a4fe335da880b0baadd84747df794d11
MD5 f9422df77ce5097e61cb66691f22bd30
BLAKE2b-256 df818eab8d6e199f41509f29bedcb51658a6d50f11725d9fc9423e8cf5c18347

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 443c1c33b32250f404b2367eb19381fd43594c16f03ebbbcd8a43a43c94886a7
MD5 77d78944575e765265d94b38dd7a7b6d
BLAKE2b-256 63d936de68b559e48b27320f0a4f9791556413a5b522f41a3f2c9d590b5e2b14

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ab270a8e438ffef527d166ba616375f24e55be7b894eabdbd75eda861b2423de
MD5 7eb60adaff71d7ec145fe0f1a73e81ba
BLAKE2b-256 5573a9c7c8e00a865a0f88375bc67f6bc450532e7000f5e87ce01260c5eeb523

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.25.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f13094b2b88efcc193aa846a692fe86e6f8a758c10b13df720523e52bc39b2e3
MD5 44fc4955a25a165856631f0a6bf0884f
BLAKE2b-256 e25097a3878af9d79234e194fdaadcdd81b4e1047c2c2260050c976e29fbf000

See more details on using hashes here.

Provenance

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