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
Metadata
Release files for snowflake-code-unit-registry 0.8.83
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| snowflake_code_unit_registry-0.8.83.tar.gz | 222.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| snowflake_code_unit_registry-0.8.83-cp39-abi3-win_arm64.whl | CPython 3.9 | abi3 | Windows ARM64 | Details |
| snowflake_code_unit_registry-0.8.83-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| snowflake_code_unit_registry-0.8.83-cp39-abi3-manylinux_2_28_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| snowflake_code_unit_registry-0.8.83-cp39-abi3-manylinux_2_28_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| snowflake_code_unit_registry-0.8.83-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| snowflake_code_unit_registry-0.8.83-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 44.1 MB
Release files / snowflake_code_unit_registry-0.8.83.tar.gz
| Download URL | snowflake_code_unit_registry-0.8.83.tar.gz |
|---|---|
| Size | 222.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d771395c0edf6d4a9ae1923486c32d6650e709e7205b34b0a7ed1bd975c808aa
|
|
BLAKE2b-256 checksum How to use checksums |
10a69f406baa25d41fbbba05adad1bdedbf368fa1bdd1c18a64151f83341d8e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / snowflake_code_unit_registry-0.8.83-cp39-abi3-win_arm64.whl
| Download URL | snowflake_code_unit_registry-0.8.83-cp39-abi3-win_arm64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.9 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
e26972a861df11b177aa0b8a6c6b8c39cdc9df67ea545a06c1def36a37654268
|
|
BLAKE2b-256 checksum How to use checksums |
fbe52f5c15c2d4585eeb264b070c6c69da8ec8b559f33dfbe2c012d311ceefed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / snowflake_code_unit_registry-0.8.83-cp39-abi3-win_amd64.whl
| Download URL | snowflake_code_unit_registry-0.8.83-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4ddccb199f4c12653925630728bb20b7fb600d8375a3c04de85c872a73250026
|
|
BLAKE2b-256 checksum How to use checksums |
f2445253ecebb3844fdfb52928a718cf717bf0f0e48b35cd2cccc7c52e0f171c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / snowflake_code_unit_registry-0.8.83-cp39-abi3-manylinux_2_28_x86_64.whl
| Download URL | snowflake_code_unit_registry-0.8.83-cp39-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.8 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a458fd8e903de17c30814a79d091ac14e6b1cfe244ff44d68f5eff340a45bc06
|
|
BLAKE2b-256 checksum How to use checksums |
ff73aa1d7b7e5870bf501695bcb83478d481b4f81bb2050a3a545188fb974b14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / snowflake_code_unit_registry-0.8.83-cp39-abi3-manylinux_2_28_aarch64.whl
| Download URL | snowflake_code_unit_registry-0.8.83-cp39-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.3 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
048127db684cf1ba86f7e1d3660bc195a8ce8a3dec8e286be3821d5ba53243f5
|
|
BLAKE2b-256 checksum How to use checksums |
8da755fa94eeaf983b7db63d5a01b43a667bd3b5b5d94538f91978e7484c63e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / snowflake_code_unit_registry-0.8.83-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | snowflake_code_unit_registry-0.8.83-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1d29d8f8adb5d121e1db53d325d19cf0b597ff067ff9ae8b00b4c0098fe95ac5
|
|
BLAKE2b-256 checksum How to use checksums |
3db0633e914ce26f48ed0e4fbff411edb2f65666469f7efd72c75e9a3da8826c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / snowflake_code_unit_registry-0.8.83-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | snowflake_code_unit_registry-0.8.83-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
a4d7363e1fb90c75e332024bf434f1ee3e650eb7d81afe1036c68d270e51de7a
|
|
BLAKE2b-256 checksum How to use checksums |
2235dc9a3d9af3c0dee3d64a5d3af59fe665cdae4dae765c5b11d35d071b01f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|