Skip to content

Commit

Permalink
Improve determinism by returning stable sort order of dashboard results
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jan 22, 2022
1 parent 6961fc6 commit 1a8aeab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,7 @@ grafana-wtf changelog
in progress
===========
- Prepare test suite for testing two different dashboard schema versions, v27 and v33
- Improve determinism by returning stable sort order of dashboard results

2021-12-11 0.12.0
=================
Expand Down
5 changes: 4 additions & 1 deletion grafana_wtf/core.py
Expand Up @@ -193,6 +193,9 @@ def scan_dashboards(self, dashboard_uids=None):
if self.progressbar:
self.taqadum.close()

# Improve determinism by returning stable sort order.
self.data.dashboards = munchify(sorted(self.data.dashboards, key=lambda x: x["dashboard"]["uid"]))

return self.data.dashboards

def handle_grafana_error(self, ex):
Expand All @@ -207,7 +210,7 @@ def handle_grafana_error(self, ex):
def fetch_dashboard(self, dashboard_info):
log.debug(f'Fetching dashboard "{dashboard_info["title"]}" ({dashboard_info["uid"]})')
dashboard = self.grafana.dashboard.get_dashboard(dashboard_info["uid"])
self.data.dashboards.append(munchify(dashboard))
self.data.dashboards.append(dashboard)
if self.taqadum is not None:
self.taqadum.update(1)

Expand Down

0 comments on commit 1a8aeab

Please sign in to comment.