Skip to main content

OGC Blocks client

Project description

bblocks-client

A Python client library for working with OGC Blocks registers.

OGC Blocks are reusable specification components that support validation, semantic annotation via JSON-LD, and federation across distributed registers.

Installation

pip install bblocks_client

Optional extras for validation and semantic uplift:

# JSON Schema validation
pip install bblocks_client[jsonschema]

# SHACL validation and semantic uplift (RDF/JSON-LD)
pip install bblocks_client[rdf]

# All extras
pip install bblocks_client[all]

Usage

Loading a register

from ogc.bblocks.register import load_register

register = load_register("https://example.org/bblocks/register.json")

# Look up a block by identifier
bblock = register.get_item_summary("my.org.bblock-id")

Imported registers (dependencies) are loaded automatically. Pass load_dependencies=False to skip this.

Accessing block metadata

get_item_summary() returns a BuildingBlockSummary with lightweight metadata. get_item_full() fetches the full BuildingBlock, including examples and semantic uplift configuration.

bblock = register.get_item_full("my.org.bblock-id")

print(bblock.name)
print(bblock.status)        # Status enum: stable, experimental, etc.
print(bblock.depends_on)    # Set of dependency identifiers
print(bblock.ld_context)    # URL to JSON-LD context
print(bblock.schema)        # Dict of media-type -> schema URL

JSON Schema validation

Requires bblocks_client[jsonschema].

from ogc.bblocks.validate import validate_json

result = validate_json(bblock, {"type": "Feature", ...})
if not result.valid:
    print(result.exception)

# Or raise directly:
result.raise_for_invalid()

SHACL validation

Requires bblocks_client[rdf].

from rdflib import Graph
from ogc.bblocks.validate import validate_shacl

graph = Graph().parse("data.ttl")
result = validate_shacl(bblock, graph)
print(result.report)
result.raise_for_invalid()

Semantic uplift (JSON to RDF)

Requires bblocks_client[rdf].

from ogc.bblocks.semantic_uplift import uplift_json

rdf_graph = uplift_json(bblock, {"name": "Alice", ...})
print(rdf_graph.serialize(format="turtle"))

This applies the block's JSON-LD context to the input data, producing an RDF graph. Pre- and post-processing steps (jq, SPARQL, SHACL rules) defined in the block are applied automatically.

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

bblocks_client-0.0.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

bblocks_client-0.0.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file bblocks_client-0.0.1.tar.gz.

File metadata

  • Download URL: bblocks_client-0.0.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bblocks_client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bf773564fd3322dd56a549b601da752b2f3626f8940f731fd8e05e37d93e3d47
MD5 2ef4d1e881881a023b2a6f4a4411d174
BLAKE2b-256 38feabe0bfd84c1a7c5a8758f1e0251b41b3c43a42f14a067250824738ef6e5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bblocks_client-0.0.1.tar.gz:

Publisher: python-publish.yml on ogcincubator/bblocks-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bblocks_client-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: bblocks_client-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bblocks_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a5022671234be95e32d08adbaae844037c9811ba25d1fb3b7237d18a45a0a1d
MD5 c55b896bdcf831dd6082444497132337
BLAKE2b-256 d59631f7e69b0a92d3bad5906a00b920493f77ab1f177957c2ac341467ff8ef8

See more details on using hashes here.

Provenance

The following attestation bundles were made for bblocks_client-0.0.1-py3-none-any.whl:

Publisher: python-publish.yml on ogcincubator/bblocks-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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