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.32.tar.gz (185.0 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.32-cp39-abi3-win_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.32-cp39-abi3-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.32-cp39-abi3-manylinux_2_38_x86_64.whl (7.4 MB view details)

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

snowflake_code_unit_registry-0.8.32-cp39-abi3-manylinux_2_38_aarch64.whl (6.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.32-cp39-abi3-macosx_11_0_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.8.32-cp39-abi3-macosx_10_12_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32.tar.gz
Algorithm Hash digest
SHA256 d7fbd90366e3b6c435d52fdb4d631d91fd463884f6c8abeca4dfcfb04e201c69
MD5 2c998f9affadab33272f58d8322a009a
BLAKE2b-256 6cd4f8db7c5f41c96522f8ec4c17f8990f606dccbc1581c5b2ff1bff9de39993

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 038c39a0f43e236dd4a3c7477b1f02f84927b3acca047806a9779a5275e586fe
MD5 8e608e31e56a5b1dc68042fc618087be
BLAKE2b-256 75edd0978b3002f247ef706c14dd33bd5abc21aa7a9e40ae0519e4b05f94beef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 967f20ffc448f15f7d2dd0840f916e32428ddbec5af1a2f293f19d8b19d4eebc
MD5 aa35fe03e9a78f8e773485cb76c2c23e
BLAKE2b-256 d0352ffc6aad3148269ba29b9d121c76c006db1ccd772c9ed8d26a4a67b041f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 230fca334295f7d0a8df88cc090e539e98656476d726b4002b4b378446b53431
MD5 070277cd3e1664f30944f3ce95d1f718
BLAKE2b-256 0243d36b7192f6ea63874410b77bfc114701bc25ddd12aca657adaa653bb42e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 7adfb0f8c88467cf274ca73aec863aa8de674aca8fa418a1e743cd69997ef5ec
MD5 240552f6efbb7446b9d171dc0e06ba61
BLAKE2b-256 e9469748c3bb9466f93de21dc2a24f24b774cb6dcbc9b7c98066bbba4b6b10df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d46ba9a8d175a7f28aefc93eded8ec140c3d34c69d1935d4fa44070c09bbe93c
MD5 4be7d1981b4b26ceaa2954dbd700dc52
BLAKE2b-256 8635534222c29b4a90a21699eab64c79954d0a0cfef22406b710eb81852d7462

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.32-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7bfb39f399e95e386859b3888110c194ffc6d846ef3a1505a226d3afa5f0346a
MD5 229775000acaf2c16d42b99610bdf185
BLAKE2b-256 8a7781bd06e541fbe68100d74f047527b15b8a369f60a312029eba7a17ed3382

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