ReJot Python Contracts
This directory contains the Python variant for defining and working with ReJot public and consumer schemas. It is intended for use in projects that need to define data contracts and transformations for use with the ReJot platform. For the latest documentation, see the ReJot Python Contracts.
Features
- Define public schemas for data publication (e.g., from a Postgres table)
- Define consumer schemas for data consumption and transformation
- Pydantic-based schema definitions for type safety
- Simple API for schema creation and validation
Installation
Requires Python 3.9 or higher.
pip install rejot-contract
Usage
from pydantic import BaseModel
from rejot_contract.public_schema import (
create_public_schema, PublicSchemaConfig, PostgresPublicSchemaConfigTransformation, Source, Version, create_postgres_public_schema_transformation
)
from rejot_contract.consumer_schema import (
create_consumer_schema, ConsumerSchemaConfig, SourceManifest, PublicSchema
)
class Account(BaseModel):
id: int
email: str
name: str
# Use the helper to create transformations for insertOrUpdate
transformations = create_postgres_public_schema_transformation(
operation="insertOrUpdate",
table="account",
sql="SELECT id, email, name FROM account WHERE id = :id",
)
# Define a public schema
public = create_public_schema(
public_schema_name="public-account",
source=Source(dataStoreSlug="default-postgres"),
output_schema=Account, # Or a JSON schema dict
version=Version(major=1, minor=0),
config=PublicSchemaConfig(
publicSchemaType="postgres",
transformations=transformations,
),
)
# Define a consumer schema
consumer = create_consumer_schema(
"consume-public-account",
source=SourceManifest(
manifestSlug="@rejot/",
publicSchema=PublicSchema(
name="public-account",
majorVersion=1,
),
),
config=ConsumerSchemaConfig(
consumerSchemaType="postgres",
destinationDataStoreSlug="default-postgres",
sql="INSERT INTO users_destination (id, full_name) VALUES (:id, :email || ' ' || :name) ON CONFLICT (id) DO UPDATE SET full_name = :email || ' ' || :name",
deleteSql="DELETE FROM users_destination WHERE id = :id",
),
)
API Reference
Public Schema
create_public_schema(...)— Create a public schema definitioncreate_postgres_public_schema_transformation(...)— Helper to generate transformation steps for common Postgres operationsPublicSchemaConfig— Configuration for public schema (type, transformations)PostgresPublicSchemaConfigTransformation— Transformation step for PostgresSource— Source data store slugVersion— Schema version
Consumer Schema
create_consumer_schema(...)— Create a consumer schema definitionConsumerSchemaConfig— Configuration for consumer schema (type, destination, SQL)SourceManifest— Reference to a public schema in a manifestPublicSchema— Reference to a public schema
create_postgres_public_schema_transformation
Helper to generate transformation steps for common Postgres operations.
Signature:
def create_postgres_public_schema_transformation(
operation: Literal["insertOrUpdate", "delete"],
table: str,
sql: str
) -> List[PostgresPublicSchemaConfigTransformation]
- For
insertOrUpdate, returns both insert and update transformations. - For
delete, returns a delete transformation. - Raises
ValueErrorfor invalid operations.
Example:
transformations = create_postgres_public_schema_transformation(
operation="insertOrUpdate",
table="account",
sql="SELECT id, email, name FROM account WHERE id = :id",
)
Project Structure
src/rejot_contract/public_schema.py— Public schema definitions and helperssrc/rejot_contract/consumer_schema.py— Consumer schema definitions and helpers
License
Apache 2.0 — see LICENSE
Metadata
Release files for rejot-contract 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rejot_contract-0.2.1.tar.gz | 7.3 kB | With provenance | Details for rejot_contract-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rejot_contract-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for rejot_contract-0.2.1-py3-none-any.whl |
Total release size: 16.1 kB
Release files / rejot_contract-0.2.1.tar.gz
| Download URL | rejot_contract-0.2.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a743dc941de9563c570945f60d510bd3011cc41204de8458e57ce342a94eaeef
|
|
BLAKE2b-256 checksum How to use checksums |
3c02317b3a9631715613bfd8a211baa567193b8f8ef697305b007668414ec580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2025.
Transparency logRelease files / rejot_contract-0.2.1-py3-none-any.whl
| Download URL | rejot_contract-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5888d302cbddd3c493997b6e60f736095e7a613865cfdf9c107f37a8a895222
|
|
BLAKE2b-256 checksum How to use checksums |
eab8d543cdb865f8915c7fdd622b9cdd8058735f6cb2d5d05d94fa74ef090a5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2025.
Transparency logSecurity for rejot-contract 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for rejot_contract-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.