From e1d1a59c798073c5bef6880e419b31ecfa9dd0c7 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Wed, 12 Apr 2023 14:20:46 +0200 Subject: [PATCH 1/2] feat: save config to json --- .gitignore | 3 ++- .../training_output/artifact_saver/to_disk.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b7de2598..e0f05476 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ package.json *.csv evaluation_results -*.pqt \ No newline at end of file +*.pqt +tests/test_eval_results diff --git a/src/psycop_model_training/training_output/artifact_saver/to_disk.py b/src/psycop_model_training/training_output/artifact_saver/to_disk.py index c99960bd..5ec5e8e5 100644 --- a/src/psycop_model_training/training_output/artifact_saver/to_disk.py +++ b/src/psycop_model_training/training_output/artifact_saver/to_disk.py @@ -1,3 +1,4 @@ +import json import logging from pathlib import Path from typing import Any, Optional, Union @@ -81,6 +82,10 @@ def save( if cfg is not None: dump_to_pickle(cfg, self.dir_path / "cfg.pkl") + + with (self.dir_path / "cfg.json").open(mode="w") as f: + cfg_dict = cfg.json() + json.dump(cfg_dict, f) if pipe_metadata is not None: dump_to_pickle(pipe_metadata, self.dir_path / "pipe_metadata.pkl") From d3ded84ea0c2d98b89d2d7b3434bd94ca8a80854 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Wed, 12 Apr 2023 14:20:51 +0200 Subject: [PATCH 2/2] style: linting --- .../training_output/artifact_saver/to_disk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psycop_model_training/training_output/artifact_saver/to_disk.py b/src/psycop_model_training/training_output/artifact_saver/to_disk.py index 5ec5e8e5..eab2a2b7 100644 --- a/src/psycop_model_training/training_output/artifact_saver/to_disk.py +++ b/src/psycop_model_training/training_output/artifact_saver/to_disk.py @@ -82,7 +82,7 @@ def save( if cfg is not None: dump_to_pickle(cfg, self.dir_path / "cfg.pkl") - + with (self.dir_path / "cfg.json").open(mode="w") as f: cfg_dict = cfg.json() json.dump(cfg_dict, f)