From 77ec65751719f6837a98446930660bcbdb0f3ab9 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Fri, 1 Mar 2024 10:27:03 +0100 Subject: [PATCH] [scripts.evaluate] Add meta data saving also for evaluation --- src/mednet/scripts/evaluate.py | 6 ++++++ tests/test_cli.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/mednet/scripts/evaluate.py b/src/mednet/scripts/evaluate.py index 9e137cce..49f8ad4e 100644 --- a/src/mednet/scripts/evaluate.py +++ b/src/mednet/scripts/evaluate.py @@ -97,10 +97,16 @@ def evaluate( aggregate_summaries, run_binary, ) + from .utils import execution_metadata, save_json_with_backup with predictions.open("r") as f: predict_data = json.load(f) + # register metadata + json_data: dict[str, typing.Any] = execution_metadata() + json_data = {k.replace("_", "-"): v for k, v in json_data.items()} + save_json_with_backup(output.with_suffix(".meta.json"), json_data) + if threshold in predict_data: # it is the name of a split # first run evaluation for reference dataset diff --git a/tests/test_cli.py b/tests/test_cli.py index bd672a62..381ef539 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -392,6 +392,7 @@ def test_evaluate_pasa_montgomery(temporary_basedir): _assert_exit_0(result) assert output_path.exists() + assert output_path.with_suffix(".meta.json").exists() assert output_path.with_suffix(".rst").exists() assert output_path.with_suffix(".pdf").exists() @@ -462,6 +463,7 @@ def test_experiment(temporary_basedir): == 1 ) assert (output_folder / "evaluation.json").exists() + assert (output_folder / "evaluation.meta.json").exists() assert (output_folder / "evaluation.rst").exists() assert (output_folder / "evaluation.pdf").exists() assert (output_folder / "gradcam" / "saliencies").exists() -- GitLab