Skip to content
Snippets Groups Projects
Commit b859e2d4 authored by Jenkins's avatar Jenkins
Browse files

Finished release 0.84.

parents c31d9385 b3629dce
No related branches found
No related tags found
No related merge requests found
...@@ -19,15 +19,35 @@ NUM_RETRIES = 3 ...@@ -19,15 +19,35 @@ NUM_RETRIES = 3
STATIC_DASHBOARDS_DIR = pathlib.Path(__file__).parents[1] / "dashboards" STATIC_DASHBOARDS_DIR = pathlib.Path(__file__).parents[1] / "dashboards"
def list_all_dashboards(request: TokenRequest) -> Dict[str, Dict[str, Dict]]: def list_all_dashboards(request: TokenRequest, config: dict) -> Dict[str, Dict[str, Dict]]:
config_ignored = set([f.lower() for f in config.get("ignored_folders", [])])
r = request.get("api/search?type=dash-db") r = request.get("api/search?type=dash-db")
dashboards = r.json() dashboards = r.json()
all_folders = get_folders(request) all_folders = get_folders(request)
result = {f["uid"]: {} for f in all_folders} result = {}
for dash in dashboards: ignored_folders = {}
result.setdefault(dash.get("folderUid", ""), {})[dash["title"].lower()] = dash for folder in all_folders:
if folder.get("title", "").lower() in config_ignored:
ignored_folders[folder["uid"]] = folder["title"].lower()
logger.info(
f"Ignoring folder {folder['title']} ({folder['uid']}) "
f"as it is in the ignored folders list"
)
continue
result[folder["uid"]] = {}
return result for dash in dashboards:
folder_uid = dash.get("folderUid", "")
if folder_uid in ignored_folders:
logger.info(
f"Ignoring dashboard {dash['title']} ({dash['uid']}) "
f"as it is in an ignored folder ({ignored_folders[folder_uid]})"
)
continue
result.setdefault(folder_uid, {})[dash["title"].lower()] = dash
return result, set(ignored_folders)
def delete_dashboard_by_uid(request: TokenRequest, uid: int): def delete_dashboard_by_uid(request: TokenRequest, uid: int):
......
...@@ -391,12 +391,12 @@ def provision_all_dashboards( ...@@ -391,12 +391,12 @@ def provision_all_dashboards(
organization: Organization, organization: Organization,
config: dict, config: dict,
): ):
current_folders = list_all_dashboards(organization.request) current_folders, ignored_folders = list_all_dashboards(organization.request, config)
to_render = populate_folders_for_organization(folders, data, organization) to_render = populate_folders_for_organization(folders, data, organization)
with ThreadPoolExecutor(max_workers=10) as executor: with ThreadPoolExecutor(max_workers=10) as executor:
futs = itertools.chain( futs = itertools.chain(
provision_folders( provision_folders(
to_render, organization, current_folders, config, executor to_render, organization, current_folders, ignored_folders, executor
), ),
) )
# We need to wait here for the futures to be completed. Those futures may # We need to wait here for the futures to be completed. Those futures may
...@@ -425,10 +425,10 @@ def provision_folders( ...@@ -425,10 +425,10 @@ def provision_folders(
folders: Sequence[BoundFolder], folders: Sequence[BoundFolder],
organization: Organization, organization: Organization,
current_folders: dict, current_folders: dict,
config: dict, ignored_folders: set,
executor: ThreadPoolExecutor, executor: ThreadPoolExecutor,
): ):
provisioned = set(config.get("ignored_folders", [])) provisioned = set(ignored_folders)
for folder in folders: for folder in folders:
provisioned.add(folder.uid) provisioned.add(folder.uid)
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.84] - 2025-06-24
- Fix ignored_folders expecting a UID, not a title
## [0.83] - 2025-06-24 ## [0.83] - 2025-06-24
- Fix RE Peers BETA folder exclusion - Fix RE Peers BETA folder exclusion
......
...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages ...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name='brian-dashboard-manager', name='brian-dashboard-manager',
version="0.83", version="0.84",
author='GEANT', author='GEANT',
author_email='swd@geant.org', author_email='swd@geant.org',
description='', description='',
......
...@@ -11,19 +11,23 @@ from brian_dashboard_manager.grafana.request import TokenRequest ...@@ -11,19 +11,23 @@ from brian_dashboard_manager.grafana.request import TokenRequest
@responses.activate @responses.activate
def test_list_all_dashboards(mock_grafana): def test_list_all_dashboards(mock_grafana, data_config):
mock_grafana.create_folder({"uid": "some-folder"}) mock_grafana.create_folder({"uid": "some-folder"})
mock_grafana.create_dashboard( mock_grafana.create_dashboard(
{"uid": "1", "title": "some dashboard", "folderUid": "some-folder"} {"uid": "1", "title": "some dashboard", "folderUid": "some-folder"}
) )
mock_grafana.create_dashboard({"uid": "2", "title": "other dashboard"}) mock_grafana.create_dashboard({"uid": "2", "title": "other dashboard"})
mock_grafana.create_folder({"uid": "1337", "title": "fakefolder"})
mock_grafana.create_dashboard({"uid": "4", "title": "fake dashboard", "folderUid": "1337"})
request = mock_grafana.request request = mock_grafana.request
data = list_all_dashboards(request) data, ignored_folders = list_all_dashboards(request, data_config)
assert len(data) == 2 assert len(data) == 2
assert data["some-folder"]["some dashboard"]["uid"] == "1" assert data["some-folder"]["some dashboard"]["uid"] == "1"
assert data[""]["other dashboard"]["uid"] == "2" assert data[""]["other dashboard"]["uid"] == "2"
assert "1337" not in data
assert "1337" in ignored_folders
@responses.activate @responses.activate
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment