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.36.tar.gz (192.0 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.36-cp39-abi3-win_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.36-cp39-abi3-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.36-cp39-abi3-manylinux_2_38_x86_64.whl (7.4 MB view details)

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

snowflake_code_unit_registry-0.8.36-cp39-abi3-manylinux_2_38_aarch64.whl (6.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.36-cp39-abi3-macosx_11_0_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

snowflake_code_unit_registry-0.8.36-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.36.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36.tar.gz
Algorithm Hash digest
SHA256 7d67e75b694200ab91f406d1088a57872c084cce6c7888d9389a1217252e051e
MD5 3c9355e75792e11afbe53436ea722cbb
BLAKE2b-256 482a2165cadba8c7e98290079780409115273e3145ecd9f8196900bdbecd335c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 88bf7ef6507c8a155537e53668ddef2323f4fedf89f62367aad1dd4e0fd6d39f
MD5 a09aa1b7ea73bb19fa7aabdf52b5dfd1
BLAKE2b-256 6ec04c7cbde175e72c462288be4bd6cb4dafc1ba8799eac0ada515509bd0f886

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 897329fd71eff30d572cf94275fe58b1559b9ebafa68cdfc32a9a5c0c67ebd7a
MD5 0b92df8b04e414218dae0f81331b6606
BLAKE2b-256 e0fd4cf45d6a10eaf916c79de85e97e232b934f5ce9af54167eff6863d4c1e1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 f0887834b999ddd271c3e3eb2235809592ae403911b67aa0343d8eb9bb1861cd
MD5 f6e12dcb5e21171a9e52de4da135f63b
BLAKE2b-256 af2026f086db182c4beb535962a63aa6b7e576689bdf718ce05a5f61745ac7f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 455c0547a3c9527e99e66eaad8164e38cb1229b7804fa4a501e40d87d057efd4
MD5 b5521a2bf0f39fabb121d7afc0fd23a2
BLAKE2b-256 cc58e3640bf9116a34913e5051f00ca05cc3dca087c049bdbced7ab61a842465

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5274f63785c76a3ab7d6e9db4056963ea9c3bde5c2c4a1f8b3ae3828241a2e2
MD5 77a19779ab83d7ad791d94bdcca070a4
BLAKE2b-256 91d3943215132c8eaf15269f63eeb400593f6f9b50282c2669d3d8a8774df4e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.36-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b294f205fb67f23a9ad9385cda6cfb8f6a17bf7b5e354ed529c112c2744634fc
MD5 588cc93634a09be45702caaf22bceccc
BLAKE2b-256 5e1b1d14fadb2fcc659621627c86c268ab1fb223b384994e0f267febbec12017

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