Skip to main content

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 annotate tui
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

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-4.1.1.tar.gz (83.7 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-4.1.1-py3-none-any.whl (107.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for data_annotations-4.1.1.tar.gz
Algorithm Hash digest
SHA256 0292474e38c54b3a1ff198b7efb6fe712607c28750e7f12129f10b17207b2471
MD5 c5349a42a165b513bded7c39c80dbb28
BLAKE2b-256 f0db4665eae9f394a6ef41008e919bd3a008fac2c963c3f4c5414d0995b527b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for data_annotations-4.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca6c4ed69c7ac5c882008a9df43660391a79003fc1c872e33558b8ce803d7eac
MD5 cdd7fd6ba327cd7cd58db9bd8e1b3e2e
BLAKE2b-256 69696d73086ac0cc036d47a2145befd5173595b09c6b93339a200f2476b5eeb5

See more details on using hashes here.

Release history Release notifications | RSS feed

5.1.0

2 files

5.0.0

2 files

This release

4.1.1 This release

2 files

4.1.0

2 files

4.0.0

2 files

3.0.0

2 files

2.13.0

2 files

2.12.0

2 files

2.11.0

2 files

2.10.1

2 files

2.10.0

2 files

2.9.0

2 files

2.8.1

2 files

2.8.0

2 files

2.7.0

2 files

2.6.0

2 files

2.5.0

2 files

2.4.0

2 files

2.3.0

2 files

2.2.0

2 files

2.1.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page