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.55.tar.gz (203.2 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.55-cp39-abi3-win_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.55-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.55-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.55-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.55-cp39-abi3-macosx_10_12_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55.tar.gz
Algorithm Hash digest
SHA256 e01fa1413245ebd7a6654b1e762237a3b2f858e221a64315c64422ebfaecdbf3
MD5 68ac7a03754ff37917204ebb3ae6daa2
BLAKE2b-256 dfb53d077ed0f064e98f0cdc27f44bec9ecd8a8fe202cde49ace514945bdb483

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 60758a5f8f511ac512a8d8c2e30384be3b0e9336340649b509b6e9daf6b65529
MD5 05c0c2eec703be39507c308822dd60cb
BLAKE2b-256 21319e15fa806b0456b23b443db8fcef7307db8ccb0612403fa5059ae50e317e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 87eb6493f409d110552364672ed967bc5e41b469f0c2f7b3ee4f9fa44f655f09
MD5 9e7006f6c395a1aa8371b4b565330ffc
BLAKE2b-256 5893106616acb143a1d01f9faf56d4c7843c3847c36841e5ec002e9d309306e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 cf1938dbf02cb4baa1e527567c55cb62293c1202f3ac21a6f57ead6681e3a1d2
MD5 1477d1fc141e836e8683a536212e4a61
BLAKE2b-256 b694354c44f614e2bd700e39abf892218b09d1ed0af7061e52acef51962a44d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 e539b4005f94efe4768ede603d4fb17bdcea4eb0fbd51a1d866ad8f59209904e
MD5 3268903f84fd67e2cace2ef00a631030
BLAKE2b-256 f8006dfe201cf8de7934c5f086d5931db964e524fb6cc9ff1e010397dd26471a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2bcfeb446c515687e446bd91dbf3da2043c14b686cb80d91256bc5bad2f5eb03
MD5 af55574439dd1b7af8466905bc464a11
BLAKE2b-256 232f4508c022f216ef1aa5d2f19172ff9e8ff1ef1a8464348beb07730652c292

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.55-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9429e185cadc0082992f1a09bcd63d9ff06db3ef9f453edf2e68948bbc3cfe7f
MD5 1d14392194bbef2855912ba413cbe830
BLAKE2b-256 f443c143a3a12c23c8100b2158efe38442a0e0f1169c929b119ed4bdc18f6612

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