httk.core.datasets

Neutral dataset identity, distribution, and publication metadata contracts.

Classes

DatasetDistribution

Describe one retrievable representation of a dataset.

Dataset

Describe one published dataset independently of a transport or provider.

DatasetRecord

Store one Dataset using the core dataset storage contract.

Module Contents

class httk.core.datasets.DatasetDistribution[source]

Describe one retrievable representation of a dataset.

Identifier and vocabulary fields must be well-formed absolute IRIs. access_url may instead be a root-relative URL for later resolution by a serving application. byte_size is a non-negative integer, and sha256 is a lowercase hexadecimal digest.

Parameters:
  • id – An optional identifier for this representation.

  • access_url – An optional URL from which the representation can be retrieved.

  • media_type_iri – An optional IRI identifying the media type.

  • format_iri – An optional IRI identifying the representation format.

  • byte_size – The optional representation size in bytes.

  • sha256 – The optional lowercase SHA-256 digest.

id: str | None = None[source]
access_url: str | None = None[source]
media_type_iri: str | None = None[source]
format_iri: str | None = None[source]
byte_size: int | None = None[source]
sha256: str | None = None[source]
classmethod create(obj)[source]

Coerce a distribution instance or exact-field mapping.

Parameters:

obj (DatasetDistribution | Mapping[str, Any]) – A distribution instance or a mapping of distribution fields.

Returns:

The existing or newly constructed distribution.

Raises:
  • TypeError – If obj is neither a distribution nor a mapping.

  • ValueError – If the mapping has unknown or invalid fields.

Return type:

Self

class httk.core.datasets.Dataset[source]

Describe one published dataset independently of a transport or provider.

id and publisher_id are absolute IRIs. The remaining fields are human-readable metadata and retain their supplied text exactly.

Parameters:
  • id – The dataset’s absolute IRI.

  • title – The dataset’s human-readable title.

  • description – A non-empty description of the dataset.

  • publisher_id – The publisher’s absolute IRI.

  • publisher_name – The publisher’s human-readable name.

  • distributions – The dataset’s retrievable representations.

id: str[source]
title: str[source]
description: str[source]
publisher_id: str[source]
publisher_name: str[source]
distributions: tuple[DatasetDistribution, Ellipsis] = ()[source]
classmethod create(obj)[source]

Coerce a mapping or existing dataset into a Dataset.

Parameters:

obj (Dataset | Mapping[str, Any]) – A dataset instance or a mapping with exactly the dataset fields.

Returns:

The existing or newly constructed dataset.

Raises:
  • TypeError – If obj is neither a dataset nor a mapping.

  • ValueError – If the mapping has missing, unknown, or invalid fields.

Return type:

Self

class httk.core.datasets.DatasetRecord[source]

Bases: Dataset

Store one Dataset using the core dataset storage contract.

Parameters:
  • id – The dataset’s absolute IRI.

  • title – The dataset’s human-readable title.

  • description – A non-empty description of the dataset.

  • publisher_id – The publisher’s absolute IRI.

  • publisher_name – The publisher’s human-readable name.

  • distributions – The dataset’s retrievable representations.

classmethod create(obj)[source]

Coerce a dataset record, neutral dataset, or field mapping.

Parameters:

obj (DatasetRecord | Dataset | Mapping[str, Any]) – A dataset record, neutral dataset, or exact-field mapping.

Returns:

The existing or newly constructed dataset record.

Raises:
  • TypeError – If obj is not a dataset or mapping.

  • ValueError – If the mapping has unknown, missing, or invalid fields.

Return type:

Self