From 0121946a41c0c315611e4679f2ffa28449e1dd69 Mon Sep 17 00:00:00 2001 From: yurakuratov <9271630+yurakuratov@users.noreply.github.com> Date: Mon, 2 Sep 2024 10:42:08 +0300 Subject: [PATCH 1/2] fix: paths where to save metrics with eval results --- eval.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eval.py b/eval.py index ddfa6a2..b0e7728 100644 --- a/eval.py +++ b/eval.py @@ -1,6 +1,6 @@ -import os import argparse import json +from pathlib import Path import numpy as np from evaluation import metrics @@ -69,9 +69,9 @@ def name_to_metric(name): results["total_score"] = np.mean(total_score) print(results) - save_path = "results/" + args.path.split("/")[1] - if not os.path.exists(save_path.split("/")[0]): - os.makedirs(save_path.split("/")[0]) + save_path = Path("./results") / Path(args.path).name + if not save_path.parent.exists(): + save_path.parent.mkdir(parents=True) with open(save_path, "w") as outfile: json.dump(results, outfile) print(f"evaluations were saved here: {save_path}") From 303e608a141cba8720bcaacdb1d91b39744f5efd Mon Sep 17 00:00:00 2001 From: yurakuratov <9271630+yurakuratov@users.noreply.github.com> Date: Mon, 2 Sep 2024 10:50:48 +0300 Subject: [PATCH 2/2] add indent=4 formating to saved json with metrics --- eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eval.py b/eval.py index b0e7728..5c7295f 100644 --- a/eval.py +++ b/eval.py @@ -73,5 +73,5 @@ def name_to_metric(name): if not save_path.parent.exists(): save_path.parent.mkdir(parents=True) with open(save_path, "w") as outfile: - json.dump(results, outfile) + json.dump(results, outfile, indent=4) print(f"evaluations were saved here: {save_path}")