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.8.tar.gz (172.2 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.8-cp39-abi3-win_arm64.whl (6.6 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.8-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.8-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.8-cp39-abi3-manylinux_2_38_aarch64.whl (6.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.8-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.8-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.8.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8.tar.gz
Algorithm Hash digest
SHA256 1a676f11c45730bda3e49321546acfc12b6288cfcf1e18eea0d808f1d807e071
MD5 e7543d08895f06bb0a708b404824e1dd
BLAKE2b-256 4fd7ff6077a37f078a2bcb0fb522231c06aad4c8294747cec22a45d2c8b27341

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 a92fcc15d4d990f2f6da2f2fa1f3b57cf3c240a9c315c221a562c2b796f5cb10
MD5 e344c0b4cfe89df7055123b05d9110cb
BLAKE2b-256 add016825c83fe9b431a4241e621055e53db0fee78daca1cfe30bd7293dde535

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 39fc267595c30365e5ae6266b8c24d87fd0555950c1a560f15f5d095c57e5576
MD5 0462b5f147085024d07e7c3fc38fa17c
BLAKE2b-256 17fd1877b7f57329219b7eb6b91d376d472db06beb78f900fb3cedaaf9a96f51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 012cf5b7cbfab793027c1e5c99a1c37b6c1f43d6b52e8d82e96c6927db967746
MD5 99195f99c340c19cb2f614ec4a544613
BLAKE2b-256 6edec10358f5a7aa960f655ff9e3358ce571dbda2357b52c7cc57833e1812028

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 1bc42455d5aa60444ba60693681cf4ce2e5ed25a4f222d24d819a3053de40b70
MD5 732d3d241ade8c7724c0bf3c5a556377
BLAKE2b-256 1c1e248b46a71e0c2e54f1770f140c6411e7b171ae418c490c92434939d97b3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01d3af4aab0d589aaa85b790dc34de2977a243fcb2beac752ceba96a465d4e5a
MD5 68bbb4a6451f9665d285fd1bf0a5469e
BLAKE2b-256 779b967921b21d916a8f64ea1f804d448d541bbcc0fc15e913f51aa126ae618c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.8-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 efc6763a3cd256713d6311fb0b902f8b92aa3cd0a6a3c62c4df7254100a74b63
MD5 f8e52b2f58a220dafa881d7227ef1611
BLAKE2b-256 47897fca314d7250e31e241a1655646f333410b3b3bb259417c2e26009d468a4

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