From d9cc2204caa47d0dc828a9a15c4f4d87b5bd8437 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Thu, 21 Nov 2024 12:38:25 +0100 Subject: [PATCH] fix missing database check when doing RL without a given database This fixes commands like: assume -s example_02a -c tiny --- assume/common/outputs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assume/common/outputs.py b/assume/common/outputs.py index b79abd54..ce8d8603 100644 --- a/assume/common/outputs.py +++ b/assume/common/outputs.py @@ -568,9 +568,9 @@ def get_sum_reward(self): query = text( f"select unit, SUM(reward) FROM rl_params where simulation='{self.simulation_id}' GROUP BY unit" ) - - with self.db.begin() as db: - rewards_by_unit = db.execute(query).fetchall() + if self.db is not None: + with self.db.begin() as db: + rewards_by_unit = db.execute(query).fetchall() # convert into a numpy array rewards_by_unit = [r[1] for r in rewards_by_unit]