Skip to main content

SCAI state management library for database migrations

Project description

scai-state

SCAI state management library for database migrations.

Installation

pip install scai-state

Usage

from scai_state import CodeUnitRegistry
from scai_state.types import CodeUnit, SourceMetadata, TargetMetadata, ObjectType, Kind

# Initialize a new registry
registry = CodeUnitRegistry.init("/path/to/repo")

# Or open an existing registry
registry = CodeUnitRegistry.open("/path/to/existing/repo")

# Create a code unit
code_unit = CodeUnit(
    kind=Kind.databaseObject,
    source=SourceMetadata(
        objectType=ObjectType.table,
        database="RETAIL_DB",
        schema="dbo",
        name="Customer",
    ),
    target=TargetMetadata(
        objectType=ObjectType.table,
        database="RETAIL",
        schema="DBO",
        name="CUSTOMER",
    ),
)

# Returns the ID (auto-generated if not provided)
id = registry.create(code_unit)

# Load a code unit
cu = registry.load(id)

# List all code units (with optional filter)
results = registry.list("source.objectType = 'table'")

# Update specific fields
registry.update(id, {"planning.wave": 2})

# Delete a code unit
registry.delete(id)

Testing

Integration tests live in tests/ and cover the full Python -> Rust -> disk -> Rust -> Python round-trip:

Test file What it verifies
test_serialization.py FFI round-trip fidelity for all fields, Pydantic alias handling, extensions empty-map preservation
test_errors.py ScaiError.error_code contract across FFI (1001, 1003)
test_batch.py BatchResult wire format with partial failures (1004)
test_crud.py Full CRUD lifecycle, upsert deep-merge semantics
test_query.py find_by_object partial matching with exclude_unset

Run them from the repo root:

./scripts/run-tests.sh python

Or directly:

cd crates/scai-state-python
maturin develop
pytest tests/ -v

Building from Source

This package requires Rust and maturin to build:

# Install maturin
pip install maturin

# Build and install in development mode
cd crates/scai-state-python
maturin develop

License

Apache-2.0

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

snowflake_code_unit_registry-0.8.59.tar.gz (203.4 kB view details)

Uploaded Source

Built Distributions

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

snowflake_code_unit_registry-0.8.59-cp39-abi3-win_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.59-cp39-abi3-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.59-cp39-abi3-manylinux_2_38_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ x86-64

snowflake_code_unit_registry-0.8.59-cp39-abi3-manylinux_2_38_aarch64.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.59-cp39-abi3-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.8.59-cp39-abi3-macosx_10_12_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file snowflake_code_unit_registry-0.8.59.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59.tar.gz
Algorithm Hash digest
SHA256 78f89da8bbbbe95d0410a639e17614e8f984cc97008fe2f862f3aa36d1f7736d
MD5 2b19384e526965046eb987b3a9840eda
BLAKE2b-256 f3ffca43f6480f491878af32aaace4b1c37195cfba3f5d629ca5fc0bf1f06f12

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.8.59-cp39-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 61d2ff37c0129d2be8c195636d39359abdbaab7102fc43dfc74efbe2ca9dbc80
MD5 062146923eb83198432ea9625a441ec3
BLAKE2b-256 7f69941a7f8a0003e8f0888a37f4abebc179949f8ea7730fe851b0f1394f976a

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.8.59-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c574c03a1f8efd55f345c0ec25c68d0f12345481e13c25af94c45b8f317a30d4
MD5 f829fa4ac7b4e127e4a7613544b4b984
BLAKE2b-256 c72d32837cc08e1c46f65f5ff1ea65b6bd2e171bb207aa9dcb24c9cddfd3a627

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.8.59-cp39-abi3-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 c12273efabde3bd5ae42120e43429f42d874bab927ba001f03205fd4ca424fc7
MD5 9560cbf74bcb0711d00535173c8edccd
BLAKE2b-256 8869a75089133d5c254842103fe982e50570809371d32172300608d0f2a8ab6e

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.8.59-cp39-abi3-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 f0d985265dabbfbc586bd50cc07782e86028fba074fde88e40663ef0007c33ad
MD5 f14cd6ceedcc49ea6a18087f81d5cd56
BLAKE2b-256 affd906e70bfa7e24791b2914382cc72e04a1ccac0aa879fa0ba33b87caf54ef

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.8.59-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93d0971f3511fdc2a02b79adc2aa3628dbf03ceba01e22c69c34c33693712378
MD5 b1d2b1d844505b459452bec1c465fa33
BLAKE2b-256 f02316c82d79e6c5d5dac4c90f38af4875daca7fd4cea7d77e3adb4d4a96217d

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.8.59-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.59-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 956e13c105898c44e6d09fa7a396a4140d49e60778ad803037679bd83d6e5a08
MD5 395d95a10f754d3ecea56b8969efac20
BLAKE2b-256 225737bb44e0ee97d32add5625cdc2e2b76a16df5d582d0fa2cb453fcf1434ce

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