watchful.enricher module

This script provides the abstract Enricher class interface to be inherited in your custom enricher class, where you can then implement your custom data enrichment functions and models within enrich_row(). Refer to https://github.com/Watchfulio/watchful-py/blob/main/examples/enrichment_intro.ipynb for a tutorial on how to implement your custom enricher class.

class watchful.enricher.Enricher[source]

Bases: object

This is the abstract class that customized enricher classes should inherit, and then implement the abstract methods __init__() and enrich_row().

abstract enrich_row(row: Dict[str | None, str | None]) List[List[Tuple[List[Tuple[int]] | Dict[str, List[str]] | str | None]]][source]

In this method, we use our variables from self.enrichment_args initialized in __init__() to enrich our data, row by row. The return value is our enriched row. This enrich_row() method needs to be implemented in your enricher class.

Parameters:

row (Dict[Optional[str], Optional[str]]) – A dictionary containing string keys as the column names and string values as the cell values, one for each cell of the row; the rows are read using csv.reader on a csv file representing the dataset.

Returns:

A list of attributes.EnrichedCell containing the attributes for each cell, for the entire row.

Return type:

List[attributes.EnrichedCell]

classmethod is_enricher(possibly_an_enricher: Generic[T]) bool[source]

This is a convenience method used for checking if possibly_an_enricher is indeed of the Enricher class.

Parameters:

possibly_an_enricher (Class) – A class that is possibly of the Enricher class.

Returns:

A boolean indicating if possibly_an_enricher is indeed of the Enricher class.

Return type:

bool