From 47749cea94ba153c9a20624953335cb1cfcc8029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Thu, 5 May 2022 23:37:13 +0200 Subject: [PATCH] Add color to summary and fix some issues --- benchmark/Arguments.py | 4 - benchmark/Results.py | 83 +++++++++++++++---- .../scripts/{be_repara.py => be_repair.py} | 0 setup.py | 1 - 4 files changed, 65 insertions(+), 23 deletions(-) rename benchmark/scripts/{be_repara.py => be_repair.py} (100%) diff --git a/benchmark/Arguments.py b/benchmark/Arguments.py index 95727dd..9f6060a 100644 --- a/benchmark/Arguments.py +++ b/benchmark/Arguments.py @@ -157,8 +157,6 @@ class Arguments: "type": str, "required": True, "choices": list(models_data), - "action": EnvDefault, - "envvar": "model", "help": "model name", }, ], @@ -168,8 +166,6 @@ class Arguments: "type": str, "required": True, "choices": list(models_data), - "action": EnvDefault, - "envvar": "model", "help": "model name", }, ], diff --git a/benchmark/Results.py b/benchmark/Results.py index 261e919..9c7cc9e 100644 --- a/benchmark/Results.py +++ b/benchmark/Results.py @@ -1153,47 +1153,94 @@ class Summary: def show_result(self, data: dict, title: str = "") -> None: def whites(n: int) -> str: - return " " * n + "*" + return " " * n + color1 + "*" if data == {}: print(f"** {title} has No data **") return + color1 = TextColor.CYAN + color2 = TextColor.YELLOW file_name = data["file"] metric = data["metric"] result = StubReport(os.path.join(Folders.results, file_name)) length = 81 - print("*" * length) + print(color1 + "*" * length) if title != "": - print(f"*{title:^{length - 2}s}*") + print( + "*" + + color2 + + TextColor.BOLD + + f"{title:^{length - 2}s}" + + TextColor.ENDC + + color1 + + "*" + ) print("*" + "-" * (length - 2) + "*") print("*" + whites(length - 2)) - print(f"* {result.data['title']:^{length - 4}} *") - print("*" + whites(length - 2)) print( - f"* Model: {result.data['model']:15s} " - f"Ver. {result.data['version']:10s} " - f"Score: {result.data['score_name']:10s} " - f"Metric: {metric:10.7f}" + whites(length - 78) + "* " + + color2 + + f"{result.data['title']:^{length - 4}}" + + color1 + + " *" ) print("*" + whites(length - 2)) print( - f"* Date : {result.data['date']:15s} Time: " - f"{result.data['time']:18s} Time Spent: " - f"{result.data['duration']:9,.2f} secs." + whites(length - 78) + "* Model: " + + color2 + + f"{result.data['model']:15s} " + + color1 + + "Ver. " + + color2 + + f"{result.data['version']:10s} " + + color1 + + "Score: " + + color2 + + f"{result.data['score_name']:10s} " + + color1 + + "Metric: " + + color2 + + f"{metric:10.7f}" + + whites(length - 78) + ) + print(color1 + "*" + whites(length - 2)) + print( + "* Date : " + + color2 + + f"{result.data['date']:15s}" + + color1 + + " Time: " + + color2 + + f"{result.data['time']:18s} " + + color1 + + "Time Spent: " + + color2 + + f"{result.data['duration']:9,.2f}" + + color1 + + " secs." + + whites(length - 78) ) seeds = str(result.data["seeds"]) seeds_len = len(seeds) print( - f"* Seeds: {seeds:{seeds_len}s} Platform: " - f"{result.data['platform']:17s} " + whites(length - 79) + "* Seeds: " + + color2 + + f"{seeds:{seeds_len}s} " + + color1 + + "Platform: " + + color2 + + f"{result.data['platform']:17s} " + + whites(length - 79) ) print( - f"* Stratified: {str(result.data['stratified']):15s}" + "* Stratified: " + + color2 + + f"{str(result.data['stratified']):15s}" + whites(length - 30) ) - print(f"* {file_name:60s}" + whites(length - 63)) - print("*" + whites(length - 2)) - print("*" * length) + print("* " + color2 + f"{file_name:60s}" + whites(length - 63)) + print(color1 + "*" + whites(length - 2)) + print(color1 + "*" * length) def best_results(self, criterion=None, value=None, score="accuracy", n=10): # First filter the same score results (accuracy, f1, ...) diff --git a/benchmark/scripts/be_repara.py b/benchmark/scripts/be_repair.py similarity index 100% rename from benchmark/scripts/be_repara.py rename to benchmark/scripts/be_repair.py diff --git a/setup.py b/setup.py index 64e92e8..e5ac12a 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,6 @@ setuptools.setup( "be_grid=benchmark.scripts.be_grid:main", "be_pair_check=benchmark.scripts.be_pair_check:main", "be_print_strees=benchmark.scripts.be_print_strees:main", - "be_repara=benchmark.scripts.be_repara:main", "be_summary=benchmark.scripts.be_summary:main", ], },