popmon.visualization package

Submodules

popmon.visualization.alert_section_generator module

class popmon.visualization.alert_section_generator.AlertSectionGenerator(read_key, store_key, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None)

Bases: Module

This module takes the time-series data of already computed statistics, plots the data and combines all the plots into a list which is stored together with the section name in a dictionary which later will be used for the report generation.

__init__(read_key, store_key, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None)

Initialize an instance of SectionGenerator.

Parameters
  • read_key (str) – key of input data to read from the datastore and use for plotting

  • store_key (str) – key for output data to be stored in the datastore

  • features (list) – list of features to pick up from input data (optional)

  • ignore_features (list) – ignore list of features, if present (optional)

  • static_bounds (str) – key to static traffic light bounds key in datastore (optional)

  • dynamic_bounds (str) – key to dynamic traffic light bounds key in datastore (optional)

  • prefix (str) – dynamic traffic light prefix. default is 'traffic_light_' (optional)

  • suffices (str) – dynamic traffic light suffices. (optional)

  • ignore_stat_endswith (list) – ignore stats ending with any of list of suffices. (optional)

transform(data_obj, static_bounds=None, dynamic_bounds=None, sections=None)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.visualization.histogram_section module

class popmon.visualization.histogram_section.HistogramSection(read_key, store_key, reference_type, settings, features=None, ignore_features=None, hist_names=None, hist_name_starts_with='histogram')

Bases: Module

This module plots histograms of all selected features for the last ‘n’ periods.

__init__(read_key, store_key, reference_type, settings, features=None, ignore_features=None, hist_names=None, hist_name_starts_with='histogram')

Initialize an instance of SectionGenerator.

Parameters
  • read_key (str) – key of input data to read from the datastore and use for plotting

  • store_key (str) – key for output data to be stored in the datastore

  • features (list) – list of features to pick up from input data (optional)

  • ignore_features (list) – ignore list of features, if present (optional)

  • hist_names (list) – list of histogram names to plot

  • hist_name_starts_with (str) – find histograms in case hist_names is empty. default is histogram.

transform(data_obj, sections=None)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.visualization.overview_section module

class popmon.visualization.overview_section.OverviewSectionGenerator(read_key, store_key, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None)

Bases: Module

This module takes the time-series data of already computed statistics, plots the data and combines all the plots into a list which is stored together with the section name in a dictionary which later will be used for the report generation.

__init__(read_key, store_key, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None)

Initialize an instance of SectionGenerator.

Parameters
  • read_key (str) – key of input data to read from the datastore and use for plotting

  • store_key (str) – key for output data to be stored in the datastore

  • features (list) – list of features to pick up from input data (optional)

  • ignore_features (list) – ignore list of features, if present (optional)

  • static_bounds (str) – key to static traffic light bounds key in datastore (optional)

  • dynamic_bounds (str) – key to dynamic traffic light bounds key in datastore (optional)

  • prefix (str) – dynamic traffic light prefix. default is 'traffic_light_' (optional)

  • suffices (str) – dynamic traffic light suffices. (optional)

  • ignore_stat_endswith (list) – ignore stats ending with any of list of suffices. (optional)

transform(data_obj, dynamic_bounds=None, sections=None)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.visualization.report_generator module

class popmon.visualization.report_generator.ReportGenerator(read_key, store_key, settings)

Bases: Module

This module takes already prepared section data, renders HTML section template with the data and glues sections together into one compressed report which is created based on the provided template.

__init__(read_key, store_key, settings)

Initialize an instance of ReportGenerator.

Parameters
  • read_key (str) – key of input sections data to read from the datastore

  • store_key (str) – key for storing the html report code in the datastore

Para bool online_report

if false (default), the plotly.js code is included in the html report, else the report takes js code from cdn server which requires internet connection

transform(sections)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.visualization.section_generator module

class popmon.visualization.section_generator.SectionGenerator(read_key, store_key, section_name, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None, description='')

Bases: Module

This module takes the time-series data of already computed statistics, plots the data and combines all the plots into a list which is stored together with the section name in a dictionary which later will be used for the report generation.

__init__(read_key, store_key, section_name, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None, description='')

Initialize an instance of SectionGenerator.

Parameters
  • read_key (str) – key of input data to read from the datastore and use for plotting

  • store_key (str) – key for output data to be stored in the datastore

  • section_name (str) – key of output data to store in the datastore

  • features (list) – list of features to pick up from input data (optional)

  • ignore_features (list) – ignore list of features, if present (optional)

  • static_bounds (str) – key to static traffic light bounds key in datastore (optional)

  • dynamic_bounds (str) – key to dynamic traffic light bounds key in datastore (optional)

  • prefix (str) – dynamic traffic light prefix. default is 'traffic_light_' (optional)

  • suffices (str) – dynamic traffic light suffices. (optional)

  • ignore_stat_endswith (list) – ignore stats ending with any of list of suffices. (optional)

  • description (str) – description of the section. default is empty (optional)

