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

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.7.17-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.7.17-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.17-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.7.17-cp39-abi3-macosx_11_0_arm64.whl (6.6 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.7.17-cp39-abi3-macosx_10_12_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17.tar.gz
Algorithm Hash digest
SHA256 95ba260b664e2ba4f9c7f931ba2d25089849234d44fe805b77d67c45d0eceb88
MD5 03f1116c0326efc55b17cbaddbb00323
BLAKE2b-256 4c170c4a4a95651d911ae9459ab55bc65707fc3bdbe389bda1b8cd11d572c651

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 3068723622187cc7bf82b1df587a5013ad2424533ba1a4b92055815e89e4faf6
MD5 0efacb632ef11c5bdc1cfb11f31f61f6
BLAKE2b-256 228e6f01d74cf39324dd5633b857cb642a90325a7a92f5976e3b1066549ebd63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 66e2cedd82b4e0ade0235d3fbd9aa86322ff72c5e0fbe246db95e650e0253d83
MD5 bdf0669fc5faa4701a1829e8cef1dcd3
BLAKE2b-256 8a1a662f7aecae801b32d3f3afe1ac87af48676d1e6d356f7a73090973b0f156

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 1bba27d23f67d65f9b8315904b8a76040780f02ce40cc8a6e47a9f9bfbdb3b6c
MD5 2948a7063fa700802130e530bd36453f
BLAKE2b-256 d3069042ee1892171f3e3d1ec94b03a6dbf6677c2a69b1228ea771abb6e7fa2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 8b242768bbb7686b8d709295a07c7a2d3267eb195c27350698ec685b8465df1d
MD5 13bb2b2f886890eaa885d1b7c18835ab
BLAKE2b-256 f1ad24a61095e057b899e899a0f3198b551fa241e67337b18b057501e7f07c7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 04c96c7fe93dfd8095bec95c99e901ebf6dfe02795a1165380056c96b3b22fb4
MD5 fd2dd9745acafd2d39cd86ec3401bd95
BLAKE2b-256 93d595fb970878970944d04cfa38eff93fa624f81c985d877c4c745ec4e961c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.17-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e8065a561861c2f02b7e50489f330247eb851f851073ce909ebec0c14d030661
MD5 1f37c0e8e48168847bbf75f153132680
BLAKE2b-256 f6800eadce36dc78a5ac33586179d6d6ea7739daad2e083eb101708b7121bb94

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