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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.38-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.38-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.38-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.38-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.38.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38.tar.gz
Algorithm Hash digest
SHA256 eb3078f07074d3650c31684975ac5d1ba6a67aac05f84b12c325425203db90cd
MD5 71da3b55881f22b8c6af64ad0e68caaa
BLAKE2b-256 df019dbc9163ab35d738b477bc9b785f77b4ead3d94a7c5e5f99da0e757395c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 c4128634ca2ddf9f25998b5e098be4181f16cdcbcb74942d9dcaba7049c4fe42
MD5 2ee705d7f31a514cb18b12f4d78c794c
BLAKE2b-256 887de8abc7d9614ad732e5be1ec84e8eafbbbff0ac11c2f2afe7fee09ce543e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dc103b18edb1825d575dea2139edbb52d0324add0c13507ef9baa8a7db43c2fa
MD5 9b8d5f1f76d8874eed004c8c76830ff2
BLAKE2b-256 0ea805543f48ad85ff19ed376d6ba9dc1801a49f33819be44aa3eab562f01ee8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 afe46b3316d9008288eceae616d91061a064973bb8618f13505edd93f7629abd
MD5 11b848823a0efd168a986af73babcf5d
BLAKE2b-256 83199631210cfba5359dd163276b1873299cdf10af9e591917438d78cc2cbab5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 76b1f2a443af14929faf8d4db6c77b8f034198c51b667e89608583f7c4fc54f4
MD5 b622ce2ef157a2f180637c817faff2d4
BLAKE2b-256 d9a539fb1d8e3761fc47f9c6eb0528a3c0b35491790fd2a18b55191f3dc6cafe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 189c2742d7f28004188876bd42a613b4f7b29b018471ca8b5df027d2405974fe
MD5 617cad5738ef16c47ae6e53f484aa970
BLAKE2b-256 5d5e5e65cb96debb1ad907bf6ba53d9462b370c75d1080be994eaf866a628b9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.38-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e972526a1ab8059c07ca5101da9618d940c009be57ad8d41ca0c73999ed4f75d
MD5 be3025793a6b3610e3c0282f554d2e8d
BLAKE2b-256 f95a09df1c9b1931d3110afb4749247e9073984f7a957f54ecd345b6831032d8

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