dispel.processing.data_trace module#

A module containing the data trace graph (DTG).

The data trace is a directed acyclic graph that traces the creation of the main data entities:

It links the creation of each entity with its creators.

class dispel.processing.data_trace.DataTrace[source]#

Bases: object

A class representation of the data trace graph.

__init__()[source]#
add_trace(source, result, step=None, **kwargs)[source]#

Add a single data trace to the graph.

Parameters:
Raises:

NotImplementedError – If the source and/or result types are not supported.

check_data_set_usage()[source]#

Check the usage of the raw data sets inside the data trace graph.

It means checking if all leaf nodes are dispel.data.measures.MeasureValue and raise warnings if any are found.

Returns:

The list of unused data sets.

Return type:

List[RawDataSet]

Warns:

UserWarning – If leaf entities do not correspond to measure values.

Raises:

ValueError – If a leaf node if neither a measure value nor a raw data set.

children(entity)[source]#

Get direct successors of an entity.

Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) –

Return type:

MultiAdjacencyView

property entity_count: int#

Get the entity count in the data trace graph.

Returns:

The number of entities in the data trace graph.

Return type:

int

classmethod from_reading(reading)[source]#

Initialise a data trace graph from a reading.

Parameters:

reading (Reading) – The reading associated to the data trace.

Returns:

The initialised data trace graph.

Return type:

DataTrace

get_flags(entity)[source]#

Get all flags related to the entity.

Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) – The entity whose related flags are to be retrieved.

Returns:

A list of all flags related to the entity.

Return type:

List[Flag]

get_measure_flags(entity=None)[source]#

Get all measure flags related to the entity.

If no entity is provided, the default entity is the reading and every measure flag coming from the reading will be returned.

Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch | None) – An optional entity whose related measure flags are to be retrieved, if None is provided the default entity is the root of the data trace.

Returns:

A list of all measure flags related to the entity. If no entity is provided, all measure flags are returned.

Return type:

List[Flag]

get_reading()[source]#

Get the reading associated with the data trace graph.

Return type:

Reading

has_node(entity)[source]#

Check whether a node exists in the data trace graph.

Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) – The entity of the node whose existence in the data trace graph is to be checked.

Returns:

True if the corresponding node exists inside the graph. False otherwise.

Return type:

bool

is_leaf(entity)[source]#

Determine whether the entity is a leaf.

Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) –

Return type:

bool

property leaf_count: int#

Get the leaf count of the data trace graph.

Returns:

The number of leaf nodes in the data trace graph.

Return type:

int

leaves()[source]#

Retrieve all leaves of the data trace graph.

Returns:

The leaf nodes of the data trace graph.

Return type:

Iterable[EntityType]

nodes()[source]#

Retrieve all the nodes inside the data trace graph.

Returns:

The list of nodes inside the data trace graph.

Return type:

NodeView

parents(entity)[source]#

Get direct predecessors of an entity.

Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) –

Return type:

MultiAdjacencyView

populate(entity)[source]#
populate(entity)
populate(entity)
populate(entity)
populate(entity)

Populate the data trace with the provided entity.

If the provided entity is a Reading or a Level, then the entity and its components are injected as data traces.

If the provided entities are processing results, then the associated results are added as data traces and also set inside the corresponding reading.

Parameters:

entity (Level | Reading | ProcessingResult | ProcessingControlResult | LevelProcessingControlResult) – The entity to injected inside the data trace.

Returns:

If existent, the list of exceptions to be raised at the end of the processing.

Return type:

Optional[List[Exception]]

Raises:

NotImplementedError – If the provided entity type is not supported.

property processing_step_count: int#

Get the processing steps count in the data trace graph.

Returns:

The number of different processing steps in the data trace graph.

Return type:

int

exception dispel.processing.data_trace.EdgeNotFound[source]#

Bases: Exception

Exception raised when an edge is not found in the data trace.

Parameters:
  • source – The entity corresponding to the source node of the edge in question.

  • result – The entity corresponding to the result node of the edge in question.

__init__(source, result)[source]#
Parameters:
exception dispel.processing.data_trace.GraphNoCycle[source]#

Bases: Exception

Exception raised if a cycle is to be created in the data trace graph.

Parameters:
  • source – The source node that has caused the graph cycle.

  • result – The result node that has caused the graph cycle.

__init__(source, result)[source]#
Parameters:
exception dispel.processing.data_trace.MissingSourceNode[source]#

Bases: Exception

Exception raised if the source node of a data trace is missing.

Parameters:

entity – The entity corresponding to the absent source node.

__init__(entity)[source]#
Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) –

exception dispel.processing.data_trace.NodeHasMultipleParents[source]#

Bases: Exception

Exception raised if a node is to have multiple parents.

Parameters:

entity – The entity corresponding to the exception.

__init__(entity)[source]#
Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) –

exception dispel.processing.data_trace.NodeNotFound[source]#

Bases: Exception

Exception raised when a node is not found in the data trace.

Parameters:

entity – The entity corresponding to the exception.

__init__(entity)[source]#
Parameters:

entity (Reading | Level | RawDataSet | MeasureValue | LevelEpoch) –