diff --git a/dashboards/dashboard_base.py b/dashboards/dashboard_base.py index 67041a19a04b2371736759297dbbeb358dfba4cd..7140368eb260d1ee2ccdfd826e1dc4933cb99954 100644 --- a/dashboards/dashboard_base.py +++ b/dashboards/dashboard_base.py @@ -1,9 +1,9 @@ from dataclasses import asdict, dataclass from typing import List, Union -from grafanalib.core import (Annotations, Dashboard, GridPos, Panel, Repeat, - RowPanel, Stat, Template, Templating, Time, - TimeSeries, Threshold, DashboardList) +from grafanalib.core import (Annotations, Dashboard, DashboardList, GridPos, + Panel, Repeat, RowPanel, Stat, Template, + Templating, Threshold, Time, TimeSeries) from grafanalib.influxdb import InfluxDBTarget from dashboards.annotations import Annotation @@ -66,6 +66,7 @@ def build_row_repeat_dashboard( measurment_name: str, panel_query: Query, unit: str, + axisLabel: str, other_vars: List[Template] = [], annotations: Annotations = Annotations(), ) -> Dashboard: @@ -81,7 +82,8 @@ def build_row_repeat_dashboard( dataSource=dataSource, targets=[get_influx_target(str(panel_query))], repeat=Repeat('h', panel_repeat_var.name), - axisLabel=unit, + unit=unit, + axisLabel=axisLabel, pointSize=9, ), ], diff --git a/dashboards/dashboard_list.py b/dashboards/dashboard_list.py index cf6c82cfb8e3dea98e1f477889cb4486d4a5616a..d4a1dba8efe8d559750b9e9568a98a7a260dd706 100644 --- a/dashboards/dashboard_list.py +++ b/dashboards/dashboard_list.py @@ -3,14 +3,14 @@ from typing import List from dashboards.dashboard_base import (DashboardOptions, build_dashboard, build_row_repeat_dashboard, get_commit_annotation, + get_dashboard_list, get_dashboard_variable_query, get_grid_pos, get_stat_panel, - pack_in_row, - get_dashboard_list) + pack_in_row) from dashboards.influx_queries import (Query, get_variable_condition, join_conditions, join_variable_and, show_tag_values) -from dashboards.units import Units +from dashboards.legends import AxisLabel, Units def _uniform_grid(arch: str, group_by: List[str]): @@ -18,7 +18,8 @@ def _uniform_grid(arch: str, group_by: List[str]): measurment_name = f'UniformGrid{arch}' row_repeat = "collisionSetup" panel_repeat = "host" - unit = Units.mlups + unit = Units.number + axisLabel = AxisLabel.mlups row_repeat_var = get_dashboard_variable_query( row_repeat, show_tag_values(measurment_name, row_repeat), dataSource) @@ -43,9 +44,14 @@ def _uniform_grid(arch: str, group_by: List[str]): annotations = get_commit_annotation("InfluxDB-1", "red", "commits", measurment_name) - return build_row_repeat_dashboard(options, row_repeat_var, - panel_repeat_var, dataSource, - measurment_name, query, unit, + return build_row_repeat_dashboard(options, + row_repeat_var, + panel_repeat_var, + dataSource, + measurment_name, + query, + unit, + axisLabel, [cellsPerBlock_var], annotations=annotations) @@ -96,6 +102,7 @@ def dashboard_granular_gas(): row_repeat = "kernel" panel_repeat = "host" unit = Units.milliseconds + axisLabel = AxisLabel.runtime row_repeat_var = get_dashboard_variable_query( row_repeat, f"SHOW FIELD KEYS FROM {measurment_name}", dataSource) @@ -117,7 +124,7 @@ def dashboard_granular_gas(): measurment_name) return build_row_repeat_dashboard(options, row_repeat_var, panel_repeat_var, dataSource, - measurment_name, query, unit, + measurment_name, query, unit, axisLabel, annotations=annotations) @@ -126,7 +133,8 @@ def dashboard_phasefieldallenchan(): measurment_name = 'PhaseFieldAllenCahn' row_repeat = "cellsPerBlock_0" panel_repeat = "host" - unit = Units.mlups + unit = Units.number + axisLabel = AxisLabel.mlups options = DashboardOptions( title='Phase Field Allen Chan', @@ -162,7 +170,7 @@ def dashboard_phasefieldallenchan(): measurment_name) dashboard = build_row_repeat_dashboard(options, row_repeat_var, panel_repeat_var, dataSource, - measurment_name, query, unit, + measurment_name, query, unit, axisLabel, annotations=annotations) dashboard.rows = [ pack_in_row("Power Consumption", panel_power), *dashboard.rows @@ -175,7 +183,8 @@ def dashboard_phasefieldallenchangpu(): measurment_name = 'PhaseFieldAllenCahnGPU' row_repeat = "cellsPerBlock_0" panel_repeat = "host" - unit = Units.mlups + unit = Units.number + axisLabel = AxisLabel.mlups options = DashboardOptions( title='Phase Field Allen Chan GPU', @@ -200,9 +209,14 @@ def dashboard_phasefieldallenchangpu(): annotations = get_commit_annotation("InfluxDB-1", "red", "commits", measurment_name) - return build_row_repeat_dashboard(options, row_repeat_var, - panel_repeat_var, dataSource, - measurment_name, query, unit, + return build_row_repeat_dashboard(options, + row_repeat_var, + panel_repeat_var, + dataSource, + measurment_name, + query, + unit, + axisLabel, annotations=annotations) diff --git a/dashboards/units.py b/dashboards/legends.py similarity index 62% rename from dashboards/units.py rename to dashboards/legends.py index ac2aae56008e68f8d5081bfb5b2357bc59712285..b9d6c9babb03871e4bc7dab19976bfa64ad98548 100644 --- a/dashboards/units.py +++ b/dashboards/legends.py @@ -2,6 +2,11 @@ from enum import Enum class Units(str, Enum): - mlups = 'MLUPS per process' seconds = 's' milliseconds = 'ms' + number = 'none' + + +class AxisLabel(str, Enum): + mlups = 'MLUPS per process' + runtime = 'Runtime' diff --git a/tests/test_dashboard_creation.py b/tests/test_dashboard_creation.py index 9e6c1d6fed504093b4762fd9e6e74a59a1fb873e..146ed7a0612d591f9e45729644f09fad2ec08f6d 100644 --- a/tests/test_dashboard_creation.py +++ b/tests/test_dashboard_creation.py @@ -1,9 +1,9 @@ from grafanalib.core import (Dashboard, Repeat, RowPanel, Templating, Time, TimeSeries) -from dashboards.dashboard_base import (get_dashboard_variable_query, - get_influx_target, - get_commit_annotation) +from dashboards.dashboard_base import (get_commit_annotation, + get_dashboard_variable_query, + get_influx_target) from dashboards.dashboard_list import dashboard_uniformGridGPU from dashboards.influx_queries import Query, show_tag_values @@ -63,6 +63,7 @@ dashboard = Dashboard( get_influx_target(str(q1)) ], repeat=Repeat('h', host_var.name), + unit='none', axisLabel='MLUPS per process', pointSize=9, ), diff --git a/tests/test_units.py b/tests/test_units.py index c3ff1e020b983217a360d6df84621fb0f838eeb3..c42f28845372fc410583fd2000ecf6e46f70c9f7 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -1,5 +1,11 @@ -from dashboards.units import Units +from dashboards.legends import AxisLabel, Units def test_units(): - assert Units.mlups == 'MLUPS per process' + assert Units.seconds == 's' + assert Units.milliseconds == 'ms' + + +def test_labels(): + assert AxisLabel.mlups == 'MLUPS per process' + assert AxisLabel.runtime == 'Runtime'