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.49.tar.gz (200.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.8.49-cp39-abi3-win_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.49-cp39-abi3-win_amd64.whl (7.2 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.49-cp39-abi3-manylinux_2_38_x86_64.whl (7.6 MB view details)

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

snowflake_code_unit_registry-0.8.49-cp39-abi3-manylinux_2_38_aarch64.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.49-cp39-abi3-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.8.49-cp39-abi3-macosx_10_12_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49.tar.gz
Algorithm Hash digest
SHA256 7ce2bdb45b54a3d1fc0d9f50889e80cf1befbe70e139b3905d93568653db95e0
MD5 16e33417101b4d1758e694fe6249dfbb
BLAKE2b-256 023eface8caf2ca201fc701930ca564150d11cb570aedfb214a6df7780c0421b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 54df7b36a3ef26a5ed14100391a8f752fa373359f91004b4ae3cc7c398133c45
MD5 6dca21306f1dc8d81d9ee62e92bf8d56
BLAKE2b-256 7c346e93246f26b5fb678f0f399df152a737bb4cc47cd6dfbd216ac9c8b7b8d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0ee4a313d34c48f542f097dd5d1c786676123e6440176b4b1ecc6456369b714f
MD5 c033976b1b0bd8addcea28e126200e15
BLAKE2b-256 653786a252e2df9271b4809f6bab9bfab6bc8bf00ce49831075d54e59ac6dae4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 091a9a9f3e4fb48b26019752e1597d6eb9d49046d157e687a33da547dd74dc92
MD5 e5e8119850eb66f5c469ae28996a37f1
BLAKE2b-256 277fdfbd25c8fc6241dacc726dbcf07b4b35cf916a9aba2225a0b0c5264bb2d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 e5296cb4030a968eca1ae8946c0c90da6c866c0e75040819ea07b1e09a86d971
MD5 431fcfaa1f8e372ea26251938590b501
BLAKE2b-256 ee9b4a493d148002c61aeadc7f657e91ffea5b597cb7696414b4a3c48982a446

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52f091a0e5ed4ca4bafb444482c9291647ea702c1758774f4fe5788b62ba6b5e
MD5 74f1c08f795f5e3ee73c7afd6764b4cd
BLAKE2b-256 adc72729eabd0d51822cbf8a9c46e34072112496df6d090535fda6cb1b6aa268

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.49-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 83c0a500dda8be17e2707aded9cc48e27470b34601902370e71e31494f86848b
MD5 acc5696e91b00d341b76c9cf5fe025c6
BLAKE2b-256 e5055f79eff855343db5e3831552e3bb101c8e02179f4dc25802fb2ce2647f5a

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