diff options
author | Tibor Frank <tifrank@cisco.com> | 2022-09-14 15:14:25 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2022-09-14 15:14:25 +0200 |
commit | 69fd124979890cac21bd0dbc7ef442563f175372 (patch) | |
tree | 8db6abea93c7daff4c3766413cc31c889a73d017 /resources/tools/dash/app/pal/stats | |
parent | 8ce2df561b011243f9138332058945e957d48d63 (diff) |
UTI: Remove datepicker, unify font sizes
Change-Id: I074425dbfe46c6411b2e04cd9c36d20f60a3f4de
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/dash/app/pal/stats')
-rw-r--r-- | resources/tools/dash/app/pal/stats/graphs.py | 24 | ||||
-rw-r--r-- | resources/tools/dash/app/pal/stats/layout.py | 86 | ||||
-rw-r--r-- | resources/tools/dash/app/pal/stats/layout.yaml | 38 |
3 files changed, 18 insertions, 130 deletions
diff --git a/resources/tools/dash/app/pal/stats/graphs.py b/resources/tools/dash/app/pal/stats/graphs.py index 42f23da5aa..f533d72aa8 100644 --- a/resources/tools/dash/app/pal/stats/graphs.py +++ b/resources/tools/dash/app/pal/stats/graphs.py @@ -17,37 +17,27 @@ import plotly.graph_objects as go import pandas as pd -from datetime import datetime, timedelta -def select_data(data: pd.DataFrame, itm:str, start: datetime, - end: datetime) -> pd.DataFrame: +def select_data(data: pd.DataFrame, itm:str) -> pd.DataFrame: """Select the data for graphs from the provided data frame. :param data: Data frame with data for graphs. :param itm: Item (in this case job name) which data will be selected from the input data frame. - :param start: The date (and time) when the selected data starts. - :param end: The date (and time) when the selected data ends. :type data: pandas.DataFrame :type itm: str - :type start: datetime.datetime - :type end: datetime.datetime :returns: A data frame with selected data. :rtype: pandas.DataFrame """ - df = data.loc[ - (data["job"] == itm) & - (data["start_time"] >= start) & (data["start_time"] <= end) - ].sort_values(by="start_time", ignore_index=True) + df = data.loc[(data["job"] == itm)].sort_values( + by="start_time", ignore_index=True) df = df.dropna(subset=["duration", ]) return df -def graph_statistics(df: pd.DataFrame, job:str, layout: dict, - start: datetime=datetime.utcnow()-timedelta(days=180), - end: datetime=datetime.utcnow()) -> tuple: +def graph_statistics(df: pd.DataFrame, job:str, layout: dict) -> tuple: """Generate graphs: 1. Passed / failed tests, 2. Job durations @@ -56,19 +46,15 @@ def graph_statistics(df: pd.DataFrame, job:str, layout: dict, :param df: Data frame with input data. :param job: The name of job which data will be presented in the graphs. :param layout: Layout of plot.ly graph. - :param start: The date (and time) when the selected data starts. - :param end: The date (and time) when the selected data ends. :type df: pandas.DataFrame :type job: str :type layout: dict - :type start: datetime.datetime - :type end: datetime.datetime :returns: Tuple with two generated graphs (pased/failed tests and job duration). :rtype: tuple(plotly.graph_objects.Figure, plotly.graph_objects.Figure) """ - data = select_data(df, job, start, end) + data = select_data(df, job) if data.empty: return None, None diff --git a/resources/tools/dash/app/pal/stats/layout.py b/resources/tools/dash/app/pal/stats/layout.py index 273ee23362..fa1da90a00 100644 --- a/resources/tools/dash/app/pal/stats/layout.py +++ b/resources/tools/dash/app/pal/stats/layout.py @@ -25,12 +25,12 @@ from dash import callback_context, no_update from dash import Input, Output, State from dash.exceptions import PreventUpdate from yaml import load, FullLoader, YAMLError -from datetime import datetime, timedelta +from datetime import datetime from copy import deepcopy from ..utils.constants import Constants as C -from ..utils.utils import show_tooltip, gen_new_url, get_date, get_ttypes, \ - get_cadences, get_test_beds, get_job, generate_options, set_job_params +from ..utils.utils import show_tooltip, gen_new_url, get_ttypes, get_cadences, \ + get_test_beds, get_job, generate_options, set_job_params from ..utils.url_processing import url_decode from ..data.data import Data from .graphs import graph_statistics, select_data @@ -244,6 +244,7 @@ class Layout: if self.html_layout: return html.Div( id="div-main", + className="small", children=[ dcc.Store(id="control-panel"), dcc.Location(id="url", refresh=False), @@ -499,30 +500,6 @@ class Layout: children=self.default["job"] ) ] - ), - dbc.Row( - class_name="g-0 p-2", - children=[ - dbc.Label( - class_name="gy-1", - children=show_tooltip(self._tooltips, - "help-time-period", "Time Period"), - ), - dcc.DatePickerRange( - id="dpr-period", - className="d-flex justify-content-center", - min_date_allowed=\ - datetime.utcnow() - timedelta( - days=self.time_period), - max_date_allowed=datetime.utcnow(), - initial_visible_month=datetime.utcnow(), - start_date=\ - datetime.utcnow() - timedelta( - days=self.time_period), - end_date=datetime.utcnow(), - display_format="D MMM YY" - ) - ] ) ] ), @@ -552,10 +529,7 @@ class Layout: "ri-ttypes-value": default["ttype"], "ri-cadences-value": default["cadence"], "dd-tbeds-value": default["tbed"], - "al-job-children": default["job"], - "dpr-start-date": datetime.utcnow() - \ - timedelta(days=C.TIME_PERIOD), - "dpr-end-date": datetime.utcnow() + "al-job-children": default["job"] } self._panel = deepcopy(self._defaults) if panel: @@ -625,19 +599,15 @@ class Layout: Output("ri-cadences", "value"), Output("dd-tbeds", "value"), Output("al-job", "children"), - Output("dpr-period", "start_date"), - Output("dpr-period", "end_date"), State("control-panel", "data"), # Store Input("ri-duts", "value"), Input("ri-ttypes", "value"), Input("ri-cadences", "value"), Input("dd-tbeds", "value"), - Input("dpr-period", "start_date"), - Input("dpr-period", "end_date"), Input("url", "href") ) def _update_ctrl_panel(cp_data: dict, dut: str, ttype: str, cadence:str, - tbed: str, start: str, end: str, href: str) -> tuple: + tbed: str, href: str) -> tuple: """Update the application when the event is detected. :param cp_data: Current status of the control panel stored in @@ -646,16 +616,12 @@ class Layout: :param ttype: Input - Test type. :param cadence: Input - The cadence of the job. :param tbed: Input - The test bed. - :param start: Date and time where the data processing starts. - :param end: Date and time where the data processing ends. :param href: Input - The URL provided by the browser. :type cp_data: dict :type dut: str :type ttype: str :type cadence: str :type tbed: str - :type start: str - :type end: str :type href: str :returns: New values for web page elements. :rtype: tuple @@ -663,9 +629,6 @@ class Layout: ctrl_panel = self.ControlPanel(cp_data, self.default) - start = get_date(start) - end = get_date(end) - # Parse the url: parsed_url = url_decode(href) if parsed_url: @@ -721,16 +684,10 @@ class Layout: ctrl_panel.set({ "dd-tbeds-value": tbed }) - elif trigger_id == "dpr-period": - pass elif trigger_id == "url": if url_params: new_job = url_params.get("job", list())[0] - new_start = url_params.get("start", list())[0] - new_end = url_params.get("end", list())[0] - if new_job and new_start and new_end: - start = get_date(new_start) - end = get_date(new_end) + if new_job: job_params = set_job_params(self.job_info, new_job) ctrl_panel = self.ControlPanel(None, job_params) else: @@ -744,26 +701,15 @@ class Layout: ctrl_panel.get("dd-tbeds-value") ) - ctrl_panel.set({ - "al-job-children": job, - "dpr-start-date": start, - "dpr-end-date": end - }) - fig_passed, fig_duration = graph_statistics(self.data, job, - self.layout, start, end) + ctrl_panel.set({"al-job-children": job}) + fig_passed, fig_duration = \ + graph_statistics(self.data, job, self.layout) ret_val = [ ctrl_panel.panel, fig_passed, fig_duration, - gen_new_url( - parsed_url, - { - "job": job, - "start": start, - "end": end - } - ) + gen_new_url(parsed_url, {"job": job}) ] ret_val.extend(ctrl_panel.values()) return ret_val @@ -771,22 +717,16 @@ class Layout: @app.callback( Output("download-data", "data"), State("control-panel", "data"), # Store - State("dpr-period", "start_date"), - State("dpr-period", "end_date"), Input("btn-download-data", "n_clicks"), prevent_initial_call=True ) - def _download_data(cp_data: dict, start: str, end: str, n_clicks: int): + def _download_data(cp_data: dict, n_clicks: int): """Download the data :param cp_data: Current status of the control panel stored in browser. - :param start: Date and time where the data processing starts. - :param end: Date and time where the data processing ends. :param n_clicks: Number of clicks on the button "Download". :type cp_data: dict - :type start: str - :type end: str :type n_clicks: int :returns: dict of data frame content (base64 encoded) and meta data used by the Download component. @@ -805,7 +745,7 @@ class Layout: ctrl_panel.get("dd-tbeds-value") ) - data = select_data(self.data, job, get_date(start), get_date(end)) + data = select_data(self.data, job) data = data.drop(columns=["job", ]) return dcc.send_data_frame( diff --git a/resources/tools/dash/app/pal/stats/layout.yaml b/resources/tools/dash/app/pal/stats/layout.yaml index 0a102e4d0a..488654640f 100644 --- a/resources/tools/dash/app/pal/stats/layout.yaml +++ b/resources/tools/dash/app/pal/stats/layout.yaml @@ -27,25 +27,6 @@ plot-stats-passed: tickcolor: "rgb(238, 238, 238)" tickmode: "auto" tickformat: "%m%d" - rangeselector: - buttons: - - count: 14 - label: "2w" - step: "day" - stepmode: "backward" - - count: 1 - label: "1m" - step: "month" - stepmode: "backward" - - count: 2 - label: "2m" - step: "month" - stepmode: "backward" - - count: 3 - label: "3m" - step: "month" - stepmode: "backward" - - step: "all" margin: r: 20 b: 5 @@ -87,25 +68,6 @@ plot-stats-duration: tickcolor: "rgb(238, 238, 238)" tickmode: "auto" tickformat: "%m%d" - rangeselector: - buttons: - - count: 14 - label: "2w" - step: "day" - stepmode: "backward" - - count: 1 - label: "1m" - step: "month" - stepmode: "backward" - - count: 2 - label: "2m" - step: "month" - stepmode: "backward" - - count: 3 - label: "3m" - step: "month" - stepmode: "backward" - - step: "all" margin: r: 20 b: 5 |