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

Uploaded CPython 3.9+Windows ARM64

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

Uploaded CPython 3.9+Windows x86-64

snowflake_code_unit_registry-0.4.10-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.4.10-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.4.10-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.4.10-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.4.10.tar.gz.

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10.tar.gz
Algorithm Hash digest
SHA256 5ba08204391719ad9894ab41851cf35da8c763fc25e05efe9a5f09ef4b7038d5
MD5 3e8e6324bdb4be1e82b583c8f97ccef1
BLAKE2b-256 4bcd514360ceb28052d6a34b5369962fcb3d11e0f10456af2e651c61bfc7e96d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 8715a2e2e0578cc511cbc400b13cb46341349d9f62454eeed8b173edc7ce0710
MD5 743e581875c5bfea45c280bad3885726
BLAKE2b-256 9ec01b70b4865f65e3c8c4db0ed9dd4ec1bb99ce416b2dd662b19127e0fe681a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8543d79082b37dae9abfefc93715e449ef9746698bca07d0b3d4a15215a28794
MD5 4e4e5a3249b9d3a7afd4e46dbd9256cd
BLAKE2b-256 7e19289496002220e4c7e0bc6d7618870f916d6515c0a937705448a874335c4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 eb01aec098ebfed33ba3b783c7d260668a9f7d3a246fa1e9264aa8f0de828046
MD5 08492edbf137e3d10caad94c3fe5e26e
BLAKE2b-256 4598e4b1dfde1b404bca6472160375e2290cd9c6a2f444c6563e4f5211474c64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 92c96d108c8e88a045ae49c4c632d5bef7568e1dda32a57d9ff61046a371d224
MD5 a10ffb836fe3175d8b4ea1f4a93009d1
BLAKE2b-256 439dd331b84fb842a60868c7810725798cce43d3a39509d43cc7e65964162230

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a617aff9d3605c71d95990ce044294741e58c67de465d20ef7b1753393b0be84
MD5 09d87a1a0b235e52d1b4186319b5ebd3
BLAKE2b-256 3ad550ab704667eb41284de615b56bea627ff399145876a9746d55b3fd3a6742

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_code_unit_registry-0.4.10-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c5f9f37db59ffe588a69b9c08d492866bd9368a0b8001a431b202d6bd77c711e
MD5 ed8f1114dc586467a7983bc9a2fc74e8
BLAKE2b-256 e50a2c1238298355d23f5bd438e3f28e78b4948602dae2b0898d274ba8bba14d

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