From fd3f8652ce68920ee6b46b7bb58d4012aad4f8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Mon, 31 Jan 2022 11:46:54 +0100 Subject: [PATCH] Add date and color to results list --- README.md | 11 +++++++++++ src/Results.py | 23 ++++++++++++++++------- src/list.py | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c43b527..6d054fe 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,14 @@ python src/benchmark.py # Do benchmark, print report and build excel file with data python src/benchmark.py -x 1 ``` + +## List + +```python +# List of results of given model +python src/list.py -m ODTE +# List of results of given model and score +python src/list.py -m STree -s f1-macro +# List all results +python src/list.py +``` diff --git a/src/Results.py b/src/Results.py index ff8a566..2fe83f7 100644 --- a/src/Results.py +++ b/src/Results.py @@ -1,4 +1,3 @@ -from cgitb import text import os import json import abc @@ -700,7 +699,7 @@ class Summary: self.datasets[result] = report.lines self.data.append(entry) - def list(self, score=None, model=None) -> None: + def list_results(self, score=None, model=None) -> None: """Print the list of results""" data = self.data.copy() if score: @@ -710,14 +709,24 @@ class Summary: data = sorted(data, key=lambda x: x["date"], reverse=True) max_file = max(len(x["file"]) for x in data) max_title = max(len(x["title"]) for x in data) - print(f"{'File':{max_file}s} {'Score':7s} {'Title':s}") - print("=" * max_file + " " + "=" * 7 + " " + "=" * max_title) + print(TextColor.LINE1, end="") + print(f"{'Date':10s} {'File':{max_file}s} {'Score':7s} {'Title':s}") + print( + "=" * 10 + + " " + + "=" * max_file + + " " + + "=" * 7 + + " " + + "=" * max_title + ) print( "\n".join( [ - f"{x['file']:{max_file}s} {x['metric']:7.3f} " - f"{x['title']}" - for x in data + (TextColor.LINE2 if n % 2 == 0 else TextColor.LINE1) + + f"{x['date']} {x['file']:{max_file}s} " + f"{x['metric']:7.3f} {x['title']}" + for n, x in enumerate(data) ] ) ) diff --git a/src/list.py b/src/list.py index b6b5199..2eecc28 100644 --- a/src/list.py +++ b/src/list.py @@ -37,4 +37,4 @@ def parse_arguments(): data = Summary() data.acquire() -data.list(score, model) +data.list_results(score, model)