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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.9-cp39-abi3-manylinux_2_38_x86_64.whl (7.3 MB view details)

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

snowflake_code_unit_registry-0.8.9-cp39-abi3-manylinux_2_38_aarch64.whl (6.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.9-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.9-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.9.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9.tar.gz
Algorithm Hash digest
SHA256 d5ec03abd5755b4a829836499f22b06e90c0044d421edd5c1b4b97f6e35f1c61
MD5 04fda4188a267b0886b27bc10c780a04
BLAKE2b-256 ce42796c9a8d1f043b010479de0e5cd8907982fd241830d65c22aed7c14e79d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 3fbd306f30125e65104f5ac7c77ec8099eb0cc70b43228c8dfbac376715c510d
MD5 48967acbd14e43aa23b876b74d469c22
BLAKE2b-256 9dc4138de71fd9e9e12ce170213d4d48e4f0f94b9991d6fb4fcbdaf0af26ae8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a585ad8cd10faf0e46148e95eba115acd8244f05fadbbf2b1691bb180cab374
MD5 ceeceb2883f125dd38fb42a325dc2e32
BLAKE2b-256 71ba471de473a9f949093edc2dde4956b5d1a41fb36898dc4ec14760832bd247

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 1c17cb8b090f817f278f97d6cce5dd9434f5576de4989b75268f1d74a9e3b3f0
MD5 a6deb2bb512b85302c9b49fbe89815b4
BLAKE2b-256 7ea07ccbfdd1fba03dad59a2accac9337d8ae77198376bb07a34ecc698fd8b8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 fbda52c0a6e7d52e0710aa856307cac34a5f488f94b1bd9258f313a7c62aeb66
MD5 a487b566abb7844d152c371f61cf5dac
BLAKE2b-256 cd6d6e035f4f978ebef97c8834ef323b2897f2933647e1cceb97c903203f643e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6def0812b0e68a978a9367e5dd1182244e4c372aa841f6e4355f8e99b3aac201
MD5 e77663824fd951e105d5687f15d35875
BLAKE2b-256 b1610cfbd8b55be120b493b1837e409b1db2bcd5912f2ff5216491415436f005

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.9-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a75a2a7304581f137c98b0089933d41bb4c011b6ba5e41c25c171aca3f71f032
MD5 114733900a404b21fabf04476b221bda
BLAKE2b-256 b16f27bcd182cb32facb88e04e9b87b93cd0e9c6b705ee8ceac8bf5d4d579e64

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