From 01238de89871c7d7854ce69e30be9d852347ecd7 Mon Sep 17 00:00:00 2001 From: Jan Maarten van Doorn <52956303+JanMaartenvanDoorn@users.noreply.github.com> Date: Tue, 9 Mar 2021 14:04:50 +0100 Subject: [PATCH 1/4] fixed bug in prediction job loop and warning in capacity model --- openstf/model/capacity/model.py | 10 +++++++--- openstf/tasks/utils/predictionjobloop.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openstf/model/capacity/model.py b/openstf/model/capacity/model.py index c9f57d264..7dd599fa4 100644 --- a/openstf/model/capacity/model.py +++ b/openstf/model/capacity/model.py @@ -83,11 +83,15 @@ def save(self, directory): os.makedirs(directory, exist_ok=True) # save model - pickle.dump(self.model, open(directory / "model.pkl", "wb")) + with open(directory / "model.pkl", "wb") as fh: + pickle.dump(self.model, fh) + fh.close() # save classes - pickle.dump(self.classes, open(directory / "classes.pkl", "wb")) - + with open(directory / "classes.pkl", "wb") as fh: + pickle.dump(self.classes, fh) + fh.close() + def load(self, directory): # load model model_file = Path(directory) / "model.pkl" diff --git a/openstf/tasks/utils/predictionjobloop.py b/openstf/tasks/utils/predictionjobloop.py index 933a98196..b2f2e0dd8 100644 --- a/openstf/tasks/utils/predictionjobloop.py +++ b/openstf/tasks/utils/predictionjobloop.py @@ -77,7 +77,7 @@ def _get_prediction_jobs(self): return prediction_jobs - def _add_missing_info_prediciton_jobs(self, prediction_jobs_input): + def _add_missing_info_prediction_jobs(self, prediction_jobs_input): prediction_jobs = [] for pj in prediction_jobs_input: From 34dac59fe744145f0d78152888b036bc4ca7c462 Mon Sep 17 00:00:00 2001 From: Jan Maarten van Doorn <52956303+JanMaartenvanDoorn@users.noreply.github.com> Date: Tue, 9 Mar 2021 14:06:09 +0100 Subject: [PATCH 2/4] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d371cb15d..1d38f92bc 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def read_long_description_from_readme(): setup( name="openstf", - version="1.5.3", + version="1.5.4", packages=find_packages(include=["openstf", "openstf.*"]), description="Open short term forcasting", long_description=read_long_description_from_readme(), From b21de3861871975f51ee6ab768fcd527e0a74df0 Mon Sep 17 00:00:00 2001 From: black Date: Tue, 9 Mar 2021 13:07:15 +0000 Subject: [PATCH 3/4] Format Python code with Black --- openstf/model/capacity/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstf/model/capacity/model.py b/openstf/model/capacity/model.py index 7dd599fa4..0833c6f70 100644 --- a/openstf/model/capacity/model.py +++ b/openstf/model/capacity/model.py @@ -91,7 +91,7 @@ def save(self, directory): with open(directory / "classes.pkl", "wb") as fh: pickle.dump(self.classes, fh) fh.close() - + def load(self, directory): # load model model_file = Path(directory) / "model.pkl" From 7186233dd1657c8eaed1e6dc40aed08c0a9be4b3 Mon Sep 17 00:00:00 2001 From: Jan Maarten van Doorn <52956303+JanMaartenvanDoorn@users.noreply.github.com> Date: Tue, 9 Mar 2021 14:24:12 +0100 Subject: [PATCH 4/4] Implemented feedback --- openstf/model/capacity/model.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openstf/model/capacity/model.py b/openstf/model/capacity/model.py index 7dd599fa4..617b7cf62 100644 --- a/openstf/model/capacity/model.py +++ b/openstf/model/capacity/model.py @@ -85,13 +85,11 @@ def save(self, directory): # save model with open(directory / "model.pkl", "wb") as fh: pickle.dump(self.model, fh) - fh.close() # save classes with open(directory / "classes.pkl", "wb") as fh: pickle.dump(self.classes, fh) - fh.close() - + def load(self, directory): # load model model_file = Path(directory) / "model.pkl"