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.9.0
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.9.0.tar.gz | 349.4 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| snowflake_code_unit_registry-0.9.0-cp39-abi3-win_arm64.whl | CPython 3.9 | abi3 | Windows ARM64 | Details |
| snowflake_code_unit_registry-0.9.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| snowflake_code_unit_registry-0.9.0-cp39-abi3-manylinux_2_28_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| snowflake_code_unit_registry-0.9.0-cp39-abi3-manylinux_2_28_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| snowflake_code_unit_registry-0.9.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| snowflake_code_unit_registry-0.9.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 52.1 MB
Release files / snowflake_code_unit_registry-0.9.0.tar.gz
| Download URL | snowflake_code_unit_registry-0.9.0.tar.gz |
|---|---|
| Size | 349.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bd6b0ad14028fb7c00c5009304d0b33581a404cb84021f041c8cc19d384a06f
|
|
BLAKE2b-256 checksum How to use checksums |
335ba3b1902f1d6e726a72838cafe28abfae3f4ce58b03432aecca24e8b736b0
|
| 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.9.0-cp39-abi3-win_arm64.whl
| Download URL | snowflake_code_unit_registry-0.9.0-cp39-abi3-win_arm64.whl |
|---|---|
| Size | 8.3 MB |
| Tags | CPython 3.9 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
c296881bbc9c4ea8b78b757408e95dc7955563726ab06dfcd2cad70a37dc435d
|
|
BLAKE2b-256 checksum How to use checksums |
d187b23b9443f2780bd0b78f388198d431fa589020ebec83dd46ec3a526a62b1
|
| 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.9.0-cp39-abi3-win_amd64.whl
| Download URL | snowflake_code_unit_registry-0.9.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 8.8 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
02cadc5b709d2a71c1839b51d88b56ba47ac8efffd221567307f160416fae67d
|
|
BLAKE2b-256 checksum How to use checksums |
56723418def98a1c857b8ab17bdef2f3ab9bd078070a66ba08277d703fce40a2
|
| 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.9.0-cp39-abi3-manylinux_2_28_x86_64.whl
| Download URL | snowflake_code_unit_registry-0.9.0-cp39-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.1 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d3d8878040716b00eb807fd25b63464c59de7180edaad72d05e50976cc1f7fdb
|
|
BLAKE2b-256 checksum How to use checksums |
19e20a6e78382b84b319ca10e112affdae5f5c819d8b2dfb35e71c19f9061067
|
| 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.9.0-cp39-abi3-manylinux_2_28_aarch64.whl
| Download URL | snowflake_code_unit_registry-0.9.0-cp39-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.5 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ef7b2697a071becc9a5754c8871b7396fdf99acb5580561404ef9c813551f95b
|
|
BLAKE2b-256 checksum How to use checksums |
d00286fd8b028c3cb39473fed3506861aa0100d16506602ec551026be17a79a0
|
| 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.9.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | snowflake_code_unit_registry-0.9.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 8.3 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
39e37f8e2a3e6d1e8d4be6b477042381c1c26e6ce29180478de4bd4c15d79531
|
|
BLAKE2b-256 checksum How to use checksums |
97e94aab7c79acc1211f4eb196e7089c6353acd74bdc7008cd1caae7312d1c41
|
| 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.9.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | snowflake_code_unit_registry-0.9.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 8.8 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c95cf2c7b72cb56bfe5159a1bdc204a8afa969f8c54ec28d94a79257bda26f55
|
|
BLAKE2b-256 checksum How to use checksums |
26d1ea1a34a3423ffd4a6e01eee4e2d9351327ee40bc438e7c1a4c306143dedf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|