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

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.61-cp39-abi3-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.61-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.61-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.61-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.61-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.61.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61.tar.gz
Algorithm Hash digest
SHA256 93149e2ce87427df43c9c2d9a2e644fd97efcb56b65d974d1473c84c09aa5a1d
MD5 6297209d5d443d80e814ae4599334416
BLAKE2b-256 6460afc8aaad73b374e21ffdd4b41bec80587511352a7c92aec4c014c7f680de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 2bd6ce82bbe1d75bc51f34d59839f3977ee3468c6a5b331bc88e1e8c0491d2b9
MD5 4741bac00b644dd0002599094ab6883f
BLAKE2b-256 e24748f2beed43f17dcce1d2249a313dcccbe58570c86486eba5390f97130064

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ba1354f4362d4713c3f0e4453766a7a83ce97095e26980789cb70207dd2f63b4
MD5 80f4687b0fb4e82baa886d02370a5e2e
BLAKE2b-256 4886162424612024b216bea8928b67b69d8147542bac71ed3c0b190f986d3c4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 16b383e0b109dd5d6fd4d50099f4386a45dcb02edb3a3b10a96d3d504370d54e
MD5 2c4d9eae7274447096c1c1aa988cabe9
BLAKE2b-256 23a1fc7d64eecfb0721cf27b4bdeb45d884463fca54b9dedb5ad8c37d4f2ce72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 4945fedc35d265e3da416d3de27a2fcd18a6f6712dcea76807541ad52356a794
MD5 abcc30d8bc00c1ef60296bb304e9bbb8
BLAKE2b-256 e71c771619dd4b91e130479f1c1b8b588167cf4f7a41d2c2c0cc3058f986ebd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e9a712b512e462520a0acd06bb82e1133ccdd3d5fc48ec229ed7b7aebb6a699
MD5 a41eb22b7c5c6d9d750521a732d2e883
BLAKE2b-256 9dbcaa8d3a6c85f8e6cc9666c62ff458c292dcf66b355f97087e66b0f1ab4a0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.61-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2d4649d9ecc4d215239c3095d12b844491be46c5014560f621a012c931715ad5
MD5 73c4367e3a5744def3992cd6d673ad2b
BLAKE2b-256 f2b6b554df0c9bdd626e5678924f6f19ecc13f31760ebe94fac8852404b2691e

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