transform(data_obj, static_bounds=None, dynamic_bounds=None, sections=None)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.visualization.section_generator.get_stat_description(name)

Gets the description of a statistic.

Parameters

name (str) – the name of the statistic.

Returns str

the description of the statistic. If not found, returns an empty string

popmon.visualization.traffic_light_section_generator module

class popmon.visualization.traffic_light_section_generator.TrafficLightSectionGenerator(read_key, store_key, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None)

Bases: Module

This module takes the time-series data of already computed statistics, plots the data and combines all the plots into a list which is stored together with the section name in a dictionary which later will be used for the report generation.

__init__(read_key, store_key, settings, features=None, ignore_features=None, static_bounds=None, dynamic_bounds=None, prefix='traffic_light_', suffices=['_red_high', '_yellow_high', '_yellow_low', '_red_low'], ignore_stat_endswith=None)

Initialize an instance of SectionGenerator.

Parameters
  • read_key (str) – key of input data to read from the datastore and use for plotting

  • store_key (str) – key for output data to be stored in the datastore

  • features (list) – list of features to pick up from input data (optional)

  • ignore_features (list) – ignore list of features, if present (optional)

  • static_bounds (str) – key to static traffic light bounds key in datastore (optional)

  • dynamic_bounds (str) – key to dynamic traffic light bounds key in datastore (optional)

  • prefix (str) – dynamic traffic light prefix. default is 'traffic_light_' (optional)

  • suffices (str) – dynamic traffic light suffices. (optional)

  • ignore_stat_endswith (list) – ignore stats ending with any of list of suffices. (optional)

transform(data_obj, dynamic_bounds=None, sections=None)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.visualization.utils module

popmon.visualization.utils.hex_to_rgb(h)

Takes a hex rgb string and returns an RGB tuple.

popmon.visualization.utils.plot_bars(data, labels, bounds, ylim, primary_color, tl_colors, metric)

Plotting histogram data.

Parameters
  • data (numpy.ndarray) – bin values of a histogram

  • labels (List[str]) – common bin labels for all histograms. default is None.

  • bounds (tuple) – traffic light bounds (y-coordinates). default is None.

  • ylim (bool) – place y-axis limits for zooming into the data. default is False.

Returns

JSON plot image

Return type

str

popmon.visualization.utils.plot_heatmap(hist_values, hist_bins, date, x_label, hist_name, y_label, is_num=False, is_ts=False, cmap='ylorrd', top=20)

Create and plot heatmap of column values.

Copyright Eskapade: Kindly taken from Eskapade package and then modified. Reference link: https://github.com/KaveIO/Eskapade/blob/master/python/eskapade/visualization/vis_utils.py#L397 License: https://github.com/KaveIO/Eskapade-Core/blob/master/LICENSE Modifications copyright ING WBAA.

Parameters
  • hist_values (list) – values of heatmap in a 2d numpy array =

  • hist_bins (list) – bin labels/edges on y-axis

  • date (list) – dates for x/time axis of heatmap

  • x_label (str) – Label for heatmap x-axis

  • hist_names (list) – list of histogram names. default is [].

  • y_label (str) – Label for histogram y-axis. default is None.

  • is_num (bool) – True if observable to plot is numeric. default is True.

  • is_ts (bool) – True if observable to plot is a timestamp. default is False.

  • top (int) – only print the top 20 characters of x-labels and y-labels. default is 20.

  • cmap (str) – the colormap for heatmap. default is ylorrd.

Returns

base64 encoded plot image

Return type

str

popmon.visualization.utils.plot_histogram_overlay(plots=[], is_num=True, is_ts=False, is_static_reference=True, top=20, n_choices=2)

Create and plot (overlapping/grouped) histogram(s) of column values.

Copyright Eskapade: Kindly taken from Eskapade package and then modified. Reference link: https://github.com/KaveIO/Eskapade/blob/master/python/eskapade/visualization/vis_utils.py#L397 License: https://github.com/KaveIO/Eskapade-Core/blob/master/LICENSE Modifications copyright ING WBAA.

Parameters
  • plots (list) – list of dicts containing histograms for all timestamps :param bool is_num: True if observable to plot is numeric. default is True. :param bool is_ts: True if observable to plot is a timestamp. default is False.

  • is_static_reference (bool) – True if the reference is static. default is True

  • top (int) – only print the top 20 characters of x-labels and y-labels. default is 20.

  • n_choices (int) – number of plots to compare at once

Returns

JSON encoded plot image

Return type

str

popmon.visualization.utils.xtick(lab, top)

Get x-tick.