Skip to main content

pyverge

Schema evolution and migrations for versioned data models. Version your models, define migrations between versions, and converge payloads to a target schema at runtime.

The engine is provider-agnostic: it works on plain dicts and only touches a model library through the ModelAdapter seam. Pydantic and JSON Schema adapters ship today; adapters for other providers (dataclasses, attrs, marshmallow, MessagePack, etc.) plug in the same way.

Installation

# Core library (versioned registry, migration engine, diffing)
pip install git+https://github.com/JoHa-HQ/pyverge.git

# With CLI (init, validate, migrate, diff, export commands)
pip install "git+https://github.com/JoHa-HQ/pyverge.git#egg=pyverge[cli]"

Development dependencies are managed as a dependency group; install them with uv sync --group dev (or hatch/your tool's equivalent).

Quick Start

from typing import Literal

import semver
from pydantic import BaseModel

from pyverge.migration import (
    MigrationSettings,
    ModelManager,
    PydanticModelAdapter,
)

# A manager binds a version strategy to an adapter and settings.
UserManager = ModelManager[semver.Version].scoped(
    PydanticModelAdapter(),
    settings=MigrationSettings(),
)


# Register versioned models. Version and kind are read from the class itself.
@UserManager.model()
class UserV1(BaseModel):
    kind: Literal["User"] = "User"
    version: Literal["1.0.0"] = "1.0.0"
    name: str
    email: str


@UserManager.model()
class UserV2(BaseModel):
    kind: Literal["User"] = "User"
    version: Literal["2.0.0"] = "2.0.0"
    name: str
    email: str
    age: int | None = None


# Register a migration between two versions.
@UserManager.migration("User", "1.0.0", "2.0.0")
def add_age(data: dict) -> dict:
    return {**data, "age": None}


manager = UserManager()

# Migrate data — converges every versioned entry to the configured target.
migrated = manager.migrate(
    {"kind": "User", "version": "1.0.0", "name": "Alice", "email": "a@b.com"}
)
# -> {"kind": "User", "version": "2.0.0", "name": "Alice", "email": "a@b.com", "age": None}

CLI

# Requires: pip install "pyverge[cli]"

pyverge init          # Bootstrap a new project
pyverge validate      # Validate data against a schema version
pyverge migrate       # Migrate data between versions
pyverge diff          # Show differences between versions
pyverge export        # Export JSON Schema definitions
pyverge info          # List registered models and versions
pyverge managers      # List available managers from configuration

Configuration lives in a pyverge.toml (or [tool.pyverge] in pyproject.toml), pointing at the module that defines your manager.

Features

  • Versioned model registry — decorator-based registration with semver or ISO date versioning
  • Meta versions — register a version by (kind, version) alone, with no concrete model, for patch-delta chains against a single latest model
  • Provider adapters — pluggable ModelAdapter; Pydantic and JSON Schema ship today, other providers (dataclasses, attrs, marshmallow, MessagePack) plug in the same way
  • Declarative migrations — express a migration as an RFC 6902 JSON Patch op list (plus set_default/coerce/map/split), compiled into a MigrationFunc via JsonPatchMigration
  • Convergent migration engine — graph-driven, with automatic migration of nested versioned entries
  • Target policies — converge to latest, earliest, a pinned version, or per-kind overrides
  • Executors — sequential or level-parallel batch convergence
  • Model diffing — breaking-change detection with JSON Patch rendering
  • Migration hooks — observability via before/after/error callbacks, plus an OpenTelemetry hook

Documentation

Plan

Items intentionally out of scope for this documentation pass, tracked here for follow-up:

  • CLI/manager facade alignmentModelManager now exposes get, get_latest, and list_versions. The CLI still expects validate_data, diff, list_models, dump_schemas, and migrate(data, schema, from_version, to_version) before those commands work end-to-end.
  • Additional model providers — adapters for dataclasses, attrs, marshmallow, and MessagePack
  • Real-source integrationsshowcases/ projects wiring for document storage (converge on read), Kafka consumers, RabbitMQ/streams workers, and MQTT/IoT gateways on the high-level ModelManager API, with thin adapters around real drivers (motor, confluent-kafka, aio-pika, paho-mqtt). The transport glue is not shipped yet.
  • API reference — an auto-generated API reference page will be restored once the SDK surface is stable.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyverge-0.5.0.tar.gz (218.8 kB view details)

Uploaded Source

Built Distribution

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

pyverge-0.5.0-py3-none-any.whl (61.1 kB view details)

Uploaded Python 3

File details

Details for the file pyverge-0.5.0.tar.gz.

File metadata

  • Download URL: pyverge-0.5.0.tar.gz
  • Upload date:
  • Size: 218.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyverge-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a1db146cefd5e8a4e8cb46bb980eb5e916e7cb05feb76bd5960a8cde20f7e3d0
MD5 a6217f0f096dfc7bd6b2a040d4bc6702
BLAKE2b-256 c25bd4a0a907e330d5e7b38b57f46896e90fa7d803834f2601e47bad2a95ef75

See more details on using hashes here.

File details

Details for the file pyverge-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pyverge-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 61.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyverge-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7852de846e59f02232246d0c5be38d5a2dc03060ccf95dd63bcd2b1b697a7eff
MD5 2faecae396671f4c02cb0edb23b1ca48
BLAKE2b-256 ef5c42f4871dd169fb729b41b70f6e7ec593dcb0cd5eaeac6622064b4a6d7a02

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page