httk-data¶
This site documents specifically the httk-data module. For the full documentation of httk₂ as a whole, see docs.httk.org.
httk-data is a httk₂ module for data
management. It is the capability layer built on the stdlib-only contracts
and models in httk-core: it serves httk-core’s record models through the
neutral httk.core.EntryProvider contract, validates values against their
OPTIMADE property definitions with jsonschema, and provides the database
storage layer httk.data.db — relational storage and querying of plain frozen
dataclasses over SQLite or DuckDB (via the httk-data[db] /
httk-data[duckdb] extras).
Quick links
Data management guide: Data management
Database storage guide: Database storage
Migrating from httk v1: Migrating from httk v1
API reference: Reference
Runnable examples: Examples
Examples notebook: Examples
Install¶
Preferably work in a Python virtual environment, then do:
git clone https://github.com/httk/httk-data
cd httk-data
python -m pip install -e .
Usage example¶
from httk.core import standard_entry_type
from httk.data import ReferenceEntryProvider, validate_record
# Serve a bibliographic reference through the entry-provider contract.
provider = ReferenceEntryProvider({"ref-1": {"title": "A study", "year": "2021"}})
assert list(provider.entry_types()) == ["references"]
# Validate an OPTIMADE 'references' record against its vendored definition.
validate_record(
standard_entry_type("references"),
{"id": "ref-1", "type": "references", "title": "A study", "year": "2021"},
)