Loading...
Loading...
Manage and work with data contracts
Read and decompose data contract files
from pycharter import parse_contract, parse_contract_file parse_contract(contract_dict) parse_contract_file(file_path)
Parse a data contract from an uploaded file (YAML or JSON)
from pycharter import parse_contract_file
# Parse contract from file
contract_metadata = parse_contract_file("contract.yaml")
# or
contract_metadata = parse_contract_file("contract.json", validate=True)Construct consolidated contracts from separate artifacts
from pycharter import build_contract, ContractArtifacts
artifacts = ContractArtifacts(
schema={"type": "object", "version": "1.0.0", "properties": {...}},
coercion_rules={"version": "1.0.0", "age": "coerce_to_integer"},
validation_rules={"version": "1.0.0", "age": {...}},
metadata={"version": "1.0.0", "description": "User contract"}
)
contract = build_contract(artifacts)Build a consolidated contract from artifacts stored in metadata store with individual version control for each component
from pycharter import build_contract_from_store
store = PostgresMetadataStore(connection_string)
store.connect()
contract = build_contract_from_store(
store=store,
schema_title="user_schema",
schema_version="1.0.0",
coercion_rules_title="user_schema",
coercion_rules_version="1.0.0",
validation_rules_title="user_schema",
validation_rules_version="1.0.0",
metadata_title="user_schema",
metadata_version="1.0.0"
)