Skip to main content

Universal schema migration engine (Python SDK)

Project description

panproto

PyPI Python MIT

Universal schema migration engine for Python. Wraps the panproto WASM module via MessagePack IPC, with automatic lens generation via protolenses.

Requires Python 3.13+.

Installation

pip install panproto

Quick start

from panproto import Panproto

with Panproto.load() as pp:
    atproto = pp.protocol("atproto")
    old_schema = (
        atproto.schema()
        .vertex("post", "record", nsid="app.bsky.feed.post")
        .vertex("post:body", "object")
        .vertex("post:body.text", "string")
        .edge("post", "post:body", "record-schema")
        .edge("post:body", "post:body.text", "prop", name="text")
        .constraint("post:body.text", "maxLength", "3000")
        .build()
    )

    # One-liner data conversion between schema versions
    converted = pp.convert(record, old_schema, new_schema)

    # Auto-generate a lens with full control
    lens = pp.lens(old_schema, new_schema)
    view, complement = lens.get(record)
    restored = lens.put(modified_view, complement)

    # Build a reusable protolens chain (schema-independent)
    chain = pp.protolens_chain(old_schema, new_schema)
    result = chain.apply(record)

    # Diff two schemas
    diff = pp.diff(old_schema, new_schema)

API

Class Description
Panproto Main entry point; call Panproto.load() to initialize
Panproto.convert() One-liner data conversion between two schemas via auto-generated protolens
Panproto.lens() Auto-generate a lens between two schemas
Panproto.protolens_chain() Build a reusable, schema-independent protolens chain
Protocol Protocol handle with schema builder factory
SchemaBuilder / BuiltSchema Fluent schema construction
MigrationBuilder / CompiledMigration Migration construction and compilation
Instance Instance wrapper with JSON conversion and validation
IoRegistry Protocol-aware parse/emit for all 76 formats
Repository Schematic version control (init, commit, branch, merge)
LensHandle Lens with get, put, and auto_generate() for automatic lens derivation
ProtolensChainHandle Reusable, schema-independent protolens chain with apply and instantiate
ProtolensChainHandle.fuse() Fuse chain into single step
ProtolensChainHandle.check_applicability() Check applicability with reasons
ProtolensChainHandle.lift() Lift along theory morphism
ProtolensChainHandle.from_json() Deserialize from JSON
SymmetricLensHandle Symmetric (bidirectional) lens for two-way synchronization
DataSetHandle Handle to versioned data set with migrate/staleness methods
Panproto.data_set() Store and track a data set
Panproto.migrate_data() Migrate data between schemas
FullDiffReport / CompatReport Breaking change analysis
TheoryHandle / TheoryBuilder GAT theory construction

Documentation

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.9.0.tar.gz (47.8 kB view details)

Uploaded Source

Built Distribution

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

panproto-0.9.0-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for panproto-0.9.0.tar.gz
Algorithm Hash digest
SHA256 ab5b0fdbc7c39617ba2fea033249822bbe38fb70da279f62120a41816e3aa849
MD5 551217de93a931bcb01b3302b0358fd1
BLAKE2b-256 fc0d032748342ca427896c9a162e561b498279408a67e796b88ca0c9926086db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panproto-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 59.7 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.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93edbdb7e504add776b8abcd9aa5c273af5d140b330960efa7399ef15d9d9a64
MD5 39ec6aaf1e6f222c403e4500fa71b9cd
BLAKE2b-256 237a5f6ea564000411762c2546dc2cbb454a40a9a955e3de19ae4850bcd302e5

See more details on using hashes here.

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