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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.7.1-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.1-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.1-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.1-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.1.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1.tar.gz
Algorithm Hash digest
SHA256 973dcf491da4890e61d9fe354e0bc21e7189ed4b2983f6e4511bebc5ffa883b5
MD5 a39c4a5a10d6bacd1350e62ab62e630e
BLAKE2b-256 83bf52c7dba4cf1e62e7c94c73f080dd20ef7e014ab23e57e52c322f143fe1cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 6eb1263a8448eda94673bcf4fb6bb21876d0d43e6d991dc567821c2eedfd24ba
MD5 184955ed7cd8eee242c80aa1cadcee34
BLAKE2b-256 d99372e6d461033350b31067f705af11748569e500f9108d089c3270881de467

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5913b51c8175f5a1d72717b1dec99283cc3fef6d7145f5b7391fdd80a1f2e650
MD5 e5a98f09c466e483fe9533770bf268c9
BLAKE2b-256 a46ce11b6969befa1cf5356d100ec083a35cb8c50b3c092441e4c1309cf62c28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 9e41ba00a5b227c01f7bf30812285278c38c4457c5bd7c85198111a2ea759c3c
MD5 e035c15c066daf936dc3f324a989200a
BLAKE2b-256 034febf62525a1fb0937927385186d44a460ea57b218458df3fe06076e829f24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 88839ed240b85a94b1a43ea5d5f31f7d37a0255578e638eedaae84ba53d40579
MD5 778f3db1ba2b80d1aaf8753cc291e365
BLAKE2b-256 e6dfaea7938bb3f877772207c561bfc0cc8c2ed307c81896f54cf9e375aa8ea2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6aa3278b4c0d2ca1ef66255ce89c7f3afad63be92f1fc2188cdfc43415e1220
MD5 4a91ab559240be67e51a59215aeb7068
BLAKE2b-256 360f12d8999ab32da587811d776d148dd9e29d7cda762a50d1c16419f87cafad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.7.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8ec9affda877e91c379285e073c5e5fd01b8e1f3c2d4563e7ea8fd52eda100b8
MD5 dc597d2fb45fd24bca9909f890ea9db3
BLAKE2b-256 21917f11aa73780c0c7ba1f75f20881c33b787f23937e8e49c76fd690e5993e8

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