Skip to main content

Annotate data artifacts with provenance and descriptions

Project description

data-annotations

PyPI Documentation License CI

data-annotations is a Python package for attaching provenance and structured descriptions to the files and directories your workflows produce.

It writes plain JSON annotation sidecars that are easy to inspect, archive, and publish with research outputs:

  • files use artifact.ext.annotation.json
  • directories use data-annotations.json at their root

Optional Markdown README sidecars can be generated for human-readable summaries.

Documentation

The full documentation is organized as a Diátaxis site.

Other links:

Installation

Install the core library from PyPI:

pip install data-annotations

Or add it to a project with uv:

uv add data-annotations

Install CLI support when you want the data-annotations command:

pip install "data-annotations[cli]"
uv add "data-annotations[cli]"

Quick start

Decorate a function that writes an artifact. When the function runs, data-annotations records provenance and writes the JSON sidecar.

from pathlib import Path

from data_annotations.annotations import record_file_annotation
from data_annotations.description import FieldDefinition


@record_file_annotation(
    title="Participant Cohort",
    summary="Participant-level cohort assignments.",
    fields=[
        FieldDefinition(
            name="participant_id",
            data_type="string",
            summary="Stable participant identifier.",
            required=True,
            nullable=False,
        ),
    ],
    primary_key=["participant_id"],
    artifact_kind="dataset",
    write_readme=True,
)
def write_participants(artifact_path: Path, input_path: Path) -> Path:
    participant_ids = [
        line.strip()
        for line in input_path.read_text(encoding="utf-8").splitlines()[1:]
        if line.strip()
    ]
    artifact_path.parent.mkdir(parents=True, exist_ok=True)
    artifact_path.write_text(
        "participant_id\n" + "\n".join(participant_ids) + "\n",
        encoding="utf-8",
    )
    return artifact_path


artifact_path = Path("outputs") / "participants.csv"
write_participants(
    artifact_path=artifact_path,
    input_path=Path("data/raw/participants.csv"),
)

This writes:

outputs/participants.csv
outputs/participants.csv.annotation.json
outputs/participants.csv.README.md

CLI

The CLI supports retrospective annotation, provenance inspection, source recovery, and sanitized publish bundles.

data-annotations annotate file path/to/participants.csv --write-readme
data-annotations annotate directory path/to/run-001 --recursive
data-annotations provenance match path/to/participants.csv
data-annotations provenance chain path/to/participants.csv
data-annotations provenance checkout path/to/participants.csv
data-annotations publish path/to/run-001 path/to/publish-bundle

Development

From a source checkout (assuming you have Task installed):

task install
task lint
task type-check
task test

Build or preview the documentation site:

task docs-build
task docs-serve

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

data_annotations-2.11.0.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

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

data_annotations-2.11.0-py3-none-any.whl (79.4 kB view details)

Uploaded Python 3

File details

Details for the file data_annotations-2.11.0.tar.gz.

File metadata

  • Download URL: data_annotations-2.11.0.tar.gz
  • Upload date:
  • Size: 61.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for data_annotations-2.11.0.tar.gz
Algorithm Hash digest
SHA256 bc3670652b95350702a8ea945cfcbaf3ba04b395be00cb814bc29342c912db7b
MD5 930c61bbc5295846a53a35a4dfc4a2ac
BLAKE2b-256 8ec71208dcc220e11aa544863895be75a6b94a38436de493537a4e45ba08d8b4

See more details on using hashes here.

File details

Details for the file data_annotations-2.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for data_annotations-2.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22d5caee628a6cc480dd743f8d810bac82f741200fee23bb9cb71693ad8c92ff
MD5 919f0e5700aec8462385e6dcb6d90307
BLAKE2b-256 dc3fbd190c222b54d34f846ec0441bc7ea60f0995b1cd17450583feec0dab08d

See more details on using hashes here.

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