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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.5.11-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.5.11-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.5.11-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.5.11-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.5.11.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11.tar.gz
Algorithm Hash digest
SHA256 556aa030415f2ac0a053f79631e0336f92daac4d3aecd9c8d4cd4a46d37413ae
MD5 ddedebdb4735d3de9f408bd9257119ec
BLAKE2b-256 ecf951c6f6ec7d5fd1ec6b1f15935f7b77c86bfbcf62d2465ea732a59069d367

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 445ec59ec54341f74296d607e853096867db9200bf865adeeed1362489feb497
MD5 10a4988a5ce6569067644e839f857300
BLAKE2b-256 f93f87caea142faeb47b498c38b31b1c98feb8aee596ce61971d571ca0e8a485

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f0ac4a8a54c1b77ca5931c5823830df0da1f84dc6f6f23e0eadf6051a04f1f63
MD5 c21f8694ef6224cd9c5e6bdde3b6f48c
BLAKE2b-256 56c4cf96a7e13df84ebf26df7e946247c6e07170eca9f458d9451d749511c0b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 acd48663bfe87d7435e7bab0882d4cf15b5cc7583cb3bab73b71bbd3a19ae599
MD5 bc1a1962072bbf83a0dc67d847d63947
BLAKE2b-256 efb882c465e5b3f16b941adfa6e9a485e4a286963ff32aa94543f3f4b3751b8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 7e5104ca9b71029c50a499fb3bffff23da82be01df2edb52b26bfcff10817103
MD5 dd207b3098ccb3e802a327db7f7ff375
BLAKE2b-256 20bd5b2f249e2de3f1438dd8596617f8fec35925183edb1639e02cae5d6b0307

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00b069018bc181748cb0d77a21865d3628572f7c8b4d2485da253a07b0698021
MD5 8c3fddbcac361ea773670247cd3e641f
BLAKE2b-256 4ba26a32d933d2cf877b981ab95b3f3a23b2c984eeae4f709b3ef37e91d32ab9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.11-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 80a95dae5ef67017ad6e38454ca148cc635bf2f988841c5a7461d126348df4c5
MD5 5d684882ceb1e6b090140509c010936b
BLAKE2b-256 f397f9fccc3844cdf869d7321150ca350699987ab23a4011e23bd02d2a660842

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