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.8.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.8.0-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panproto-0.8.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.8.0.tar.gz
Algorithm Hash digest
SHA256 9a8093c4d0147cb40945bbd16cf5758186b2ca635d7d8fc7af5a593d6cfd61d6
MD5 c22a4f6b266aed17b2b0397d4b52701e
BLAKE2b-256 af1a9fbb3d1867fad00ce495c3c744eed62462a14224bee2be1c94f8c388d932

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panproto-0.8.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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7340aa9986c891e25191cabb95dda4dbc9b7fef67120d6a1fb8e6e32a0b239e7
MD5 3b45e920e875d32b9e431ef34815e11a
BLAKE2b-256 d544bbac3b485d8e9e087ec17c704cabce171d25356f7fe952712c74be641964

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