Skip to content

pudl_diff.datapackage

The parts of a PUDL datapackage descriptor that the tool reads.

A datapackage descriptor is a JSON file describing the tables of a dataset. These types say what the tool relies on in it, and nothing more: PUDL's descriptors have many more fields, which are ignored.

Datapackage

Bases: TypedDict

A dataset's descriptor, of its tables and where the dataset came from.

Source code in src/pudl_diff/datapackage.py
class Datapackage(TypedDict):
    """A dataset's descriptor, of its tables and where the dataset came from."""

    resources: NotRequired[list[Resource]]
    """The dataset's tables."""
    id: NotRequired[str]
    """The dataset's build UUID."""
    created: NotRequired[str]
    """UTC ISO-8601 timestamp of when the dataset was built."""
    git_sha: NotRequired[str]
    """The git commit SHA of the PUDL code that built the dataset."""
    git_tags: NotRequired[list[str]]
    """The git tags on that commit."""

created instance-attribute

UTC ISO-8601 timestamp of when the dataset was built.

git_sha instance-attribute

The git commit SHA of the PUDL code that built the dataset.

git_tags instance-attribute

The git tags on that commit.

id instance-attribute

The dataset's build UUID.

resources instance-attribute

The dataset's tables.

Field

Bases: TypedDict

A column of a table.

Source code in src/pudl_diff/datapackage.py
class Field(TypedDict):
    """A column of a table."""

    name: str
    """The column's name."""

name instance-attribute

The column's name.

Resource

Bases: TypedDict

A table of the dataset.

Source code in src/pudl_diff/datapackage.py
class Resource(TypedDict):
    """A table of the dataset."""

    name: str
    """The table's name, which is also the name of its Parquet file."""
    schema: TableSchema
    """The table's columns, and its primary key."""

name instance-attribute

The table's name, which is also the name of its Parquet file.

schema instance-attribute

The table's columns, and its primary key.

TableSchema

Bases: TypedDict

The columns of a table, and its primary key.

Source code in src/pudl_diff/datapackage.py
class TableSchema(TypedDict):
    """The columns of a table, and its primary key."""

    fields: list[Field]
    """The table's columns, in order."""
    primaryKey: NotRequired[list[str]]
    """The names of the columns that uniquely identify a row, if it has any."""

fields instance-attribute

The table's columns, in order.

primaryKey instance-attribute

The names of the columns that uniquely identify a row, if it has any.