Create target folder if not exists in EvalResult.save() (#2647)

* Create target folder if not exists in EvalResult.save()

* log out dir
This commit is contained in:
tstadel 2022-06-09 19:26:12 +02:00 committed by GitHub
parent 9968c373d2
commit c8f9e1b76c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1245,6 +1245,9 @@ class EvaluationResult:
:param out_dir: Path to the target folder the csvs will be saved.
"""
out_dir = out_dir if isinstance(out_dir, Path) else Path(out_dir)
logger.info(f"Saving evaluation results to {out_dir}")
if not out_dir.exists():
out_dir.mkdir(parents=True)
for node_name, df in self.node_results.items():
target_path = out_dir / f"{node_name}.csv"
df.to_csv(target_path, index=False, header=True)