Skip to main content

schemalock

A git-trackable lockfile for DataFrame schemas — like poetry.lock, but for schemas.

Detects unintended schema drift in data pipelines and requires deliberate, confirmed action to update. Works universally across pandas, PySpark (local), and PySpark on Databricks.

Install

pip install schemalock
# or, with local PySpark support:
pip install schemalock[spark]

Usage

from schemalock import lock, check, lock_update

# Create a lock file (fails if one already exists)
lock(df, name="customer_silver")

# Validate a dataframe's schema against the lock file
check(df, name="customer_silver")  # raises SchemaDriftError on mismatch

# Deliberately update the lock file (interactive only)
lock_update(df, name="customer_silver")

How it works

schemalock computes a normalized schema for a pandas or PySpark DataFrame — mapping engine-specific types (int64, LongType(), ...) into a shared vocabulary (integer, float, string, timestamp, boolean, ...) — and writes it to a JSON lock file under schemas/. Future runs of check() compare the current schema against the lock file and raise SchemaDriftError on any mismatch.

Lock files can only be created once (lock()), and can only be changed via lock_update(), which requires an interactive TTY, a typed confirmation of the schema name, and a non-empty reason.

License

MIT

Metadata

Release files for schemalock 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schemalock 0.1.0
File Size Uploaded
schemalock-0.1.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for schemalock 0.1.0
File Interpreter ABI Platform
schemalock-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / schemalock-0.1.0.tar.gz

Download URL schemalock-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a74a4db60ced0de0113a87a20a7dd504505dec6bdadea4e90a343422037f7007
BLAKE2b-256 checksum
How to use checksums
7f795302d401ecdecfd727bd72fdc3b4bf9823064d7d0d328fe2e2e29670ddc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / schemalock-0.1.0-py3-none-any.whl

Download URL schemalock-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
871bc5e83c650440f4794375e0054b484a9a3bb0cb88c88b29d3c30edfcaa44b
BLAKE2b-256 checksum
How to use checksums
abad5649c3083d7c7f4df3707347fe078f8357a1bb5ec42405be1d9f19c159d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page