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.80
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.80.tar.gz | 222.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| snowflake_code_unit_registry-0.8.80-cp39-abi3-win_arm64.whl | CPython 3.9 | abi3 | Windows ARM64 | Details |
| snowflake_code_unit_registry-0.8.80-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| snowflake_code_unit_registry-0.8.80-cp39-abi3-manylinux_2_38_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.38+ x86-64 | Details |
| snowflake_code_unit_registry-0.8.80-cp39-abi3-manylinux_2_38_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.38+ ARM64 | Details |
| snowflake_code_unit_registry-0.8.80-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| snowflake_code_unit_registry-0.8.80-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 44.0 MB
Release files / snowflake_code_unit_registry-0.8.80.tar.gz
| Download URL | snowflake_code_unit_registry-0.8.80.tar.gz |
|---|---|
| Size | 222.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
411f73dbc5fea7c44f6ddefd50bf472ab7cd07c49995978be982c26dc842ba10
|
|
BLAKE2b-256 checksum How to use checksums |
bcb41bfe64d0e9b37f5e79b6a1da1e4b51306501c60bc754e9b8984de4f18c83
|
| 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.80-cp39-abi3-win_arm64.whl
| Download URL | snowflake_code_unit_registry-0.8.80-cp39-abi3-win_arm64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.9 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
335103407f74ebf4d07802128ed2c6829e3eb3e8ff94bf5d0fd767fef9055122
|
|
BLAKE2b-256 checksum How to use checksums |
b7889a9375a551ac752d6edccf8e4ea371686cdca8751fc3987669c02d16298d
|
| 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.80-cp39-abi3-win_amd64.whl
| Download URL | snowflake_code_unit_registry-0.8.80-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5fd035ee0e6d3004f42ac2c8d4ed6061ab9754c6bb060cddf3bcf7f80ddc0fe8
|
|
BLAKE2b-256 checksum How to use checksums |
331e47a0014ef9434766505da8848f124783ad581181a8595fcbe867084dbf6a
|
| 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.80-cp39-abi3-manylinux_2_38_x86_64.whl
| Download URL | snowflake_code_unit_registry-0.8.80-cp39-abi3-manylinux_2_38_x86_64.whl |
|---|---|
| Size | 7.7 MB |
| Tags | CPython 3.9 Linux glibc 2.38+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b2cd822a60b763b5e43aadbd9f0dc7fa1f0c060211a2d5cfdce46aec96f0def6
|
|
BLAKE2b-256 checksum How to use checksums |
8788f75c5a919229fd496fc22057f7b6982e3eac4a425e7d2be65b80cd439dff
|
| 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.80-cp39-abi3-manylinux_2_38_aarch64.whl
| Download URL | snowflake_code_unit_registry-0.8.80-cp39-abi3-manylinux_2_38_aarch64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.9 Linux glibc 2.38+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ef347d419b16317c7a909f67d12909795902428306a1f710ac33d5b2b984eafa
|
|
BLAKE2b-256 checksum How to use checksums |
1f3a0bb1ad7eb33e7a8e319ba55b052cb4ae9edbdefca20ca7ab148bf0a6176c
|
| 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.80-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | snowflake_code_unit_registry-0.8.80-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 |
7028e616939b2c8c8893c4d40d390b3080daeb920341c30d372cb5b924496ceb
|
|
BLAKE2b-256 checksum How to use checksums |
6a2092e53309e2f1c3cab457401ffa5b9ce0b9741edfae156c0f1bd4b9b6b311
|
| 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.80-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | snowflake_code_unit_registry-0.8.80-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 |
3321232079c92607ee20049717ce1b9b52c073abad8e3501939e6e83bcff9df2
|
|
BLAKE2b-256 checksum How to use checksums |
d9cbdb665b548f89586656e41d5425d2f6482edee790788b839248624066d1e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|