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.1.tar.gz (171.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.8.1-cp39-abi3-win_arm64.whl (6.6 MB view details)

Uploaded CPython 3.9+Windows ARM64

snowflake_code_unit_registry-0.8.1-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.8.1-cp39-abi3-manylinux_2_38_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ x86-64

snowflake_code_unit_registry-0.8.1-cp39-abi3-manylinux_2_38_aarch64.whl (6.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

snowflake_code_unit_registry-0.8.1-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.1-cp39-abi3-macosx_10_12_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1.tar.gz
Algorithm Hash digest
SHA256 8a5eb8aacd1436326fb27ba3385b279a4aa7f36f60b9b7fb17a30e500d633473
MD5 1adda13f3efe2723bd356e856b748a5a
BLAKE2b-256 42b456d3d333df30609cca6dd2191c3643a85a6196650a9d12745c9816e460eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 242b3fc3c656f668af251d62b59b9e3c103b6000d7c91697a0ba89df4f765a80
MD5 91f38c0ff52efe8a7fafed8d1d35cdba
BLAKE2b-256 cbade49c6204727ead29545bd9773e0dd9d70e5a97fae49c97ae9390e6dc3319

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 66b8ed7bb617ff8a16409bf17d8334dc98ef796e1661099ff3ec5d4827064b64
MD5 2f6e6b98f09daa23f9043f8c2cbbf539
BLAKE2b-256 61afc2cb7fdd1d02a51517eadf85f323cbceb322d626b9fbe54a2a19001739c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 1915b42810a6e845771b1a7ab05f4c1e5f98300fedf740af34365646b5753c47
MD5 00f1cabefe99a8962124deff6b2ecb15
BLAKE2b-256 b34c906520d5fe936deee5d1207a4a1d2b5766e246338770e16fea0635814d3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 5f238983c726f1c81caf3cf28e036707262ac67ad79b6e83f5039bb538e2b6d2
MD5 41db566855cca5d6b64ecd9b3fe329d0
BLAKE2b-256 014fcb8fda32fec58979dd10299710233065ec8c1156e16b01663c3107dafce9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 093b4adf4d3e71ce6e3145cf1dfc00281d7efc4dd0536ccdc9785cb682948544
MD5 c9162e61e2ee99c4c6312ab651fea8a7
BLAKE2b-256 b4a8954d1ab0547fecce2e53241aa165170cb518ee316311598b8d62a74ef7cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.8.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 48ccb5b6a0a5b9651fbadfee85fcd3576022899a663df23e3fda3500e3937ecb
MD5 a70b719b93f7e162153752949efde112
BLAKE2b-256 2787703645d28dbee97ff9590a46991179d4ab39ce187f57f53961d9b26b2a76

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