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.7.15.tar.gz (140.6 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.7.15-cp39-abi3-win_arm64.whl (6.6 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.7.15-cp39-abi3-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.7.15-cp39-abi3-manylinux_2_38_x86_64.whl (7.2 MB view details)

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

snowflake_code_unit_registry-0.7.15-cp39-abi3-manylinux_2_38_aarch64.whl (6.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.7.15-cp39-abi3-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.7.15-cp39-abi3-macosx_10_12_x86_64.whl (6.9 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15.tar.gz
Algorithm Hash digest
SHA256 4c48c6c96558dc8f5dc3529b7e4e6fa17fb00ff2c1d27494737fb5961208df40
MD5 6ab4eeafe70167542d7eb81e75e46409
BLAKE2b-256 4f6304c6874edde537d4a261921940dd2efe145864260a778b8f76ee3d96ce6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 479c7476b2a68224969d58be6a9413295af8486338b590d9e110ab3756d3fcde
MD5 8bc3c1208b9fa68807930dd59d869633
BLAKE2b-256 11c62e014ce9d4cd16a0012d60ed22ac9c92625785e872a1490b06fdd9344a07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b0e638cb3ba62a280fbe012979508f4248628999e27ecdd9b223514a08dae2f9
MD5 34aa2c1136b3c8434ee40dd2f2b4fbbb
BLAKE2b-256 1b24ccc1d35f1f51cf9be279cee8358467653384034a0ea1584971787f629579

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 91bed05f3622b58b992c7d6976d6ee05fb5cfa3fb3d53058182540b56248670b
MD5 06556f8c4ef216861c90d0a2213481d6
BLAKE2b-256 65b6f378f7c236607bca290c6a518aae4e182e39cd68b6356f8430a6c635533c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 65746c6e592457a946b525539c9ba34c81ca141811c3225921771d33b08cb529
MD5 5e97e61036e1043636b50f8e4f0a4e08
BLAKE2b-256 a6dea90d63aad60e74fb2d2a921c00d09e8fc0f964ff436e5cfece1c245b1229

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 020c03d0e80be4b58f10662a508ea25e58e4148029c928df72296f5013792e22
MD5 802711178df05edd898de4f338ddcb09
BLAKE2b-256 9b401f5fb56ba43982cfa40b35a017938b88d4934661e68036d9bb97f03edda6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.15-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eb9bf6d9f4bcb0adb452ca27b792f2ec39dd11f005ccec50ca2c2bbb6dfbddaa
MD5 59231fe91ea8cb16264acee3e13fe659
BLAKE2b-256 1becd00d95f20fbee6afc20304a30738b68afb6ccbdc4331a48836d45ff98dac

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