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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.7.12-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.12-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.7.12-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.7.12-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.7.12.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12.tar.gz
Algorithm Hash digest
SHA256 bc631168281c8d2c8893fb1263c3b5a6bead579ed2c9f3bbddd848e520f25c8e
MD5 9fce151858b85b0e8aa8333f592b10fe
BLAKE2b-256 b5081297a5c6fec83ad7dfb069557f622dc794c806a97653d376d2e6742bf8c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 1429e450e47d8c09662804ce1328ff5d6a2e2bc4d0bf07c531582a4b9ade1528
MD5 3ce7eac325824e430fc56aa183f7f985
BLAKE2b-256 9a736997316571a6a0f6031d43b645b7a9c0ec204751b7e8f804700adf8f9653

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f23939e34df39a6b4240a4d260895427baf9137d01fe2ca4452aa02767f4f6d4
MD5 90cace63cd5fb8ffd32687dd3276a22f
BLAKE2b-256 addb6cddd2c5f72559af5901ed49ee366190e6625d1edf013b69ee6719409cb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 9490e37b4e3c5115fba6e56ce6ed3feb3aebdee69cf8d3832aa24801a76c79d6
MD5 dc80c9b4d4929fc569dd5557371bb98d
BLAKE2b-256 fc1995b4d71271f3516118e704080169f6898cb782b90537fc4477a61009e13d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 965bfa0226776c12dd90ba45b6deaa36cb5b2a2c03de776c03b81c44a3021df0
MD5 6857677bd90b02e81441291e631aa6c1
BLAKE2b-256 2f1d72dc51d8ea08b46ae428f0aa72c1c0431f42451dfffaa0ea894d67c84e54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a2900dc1056e66a72e85bacc6ade5e5b3dc3f26daaef92c67566fe463f3f601
MD5 b2504dee0cee7e02b79468324c37c508
BLAKE2b-256 c4b37523eec44be2273660a1438e37e56ff01a428b118ac4158c55ab2c73fa4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.12-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f0fb68c3c0d0bd62d2c3efb6ea95ae2abc498bc99c21bcfac3c3d32f84b72148
MD5 c8d37632f1c7d7ebb291b61adb7de3a4
BLAKE2b-256 88deaf9b7cbaa5d13c8c09af4e318bc1f635f0bb35f2758e35c8667e8c36a28b

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