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

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.47-cp39-abi3-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.47-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.47-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.47-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.47-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.47.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47.tar.gz
Algorithm Hash digest
SHA256 fcc2cfbd7016ad628ba96edd5908f3b625e5e2ec6f0522ff51b050fa3cd90a3b
MD5 e9a9f5faff4a121e02f49731a2f7588f
BLAKE2b-256 74ae36a4fd42dc32e1b5a15b7a917062e9f8a204358db621e751aede10db9bcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 7bcc9deda282da6fd7ce35a854ba1357f6e6eb74912117f4c30de8544327204f
MD5 233b7736e63bb89c9f4bc11d717a7cd2
BLAKE2b-256 c46d159a1f15533859f1552ae37b44b76ead5b219543269afd81ec28bb32d078

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 20ffa171a2dd79702b7b30a9de0dd7d980d6ec8ba00045f71f89e9f01b5f57d3
MD5 b9878e12a5b092dca0de9b8e25bbd1d8
BLAKE2b-256 e8f886063fe0bf22d3295f43ae3804549fe164691d70c5d800b70ca3d717c378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 bbe71f49c963464a805cba733639bab745545731dd92c774cd65726de6e2caba
MD5 a6759d0f0eb2c3f47d9ac49fcfd427d1
BLAKE2b-256 2484907fdc587d4f46bf4c439895881778c4feb6d27dfeb8b9cc4c15131250bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 9392785be227625300859f5d25c9d71a18137ff3cd7a1b019484c0e3acf061b7
MD5 8fd48ecd101aed7eda9ccd58a61762c8
BLAKE2b-256 3e5d071b833cae2175ccd3136dde983d5e7430f1f26a122ca975e1f073ab3614

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c79fe81b5c6ea53b009183810ee84b058056d74ce749fcc5eaebb01ce7a3217
MD5 5009dc0d145bff677ee12b3d622b516f
BLAKE2b-256 c08761c59249da29b7eba7942d614201b769b9aa4582bd2dfcf5d18d3cbfe909

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.47-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d470abf7ccfa4d4c5fe40c645897527b58c02b7508287c804cb2d4d9740c82da
MD5 1af32abbda66a66abef662e436ade106
BLAKE2b-256 577e98c68992e929f50a2987526c9714bebc85219e02c0ed0b7fd633da239d26

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