From a76ee3533aecda8b14ecda3f53e57e094831dc62 Mon Sep 17 00:00:00 2001 From: Michael Hafner Date: Sat, 9 Nov 2024 13:52:13 +0100 Subject: [PATCH] clear the simulation in the db on startup --- assume/common/outputs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/assume/common/outputs.py b/assume/common/outputs.py index 755af14d..b3d9e396 100644 --- a/assume/common/outputs.py +++ b/assume/common/outputs.py @@ -98,9 +98,6 @@ def __init__( self.write_dfs: dict = defaultdict(list) self.locks = defaultdict(lambda: Lock()) - if self.db is not None: - self.delete_db_scenario(self.simulation_id) - self.kpi_defs: dict[str, OutputDef] = { "avg_price": { "value": "avg(price)", @@ -191,6 +188,8 @@ def setup(self): def on_ready(self): if self.db_uri: self.db = create_engine(self.db_uri) + if self.db is not None: + self.delete_db_scenario(self.simulation_id) if self.save_frequency_hours is not None: recurrency_task = rr.rrule( freq=rr.HOURLY,