dr-hf
Definitions · Terms · Contracts
Hugging Face Hub identity layer for dr-* research infrastructure: dataset and model pins fixed at commit SHAs, an all-split dataset reader, named subsets with recorded derivations, checkpoint branch parsing, and publishing of converted models with provenance. Loading models and running inference live in dr-providers.
Installation
uv add dr-hf
Runtime dependencies: datasets, huggingface_hub, pydantic.
Quick start
from dr_hf import (
SubsetRegistry,
origin_subsets,
read_rows,
resolve_dataset_pin,
seeded_sample,
)
# Pin a dataset config at the commit "main" points to now.
pin = resolve_dataset_pin(
"allenai/ai2_arc", config="ARC-Challenge", native_id_field="id"
)
# Read every split; each row carries its origin split and native id.
rows = list(read_rows(pin))
# Origin subsets are keyed (split, "origin-<sha7>"); derive more from them.
origins = {s.key.name: s for s in origin_subsets(pin, rows)}
dev = seeded_sample(origins["test"], name="dev", version="v1", size=100, seed=0)
registry = SubsetRegistry("subsets/")
registry.register(dev) # same key + different content -> SubsetConflictError
Surface
| Module | Purpose | Key exports |
|---|---|---|
| pins | Hub repos fixed at full commit SHAs | DatasetPin, ModelPin, ROW_INDEX, CommitSha, resolve_dataset_pin, resolve_model_pin |
| datasets | All-split reader | SourceRow, read_rows, split_sizes, NativeIdError |
| subsets | Named subsets and registry | SplitKey, Derivation, DerivationKind, PartitionShare, NamedSubset, origin_key, origin_subsets, seeded_sample, seeded_partition, exclude, union, explicit, SubsetRegistry, SubsetConflictError, SubsetNotFoundError |
| identity | Identity hashes through dr-serialize | identity_hash, DATASET_PIN_SCHEMA, NAMED_SUBSET_SCHEMA, IDENTITY_SCHEMA_VERSION |
| publishing | Model upload with card and provenance | ModelProvenance, publish_model, TagConflictError, MODEL_CARD_FILENAME, PROVENANCE_FILENAME |
| branches | Checkpoint branch discovery and stepN-seed-* parsing |
get_checkpoint_branches, parse_branch_name, create_branch_metadata, ... |
| io | Atomic multi-file dataset commits | commit_dataset_files_to_hf |
| location | Dataset repository references | HFLocation, HFRepoID, HFResource |
| models | Branch metadata and commit models | BranchInfo, BranchMetadata, DatasetFileCommitEntry, DatasetCommitResult, ... |
Key rules (see contracts):
- Pins and provenance accept only full 40-character commit SHAs.
read_rowsvalidates that native ids exist, are non-null, and are unique across every split of the pinned dataset before yielding any row; datasets whose id field repeats across splits useROW_INDEX.- Seeded samples and partitions follow a documented rule driven only by
random.Random(seed).random(), so membership is reproducible from the derivation and parent alone. - The subset registry maps one
(pin_hash, split key)to one content hash. publish_modeluploads weights,README.md, andprovenance.jsonin one commit and never moves an existing tag.- Every hash is a dr-serialize identity hash of an identity document with a
dr-hf-owned schema name (
dr_hf.dataset_pin,dr_hf.named_subset) and schema version 1; dr-hf computes no digests of its own.
Publishing a converted model
from dr_hf import ModelProvenance, publish_model
pin = publish_model(
"converted/step1000-seed0",
repo_id="drotherm/DataDecide-dolma1_7-150M",
branch="step1000-seed0",
tags=(),
card_markdown=card_text,
provenance=ModelProvenance(
source_repo_id="allenai/DataDecide-dolma1_7-150M",
source_revision=source_sha,
conversion_tool="datadec.models.convert 0.1.0",
verification={"max_abs_logit_diff": 2.1e-5, "batch": "8 x 256"},
),
private=True,
commit_message="Add step1000 seed 0",
)
Documentation
- Definitions site — shared vocabulary and binding contracts (terms, contracts; agents read the TOML directly)
- Changelog
Development
Install dependencies and the commit hook once per clone:
uv sync --locked
uv run pre-commit install
The hook runs scripts/pre-check.sh (TOML lint of .defs, Ruff format,
Ruff lint, ty) followed by the test suite. Hub-backed conformance tests are
opt-in:
uv run pytest -m hub
License
MIT
Metadata
Release files for dr-hf 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dr_hf-0.1.2.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dr_hf-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.1 kB
Release files / dr_hf-0.1.2.tar.gz
| Download URL | dr_hf-0.1.2.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc56996e7a7a4cd58282336ee9a94ffe08fd2fc3b6de0be9db2e7f430639ec73
|
|
BLAKE2b-256 checksum How to use checksums |
75cea537b7fe5ab750fe59577606a84808c9d951c0e2f67116422a67b97036e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / dr_hf-0.1.2-py3-none-any.whl
| Download URL | dr_hf-0.1.2-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cf68381bc0910d89c1a14f71853faa8b4fa39f1b6cc8dffcfe2069cf6edd752
|
|
BLAKE2b-256 checksum How to use checksums |
7e23a77300af7a5aae56b2672fe9cdf4af655a0a6031ec826a913be7a92e06d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency log