Skip to main content

PyPI version shields.io PyPI pyversions

Schemapack

Make your JSON Schemas sociable and create linked data models.

Description

Schemapack is a library that defines a lightweight data modeling framework based on a schema description, a compatible data instance format, and the tooling that supports them. It introduces two main components: the schemapack, which describes linked data structures, and the datapack, which represents the data conforming to those structures. The tooling around schemapack and datapack focuses on loading, extraction, and validation, and supports partial extraction and data embedding operations. The Schemapack library includes a CLI component that provides access to core functionality via the command line.

Installation

This package is available at PyPI: https://pypi.org/project/schemapack

Install:

bash

pip install schemapack

Upgrade:

pip install --upgrade schemapack

Usage

bash

schemapack --help


 Usage: schemapack [OPTIONS] COMMAND [ARGS]...

 Common arguments and options.

╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version                     Show the version of the library and exit.                                                                   │
│ --install-completion          Install completion for the current shell.                                                                   │
│ --show-completion             Show completion for the current shell, to copy it or customize the installation.                            │
│ --help                        Show this message and exit.                                                                                 │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ validate              Validate a datapack against a schemapack.                                                                           │
│ check-schemapack      Check if the provided JSON/YAML document complies with the schemapack specs.                                        │
│ check-datapack        Check if the provided JSON/YAML document complies with the datapack specs.                                          │
│ condense-schemapack   Writes a version of the provided schemapack with embedded content schemas to                                        │
│                       stdout.                                                                                                             │
│ isolate-resource      Isolate a resource from the given datapack and write a datapack that is rooted to                                   │
│                       this resource to stdout.                                                                                            │
│ isolate-class         Isolate a class from the given schemapack and write a condensed (with content                                       │
│                       schemas being embedded) schemapack that is rooted to this class to stdout.                                          │
│ export-mermaid        Generate an entity relationship diagram based on the mermaid markup from the                                        │
│                       provided schemapack.                                                                                                │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯


Quick Start

This example shows how to validate a datapack.yaml file against a schemapack.yaml using the schemapack Python library. The schemapack defines the schema and validation rules, while the datapack contains the actual data to be validated. The steps below demonstrate how to load both files and run validation with SchemaPackValidator.

from pathlib import Path

from schemapack import SchemaPackValidator, load_datapack, load_schemapack

schemapack_path = Path("path/to/schemapack.yaml")
datapack_path = Path("path/to/datapack.yaml")

# load schemapack
schemapack = load_schemapack(schemapack_path)

# load datapack
datapack = load_datapack(datapack_path)

# validate datapack against schemapack
validator = SchemaPackValidator(schemapack=schemapack)
validator.validate(datapack=datapack)

Documentation

Development

This package is a member of the GHGA monorepo and is developed from the repository root rather than on its own. The repository ships a devcontainer with the whole toolchain: open it in VS Code and run Remote-Containers: Reopen in Container, or set the environment up directly with just sync.

The usual tasks, run from the repository root (see ADR-0015 for the full recipe list):

just sync                  # install every member plus the shared dev toolchain
just test libs/schemapack  # this member's test suite
just lint                  # ruff check + format check across the workspace

License

This repository is free to use and modify according to the Apache 2.0 License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schemapack-4.4.0.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

schemapack-4.4.0-py3-none-any.whl (74.2 kB view details)

Uploaded Python 3

File details

Details for the file schemapack-4.4.0.tar.gz.

File metadata

  • Download URL: schemapack-4.4.0.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for schemapack-4.4.0.tar.gz
Algorithm Hash digest
SHA256 bfbffc28648a0cba9a3ab57facbcfe1381f0491973782f8bb72874348700dec6
MD5 0316ca8566d7ea2b80af70d79832a5c8
BLAKE2b-256 62bff7090073cb923bf55bc34d64840fd7cc8e58b4cf69c6bbaca7610e424cc3

See more details on using hashes here.

File details

Details for the file schemapack-4.4.0-py3-none-any.whl.

File metadata

  • Download URL: schemapack-4.4.0-py3-none-any.whl
  • Upload date:
  • Size: 74.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for schemapack-4.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9615342421615747e2b430d964cdc0ceadd0760242cdbe734e5e3ba20ae92ab2
MD5 73531c6981662e3a2883fddbc0eb058b
BLAKE2b-256 df8a8d78e07109c08e8f6bb550e5c61871d993eee0e8a3c60cc91be52644d3f9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

4.4.0 This release

2 files

4.3.0

2 files

4.2.0

2 files

4.1.0

2 files

4.0.1

2 files

4.0.0

2 files

3.1.0

2 files

3.0.0

2 files

2.0.0

2 files

1.0.0

2 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