LineageTree#

The LineageTree class is used by the Lineage API for describing lineage trees of datasets.

..note:

Only the postgis index driver supports the Lineage API.

class datacube.model.LineageDirection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Enumeration specifying the direction sense of a LineageTree (source-ward or derived-ward)

  • SOURCES indicates a lineage tree that contains the source datasets of the root node

  • DERIVED indicates a lineage tree that contains the derived datasets of the root node

class datacube.model.LineageTree(direction, dataset_id, children=None, home=None)[source]#

A node in a Dataset Lineage tree.

  • direction (LineageDirection): Whether this is a node in a source tree or a derived tree

  • dataset_id (UUID): The dataset id associated with this node

  • children (Optional[Mapping[str, Sequence[LineageTree]]]):

    An optional mapping of lineage nodes of the same direction as this node. The keys of the mapping are classifier strings. children=None means that there may be children in the database. children={} means there are no children in the database. children represent source datasets or derived datasets depending on the direction.

home (Optional[str]):

The home index associated with this node’s dataset. Optional. Index drivers may not implement a home table, in which case this value will always be None.

find_subtree(dsid, _state=None)[source]#

Finds subtree with root at dsid, if there is one.

Immediately returns the first match found with not-None children, but keeps track of first children=None match to return if no not-None matches.

Parameters:
Return type:

Optional[LineageTree]

Returns:

None, or the subtree with root at dsid.

classmethod from_data(dsid, sources=None, direction=LineageDirection.SOURCES, home=None, home_derived=None)[source]#

Generate a shallow (depth=1) LineageTree from the sort of data found in an EO3 dataset

Parameters:
  • dsid (UUID) – The (derived) dataset id

  • sources (Optional[Mapping[str, Sequence[UUID]]]) – A dictionary of classifiers to list of source IDs

  • direction (LineageDirection) – Tree direction (default SOURCEwards, as per an EO3 dataset)

  • home (str | None) – Home database for source datasets (defaults to None).

  • home_derived (str | None) – Home database for the derived dataset (defaults to None).

Return type:

LineageTree

Returns:

A depth==1 LineageTree

classmethod from_eo3_doc(doc, home=None, home_derived=None)[source]#

Generate a shallow (depth=1) LineageTree from an EO3 dataset document

Parameters:
  • doc (Mapping[str, Any]) – The dataset metadata dictionary

  • home – Home database for source datasets (defaults to None).

  • home_derived – Home database for the derived dataset (defaults to None).

Return type:

LineageTree

Returns:

A depth==1 LineageTree