From 67d54af68fd6f1ea083fc2efb56ee985ae40e2e9 Mon Sep 17 00:00:00 2001 From: Patil Date: Thu, 7 Jul 2022 13:33:37 +0530 Subject: [PATCH] feat: group comparisons feat: group comparisons --- popmon/visualization/histogram_section.py | 3 +- popmon/visualization/section_generator.py | 41 +++++++++++++------ .../templates/assets/css/custom-style.css | 5 +++ popmon/visualization/templates/section.html | 13 ++++++ 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/popmon/visualization/histogram_section.py b/popmon/visualization/histogram_section.py index 624a4863..d7d452db 100644 --- a/popmon/visualization/histogram_section.py +++ b/popmon/visualization/histogram_section.py @@ -159,7 +159,7 @@ def transform(self, data_obj: dict, sections: Optional[list] = None): plot_type_layouts["heatmap"] = hplots[0]["layout"] plots = hplots + plots - # print(plot_types,layouts) + features_w_metrics.append( { "name": feature, @@ -167,6 +167,7 @@ def transform(self, data_obj: dict, sections: Optional[list] = None): "plots": plots, } ) + sections.append( { "section_title": self.section_name, diff --git a/popmon/visualization/section_generator.py b/popmon/visualization/section_generator.py index 04d49907..1ebcbf35 100644 --- a/popmon/visualization/section_generator.py +++ b/popmon/visualization/section_generator.py @@ -26,9 +26,8 @@ from popmon.analysis.comparison import Comparisons from popmon.analysis.profiling import Profiles - from ..base import Module -from ..config import Report +from ..config import Report, Settings, Comparison from ..utils import filter_metrics, parallel, short_date from ..visualization.utils import _prune, plot_bars @@ -126,13 +125,12 @@ def __init__( self.skip_empty_plots = settings.skip_empty_plots self.description = description self.show_stats = settings.show_stats if not settings.extended_report else None - self.primary_color = settings.primary_color self.tl_colors = settings.tl_colors def get_description(self): return self.section_name - + def transform( self, data_obj: dict, @@ -204,14 +202,33 @@ def transform( del layouts["shapes"] if "range" in layouts["yaxis"]: del layouts["yaxis"]["range"] - - features_w_metrics.append( - { - "name": feature, - "plot_type_layouts": {"barplot": layouts}, - "plots": sorted(plots, key=lambda plot: plot["name"]), - } - ) + + + if(self.section_name == "Comparisons"): + prev_key = "Rolling Reference " + "(window = " + str(Comparison().window) + ", Shift = " + str(Comparison().shift) + ")" + reference_key = Settings().reference_type + " Reference" + grouped_metrics = {reference_key: [], prev_key:[]} + for plot in plots: + if "ref" in plot["name"]: + grouped_metrics[reference_key].append(plot) + else : + grouped_metrics[prev_key].append(plot) + + features_w_metrics.append( + { + "name": feature, + "plot_type_layouts": {"barplot": layouts}, + "plots": grouped_metrics, + } + ) + else: + features_w_metrics.append( + { + "name": feature, + "plot_type_layouts": {"barplot": layouts}, + "plots": plots, + } + ) sections.append( { diff --git a/popmon/visualization/templates/assets/css/custom-style.css b/popmon/visualization/templates/assets/css/custom-style.css index 2dab39c0..955082a7 100644 --- a/popmon/visualization/templates/assets/css/custom-style.css +++ b/popmon/visualization/templates/assets/css/custom-style.css @@ -14,6 +14,11 @@ section { padding: 70px 0 } +h3 { + width: calc(100% - 100px); + margin: 20px 20px 20px 20px; +} + a.nav-link { cursor: pointer; font-weight: 300; diff --git a/popmon/visualization/templates/section.html b/popmon/visualization/templates/section.html index 11a7f059..5652a98f 100644 --- a/popmon/visualization/templates/section.html +++ b/popmon/visualization/templates/section.html @@ -30,12 +30,25 @@

{{ section_title }}

{%- endfor -%}
+ {%- if feature.plots is mapping -%} + {%- for ref,plots in feature.plots.items() -%} + {%- set count = (plots|length + 1)*(loop.index - 1) -%} +

{{ref}}

+ {%- for metric in plots -%} + {%- set plt = count + loop.index -%} + {%- with metric=metric -%} + {%- include 'card.html' -%} + {%- endwith -%} + {%- endfor -%} + {%- endfor -%} + {%- else -%} {%- for metric in feature.plots -%} {%- set plt = loop.index -%} {%- with metric=metric -%} {%- include 'card.html' -%} {%- endwith -%} {%- endfor -%} + {%- endif-%}
{%- endfor -%} {%- else -%}