From 0d449d1288f96d777ebd5073e6ce8140cf68ab46 Mon Sep 17 00:00:00 2001 From: 1pha <1phantasmas@korea.ac.kr> Date: Fri, 19 Jan 2024 13:37:28 +0900 Subject: [PATCH] Add timestamp --- sage/trainer/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sage/trainer/utils.py b/sage/trainer/utils.py index 6104e59..0249ced 100644 --- a/sage/trainer/utils.py +++ b/sage/trainer/utils.py @@ -1,5 +1,6 @@ """ Includes model inference, output sorting utils """ +from datetime import datetime from pathlib import Path import pickle @@ -69,6 +70,12 @@ def _sort_outputs(outputs): return result +def timestamp(fmt: str = "%y%m%d_%H%M") -> str: + now = datetime.now() + now = now.strftime(fmt) + return now + + def finalize_inference(prediction: list, name: str, root_dir: Path = Path(".")) -> None: @@ -89,7 +96,7 @@ def finalize_inference(prediction: list, pickle.dump(prediction, f) # 2. Log Predictions - run_name = save_name[:-4] + run_name = save_name[:-4] + "_" + timestamp() preds, target = prediction["pred"], prediction["target"] if name.startswith("C"): logger.info("Classification data given:")