From 21585d18ab1166d03a151d6f59892cde60f9f89b Mon Sep 17 00:00:00 2001 From: David de la Iglesia Castro Date: Thu, 16 Sep 2021 08:25:03 +0200 Subject: [PATCH] Force sorted order in plots rendering (#6601) * Force sorted order in plots * Fix type hint * Fixed mypy * Updates test_plots * Removed reduntant test * Removed unused import --- dvc/render/utils.py | 7 ++++--- tests/unit/test_plots.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dvc/render/utils.py b/dvc/render/utils.py index c9f227c79..6734ac65d 100644 --- a/dvc/render/utils.py +++ b/dvc/render/utils.py @@ -1,13 +1,14 @@ import os.path -from typing import Dict, List, Set +from typing import Dict, List -def get_files(data: Dict) -> Set: +def get_files(data: Dict) -> List: files = set() for rev in data.keys(): for file in data[rev].get("data", {}).keys(): files.add(file) - return files + sorted_files = sorted(files) + return sorted_files def group_by_filename(plots_data: Dict) -> List[Dict]: diff --git a/tests/unit/test_plots.py b/tests/unit/test_plots.py index 49ec95f58..306cb822c 100644 --- a/tests/unit/test_plots.py +++ b/tests/unit/test_plots.py @@ -28,9 +28,9 @@ def test_plots_order(tmp_dir, dvc): name="stage2", ) - assert get_files(dvc.plots.show()) == { + assert get_files(dvc.plots.show()) == [ "p.json", - os.path.join("sub", "p4.json"), "p1.json", os.path.join("sub", "p3.json"), - } + os.path.join("sub", "p4.json"), + ]