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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.28-cp39-abi3-manylinux_2_38_x86_64.whl (7.3 MB view details)

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

snowflake_code_unit_registry-0.8.28-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.28-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.8.28-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.28.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28.tar.gz
Algorithm Hash digest
SHA256 9448a66079048746ee399360bd6a8e56cae6e2fab67ad0fd4a136a72a64a0f24
MD5 9f27b01c17be863dc4a1356c49c6f501
BLAKE2b-256 9e022732a39c3fa0e341e963dd48b9e1984454edbd63b137513fdfa0950c7f02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 8393c3f972a7f80e48a69b884ee6fa609cfe46f41196c70ea4966dc161c1f2d8
MD5 c3fa4d9849b6097ebd694dea8ca002fc
BLAKE2b-256 315bc50c1f4195ed7e0f0556fe263321fae20f20908623f8e29ed73188a0ac79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3e4d5c49e6c35125eb67de3ad5a506a52096997b6fa95833d1aaac37438d0427
MD5 290ec136fd61426f36608db6e7141a15
BLAKE2b-256 12315b18efe948919d54116e6bc30ff5162005e5c1cab46105f75eb0c838061a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 949a102822d97ca79fafa1385e2af7d31b28bc4e73fda7ae4002f3737da39fd4
MD5 ff5372e1be7d3c09f9ff6188e76b8073
BLAKE2b-256 3412938031410d0103efaf685a583811b9581655fdbdb77d9112910828426bd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 4b4bad72938b2a04e48a605a78d32d7048a929d280dbb66e36b9eefea1a1ab57
MD5 b5b4db738edb338ae49cc049a0cea087
BLAKE2b-256 89aeda4e80ad737215dd20bc067417b1449c8bafdbaefb5d46799767b12cd208

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44229cdbedaae6b1bba99b87efb88a47c150f1d8593d698ca06028284fd68577
MD5 ff867d29fb3f9e21164aa50ec2e3036a
BLAKE2b-256 2b5a3365668d6d3780828024f35ac558bf386062f5207a1840cabb956863da20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.28-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d0ac11a04a1f00a337ca771e398e73935ad176831952dce2da58aa40a62a9744
MD5 e67f31582be2ceadbfbc677715cbac2a
BLAKE2b-256 b6846dcbc2759cc73ec092cdca48391012cdfcb5eb4adcb45975a721bb229c6a

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