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.4.3.tar.gz (99.2 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.4.3-cp39-abi3-win_arm64.whl (2.9 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.4.3-cp39-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.4.3-cp39-abi3-manylinux_2_34_x86_64.whl (3.2 MB view details)

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

snowflake_code_unit_registry-0.4.3-cp39-abi3-manylinux_2_34_aarch64.whl (3.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ ARM64

snowflake_code_unit_registry-0.4.3-cp39-abi3-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.4.3-cp39-abi3-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3.tar.gz
Algorithm Hash digest
SHA256 627de8eb8ee058f51a7a3bec569e084062bb76ef889d05a0c1223916789b33ea
MD5 930c8cd0507fc89ef6c784bcec0f8a2c
BLAKE2b-256 bc88211dc7255e9e72a48bde62feb5d76b982c2e7858fff298584afb08be1778

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 7e8a249272854bf9cefcf7f01cc7144996a137c5a95cef1bd20dc349e9bbfabd
MD5 ed3262af1021440586071417f52096d6
BLAKE2b-256 660d1bc80b795e48713582deb73b59ae9ea7ab07f9d5e72fb7b2c7903c99b7cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e65352e678f1c8445a3e62bd56f4ab722e6f4dec11b4baf09c815a4d27618369
MD5 b8746cf9a747c9002babdb20f4994480
BLAKE2b-256 53c0da270004130e18505a0567b662b5769ceebabbd0371575b0a2f6b3cc08e2

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.4.3-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 da8b64fcce62e6b9a75a08c186d74899aee3e76bad336c9caebd21a69f12fed8
MD5 d1f0ea790f9aad16512a42b8c7f339e4
BLAKE2b-256 a4d47c47dd1c5f395aa4d27165aea4d23979f1ba265ef4913611713fe52e00f0

See more details on using hashes here.

File details

Details for the file snowflake_code_unit_registry-0.4.3-cp39-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3-cp39-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 1de77bc01c026bbe7505e4042106e13230865eae26828b9da13c227483ef6f99
MD5 16c9f26b322317d6c4cda3dfad1aea7d
BLAKE2b-256 a0aba427c4dc513a5a9b2819982214f64618e2916ef7706b1e0ec19d0287b836

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 844d17c4a9555b26fe31f3331f49eb2c63a4c843a05796f555a30dcf32bbf489
MD5 7f8d238061386ecb0f0c54df2989a660
BLAKE2b-256 aaa857e4fe0bcf3041823c98a7027cdfc8e1583357f4729649267dafd50ef9bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5b84921996c8897050facdbbfb4399edb5e222fd73d78aca422068fcef6a2132
MD5 f212ea350a2c1c2d383c1016df5a4ed1
BLAKE2b-256 93ebb8a76973ce68bfbbbe51ba4dbe8a84b9e76415644d4d440881f056733189

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