ssb_timeseries.types

Type aliases and series types used across ssb_timeseries.

The definitions live in the submodules series (versioning, temporality and SeriesType) and metadata (name and tag aliases). They are re-exported here so that from ssb_timeseries.types import … keeps working for both internal and external code.

DatasetName

alias of str

class DatasetTags

Bases: TypedDict

A dictionary representing the full dataset metadata, including ‘series’.

The five declared keys are mandatory; additional tags are allowed, but their values must be tag values.

name: str
repository: str
series: dict[str, dict[str, str | list[str]]]
temporality: Temporality | str
versioning: Versioning | str
F

alias of Callable

RepositoryName

alias of str

SeriesName

alias of str

class SeriesType(versioning, temporality)

Bases: object

SeriesTypes are defined by combinations of attributes that have technical implications for time series datasets.

Notable examples are Versioning and Temporality, but a few more may be added later.

Parameters:
__repr__()

Reconstructable representation, sufficient to recreate the value.

Return type:

str

__str__()

Canonical spelling, also used as the persisted directory name.

Return type:

str

property date_columns: list[str]

Returns the date columns for the series type.

classmethod from_name(name)

Return the SeriesType with the given canonical name, ignoring case.

The canonical names are the persisted spellings, for example ‘NONE_AT’.

Return type:

SeriesType

Parameters:

name (str)

classmethod from_tag_values(versioning, temporality)

Return the SeriesType stored as the ‘versioning’ and ‘temporality’ tag values.

Return type:

SeriesType

Parameters:
temporality: Temporality
versioning: Versioning
TagKey

alias of str

class Temporality(*values)

Bases: Enum

Temporality describes the time dimensionality of each data point: a single point in time or a period.

AT = 1

Single points in time, expressed with (exact) ‘valid_at’ dates.

FROM_TO = 2

Duration periods, expressed with ‘valid_from’ (inclusive) and ‘valid_to’ (exclusive) dates.

property date_columns: list[str]

Returns the date columns of the temporality.

class Versioning(*values)

Bases: Enum

Versioning refers to how revisions of data are identified (named).

AS_OF = 1

Version identified by dates allows date arithemetic (‘equals’ | ‘greater than’ | ‘smaller than’ | ‘between’).

NAMES = 2

Versions identified by free text names.

This functionality is under consideration, hence preparepared in the type system, but with not all the way through IO and core modules.

NONE = 0

Version control only. Versions are not accessible through API.

property date_columns: list[str]

Returns the date columns for versioning.

Type Helper Modules