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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9.tar.gz
Algorithm Hash digest
SHA256 ecadb4ac61cc25cdefc5170d3723efd64b6f21213e7ffc4dc4c230be0431d340
MD5 0536f5115fc93723de7fd7222dd83f64
BLAKE2b-256 8adb19184f72b208b43656b7530f594db2aea4844c457dc3cf80b1c6446de762

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 dfb7ce6cbeef413482d4373f1e2cf4082ff8289026fdf28647760910ea6783f5
MD5 591e279d46739ec5bf414d206f66506a
BLAKE2b-256 8695096c421a86ce3d84b5aef0b02cd9a1641c2d004763bfee151fbe6d1876ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0c3949dcf89126f60fee5bfe8e5f1d5f7a506b812ac090f3c0eb92c0ca68d2c7
MD5 7250240223fef04e762bec39c13780ee
BLAKE2b-256 f97cbfc6269222c948f2636d8ada9b91970b849777cce30f575de9e2d9de15d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 90daad4a08ce0fc4133471d28363a214842645db45b271d75007f8551426e66a
MD5 3fa9594eb901ea854591782968e8149e
BLAKE2b-256 6b0b7f2991d3f7819aea8dbdac2a821a008150bea26276d7ccaab1530a3f10ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 36befc2269707300cac38f8f32f099757ae3c24420cba81027e18a663c26ba8e
MD5 aa9d6a142253a681827d16b82de226c0
BLAKE2b-256 0747abd169af6c9d056618d49a96485d6fd986db2e1fed0737711b0bab1e81bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef27c94c5509c25955fe04172a34fe9a8e29ac740efe4fc3417724d8a9a1b0b0
MD5 8bd4ef57fc14b794ee873a0e3acbdfab
BLAKE2b-256 4b3f7262d0623e0ad2f4ad3ee7de2bead75647509b5479dae753300fcee30e5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.9-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 51739385ecb272fd701ccf91b8676014bd1ab3616747ebd4f31d5f8a2a5ec185
MD5 b29ec8a028654ae3a7f076d6b41c1587
BLAKE2b-256 5c72960a02f0b723e8296814abf13ce3a4f5396c40e90fb249e9cdc57a3e8dfa

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