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.7.0.tar.gz (38.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.7.0-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panproto-0.7.0.tar.gz
  • Upload date:
  • Size: 38.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.7.0.tar.gz
Algorithm Hash digest
SHA256 b275d9001c5973258696aca9f21be038392d8e07aebb160c4e6bb588b9dde4fd
MD5 88e4adb7bc2bcf45cc3a7d05a5ec8e98
BLAKE2b-256 c0494a40f7e8967888a2bd8895762d582d6a4d4cfdec93848df52ac963e724af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panproto-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 49.8 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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a82a6606f84226fe03bd30c6ba4eb8e96ccfeb1d3f5cd090349ff0c319c97f6
MD5 eac1e2f944ee8b0c52df6409bcb9af6c
BLAKE2b-256 cd9e8e95c3fc5238ff7fc0d90f86c06d7314f5308a38cda9bd663752240406a1

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