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.41.tar.gz (200.9 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.41-cp39-abi3-win_arm64.whl (6.8 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.41-cp39-abi3-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.41-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.41-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.41-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.41-cp39-abi3-macosx_10_12_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file snowflake_code_unit_registry-0.8.41.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41.tar.gz
Algorithm Hash digest
SHA256 d0fee8d6dbc87e203302d28bae3ac85500675c9ad060b5f261d7cb83e7968086
MD5 d6c33b9cb7136e51c083b71238f4e2a5
BLAKE2b-256 678d795ac219f5f83c9c9defa4539c7e3e5c4bd55e02e5403cc8e7bfbc519550

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 f6e2d317d72a503e5fdd32891ad9992c27821bdc41c391bbb98908a7182473f0
MD5 1e46ee65a55633b30751f744d826664e
BLAKE2b-256 ae5e32f7ccafabab33b50fd36b624b2a25dd776c3ac8a2d20b69eec6d02a2606

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e1416e7e1982cabc26380e9a27986bd541c1abdee2cf98c72bcdd1a7b5eff642
MD5 3d8e3dc3cb0cef6f7e7d8c05c34813e6
BLAKE2b-256 522147a800320dc857395624d1211f3df5864a0b2f7e335c91596f42917b58ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 2f7f5d74ceb8cf7829b2c9a486201acf97315297c0ed3ad7294b2db527dfccd9
MD5 c256972141f2e80926ae8dec8be306a9
BLAKE2b-256 9c1e3f1dfa32e2919ec075d1186f8d87be53b24cb832133145514b90d6083b41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 62426371825e4fb08aa4c793b3dfca6d6a11b2fc8f42a466d201b669f0798d2e
MD5 73fed00fef0c563343258a1fffe4fba7
BLAKE2b-256 2a3f162b1f35039c548bcdf1a0d593b7ed97416db20bba8f4aba0d6c9add3e50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4746a7fe3d8176706737bbd20d553cf21a114f0e602e2678b9db5b0a1dced9e4
MD5 0bc2ae6f459c5b4a81712831c7478786
BLAKE2b-256 6fbeaa0cb8542394efedcd362a64cccb8e84b40f6e743aff1a1755b90aa587d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.41-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed774a7dbcc3d6e4dcc6058d1546146aaba7cb3c52695ea17af2b1fc09db78a0
MD5 8ec2c196201b3d061d9bd1211bedcb5d
BLAKE2b-256 e217d92c3c4538ec4507aac3dbee088483516d4b250f29e616862fd61cc3bcb1

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