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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.5.12-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.5.12-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.5.12-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.5.12-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.5.12.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12.tar.gz
Algorithm Hash digest
SHA256 0cff330fd1505940056d918271e5b809b7249d59dee8e8ec6be9eb149dcab2ea
MD5 aef321cca16574a1c9a7cb0da06e5631
BLAKE2b-256 028ac67a3ce5d736a5dbcce99bde239e1b1edae0063d5014a8cce956f850d3a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 d98b1f77ccc569c91d520b4fed121edec3a8ce90d52ee14a19e350f838803cd5
MD5 8bae1fbbf20b0adb468edd5d26a269d2
BLAKE2b-256 79c55fb144eefd45709fac6deadcbf582b17bb7ecd5a57890bda444a5d995d3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 60ac6da611c84edff7e4a675252050d50eb23609977f12db2f239f9176d4513d
MD5 fed8bdc68a9b4c43668a484adc67623f
BLAKE2b-256 1d9104f19871054c0d1e04ab26122d99b9165feef4db5266f1f463435e19e1a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 80add05182f517f39d96e5e2249447333773d0b4b76c0e9838caf0aef36230d4
MD5 0770cbda11574b81270930a147d6dd73
BLAKE2b-256 73400cd8a7f7be49dc5c9fb94d87632b17ad34cdaf4aa71ee3d94e0d03457af0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 3e5b92c7c885d32bfad9ad1630db24c9b08fdfbccb62b3d9b9c4e69c0744af94
MD5 5e4a002dfaf27eaba70eaaa178afeff0
BLAKE2b-256 edc5199ce753b15a979b58756220297ab623fe41ec526d235ce779c513f37953

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b9a3659af8a112751433e24c4108552355d4f42d71fc2dfc717ad837927f70d
MD5 938a457dfcd5aa0513303a0ff10eca86
BLAKE2b-256 d9300a0d85a40b5165062d68673654e96248488675893282bc16ed70416b8c64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.5.12-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3bf2cf545387a61bceb0fb9baddf8064e8c635798d8cee08e26856d229960085
MD5 6fcf1c3c9bb10a76c1c50c6b52a3b51c
BLAKE2b-256 a3bde75d836350e91f0128cc00e3dbb5e881d375b8686d698e05aef60bd26f5d

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