Skip to main content

Schematic version control with panproto (Python SDK)

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 Distribution

panproto-0.22.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

panproto-0.22.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

panproto-0.22.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (6.1 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

panproto-0.22.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (6.1 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

panproto-0.22.0-cp313-abi3-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.13+Windows x86-64

panproto-0.22.0-cp313-abi3-manylinux_2_28_aarch64.whl (6.1 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

panproto-0.22.0-cp313-abi3-macosx_11_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

panproto-0.22.0-cp313-abi3-macosx_10_12_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

panproto-0.22.0-cp311-cp311-manylinux_2_28_x86_64.whl (6.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

File details

Details for the file panproto-0.22.0.tar.gz.

File metadata

  • Download URL: panproto-0.22.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for panproto-0.22.0.tar.gz
Algorithm Hash digest
SHA256 8c9a96b4fb9f7477d13b8e484d8911e89efc00cf7869531adf8964e18398fe04
MD5 72a0609111669fb997d688c121a0316e
BLAKE2b-256 39ed2c743b8d4ea20f83e300d83c6fcf868fcded9a3a6e2c46deba6e773f5f03

See more details on using hashes here.

File details

Details for the file panproto-0.22.0-py3-none-any.whl.

File metadata

  • Download URL: panproto-0.22.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for panproto-0.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0231353a76a5e213609a01ff58e3ee53bf1f65123bba23244e3c5b798847012b
MD5 2702b97dfc5e08d9db39d8123e34cd0d
BLAKE2b-256 6816635bc55608414a9cd25c0b76dd356e85b77a1f5c2f95bbb707110c7b539a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panproto-0.22.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f272ee6da030525482d06d29846ace665fa81ae098acfa86965c339b08a9ee19
MD5 184c0668fe4b292e5c5eaa4675c6d80e
BLAKE2b-256 abc21927d6a3b765b31840e06b1826734fa2580bf19a02866015c3fd8208d3e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.22.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ad78d9c52b35cdd82c63800c362c832ec7e359ef84c3ea94670b73b382d254a2
MD5 9e18c4622d7bfd9e4a6adfd56efa6364
BLAKE2b-256 0178c8865c54782cda036978d6c2b3939359c666e500d33e31f5e6474106367d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: panproto-0.22.0-cp313-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.5 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.22.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6904221a8235bd4863bb93acab4f46a4a0c59b23c3863fe77c9282f425841e5c
MD5 948dc2515da32c11b2024c93a1304fce
BLAKE2b-256 a7d58715541b2b2f4e88edac955f09f23e32b089b51207a607fa718f61a5a0a0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.22.0-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8f9025c9f6aeeeb0de1ce080dbad13f5bfd8b8355bb87ef73e3f4d570c022940
MD5 0156bc5edf5102b19c4931e4583c7772
BLAKE2b-256 3df6a247305e07b77bc6eb84b9dbfa6e2a83d6e8a5641dbc530a63053b7ac481

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.22.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b05530e1fa833a2f7d4e495b8317b17a477a06628e05fd8c98a4922e5167e9bf
MD5 4bf36fef581f7082ffd023ec3938d16a
BLAKE2b-256 1b11a1a24ff858620ed9ff05755a93b1c54b0ad58da45bbc7a8fbad0c56c22fb

See more details on using hashes here.

File details

Details for the file panproto-0.22.0-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for panproto-0.22.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0d75b90db0d0fde696070986eabf70203083f2880795843ad5f5c846f56eb5f3
MD5 294b73c143965ac86c7d16dc1ed70c73
BLAKE2b-256 9d2699723e4718d148e0fac0ac179edae2431d66018146a3e29576c4ac7cbd5c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for panproto-0.22.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aced64334af864bb53a77f11f9e5eff5e5b87acc8166b203f954a7822cb4015c
MD5 cb32a3f97683d6981b3e1af8b3a74218
BLAKE2b-256 1b1bf210b590074d5691304229d233417b645d207ccc30c4fc9b267188de5ef0

See more details on using hashes here.

Provenance

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