Storage and retrieval of object-derived, decomposable recursive unique identifiers.
Project description
Henge
Henge is a Python package for building data storage and retrieval interfaces for arbitrary data. Henge is based on the idea of decomposable recursive unique identifiers (DRUIDs), which are hash-based unique identifiers for data derived from the data itself. For arbitrary data with any structure, Henge can mint unique DRUIDs to identify data, store the data in a key-value database of your choice, and provide lookup functions to retrieve the data in its original structure using its DRUID identifier.
Henge was intended as a building block for sequence collections, but is generic enough to use for any data type that needs content-derived identifiers with database lookup capability.
Install
pip install henge
Quick Start
Create a Henge object by providing a database and a data schema. The database can be a Python dict or backed by persistent storage. Data schemas are JSON-schema descriptions of data types, and can be hierarchical.
import henge
schemas = ["path/to/json_schema.yaml"]
h = henge.Henge(database={}, schemas=schemas)
Insert items into the henge. Upon insert, henge returns the DRUID (digest/checksum/unique identifier) for your object:
druid = h.insert({"name": "Pat", "age": 38}, item_type="person")
Retrieve the original object using the DRUID:
h.retrieve(druid)
# {'age': '38', 'name': 'Pat'}
Tutorial
For a comprehensive walkthrough covering basic types, arrays, nested objects, and advanced features, see the tutorial notebook.
What are DRUIDs?
DRUIDs are a special type of unique identifiers with two powerful properties:
-
Decomposable: Identifiers in henge automatically retrieve structured data (tuples, arrays, objects). The structure is defined by a JSON schema, so henge can be used as a back-end for arbitrary data types.
-
Recursive: Individual elements retrieved by henge can be tagged as recursive, meaning these attributes contain their own DRUIDs. Henge can recurse through these, allowing you to mint unique identifiers for arbitrary nested data structures.
A DRUID is ultimately the result of a digest operation (such as md5 or sha256) on some data. Because DRUIDs are computed deterministically from the item, they represent globally unique identifiers. If you insert the same item repeatedly, it will produce the same DRUID -- this is true across henges as long as they share a data schema.
Persisting Data
In-memory (default)
Use a Python dict as the database for testing or ephemeral use:
h = henge.Henge(database={}, schemas=schemas)
SQLite backend
For persistent storage with SQLite:
from sqlitedict import SqliteDict
mydict = SqliteDict('./my_db.sqlite', autocommit=True)
h = henge.Henge(mydict, schemas=schemas)
Requires: pip install sqlitedict
MongoDB backend
For production use with MongoDB:
- Start MongoDB with Docker:
docker run --network="host" mongo
For persistent storage, mount a volume to /data/db:
docker run -it --network="host" -v /path/to/data:/data/db mongo
- Connect henge to MongoDB:
import henge
h = henge.Henge(henge.connect_mongo(), schemas=schemas)
Requires: pip install pymongo mongodict
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file henge-0.2.3.tar.gz.
File metadata
- Download URL: henge-0.2.3.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
220c345c7ed7dc6e1586080d1f408309702f8c6b45f6ed583a734e21941ffa84
|
|
| MD5 |
411dfcf79aa14c2cdf97f1c33966e964
|
|
| BLAKE2b-256 |
f6d5cc8c4a867d13c1763d760cc7bff53307d2fe61df3fd4b6aa7194d75c70db
|
Provenance
The following attestation bundles were made for henge-0.2.3.tar.gz:
Publisher:
python-publish.yml on databio/henge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
henge-0.2.3.tar.gz -
Subject digest:
220c345c7ed7dc6e1586080d1f408309702f8c6b45f6ed583a734e21941ffa84 - Sigstore transparency entry: 908322705
- Sigstore integration time:
-
Permalink:
databio/henge@39952ff6bad94aa8fbdbc8584e4146ae39b634a0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/databio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@39952ff6bad94aa8fbdbc8584e4146ae39b634a0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file henge-0.2.3-py3-none-any.whl.
File metadata
- Download URL: henge-0.2.3-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7825f6f5d5bf332bad97f10b44ff92b36961e4a511e75de1618b545cbfed436b
|
|
| MD5 |
aafbbd7548d34e8a57b12fc57503e22f
|
|
| BLAKE2b-256 |
f59af2df76a21821719ce71b4921ddeaaa938feeb558236f591574c614cc088b
|
Provenance
The following attestation bundles were made for henge-0.2.3-py3-none-any.whl:
Publisher:
python-publish.yml on databio/henge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
henge-0.2.3-py3-none-any.whl -
Subject digest:
7825f6f5d5bf332bad97f10b44ff92b36961e4a511e75de1618b545cbfed436b - Sigstore transparency entry: 908322707
- Sigstore integration time:
-
Permalink:
databio/henge@39952ff6bad94aa8fbdbc8584e4146ae39b634a0 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/databio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@39952ff6bad94aa8fbdbc8584e4146ae39b634a0 -
Trigger Event:
release
-
Statement type: