From 372e01ed6ec49f1df4e5aab85f204e670d2efb0f Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:34:13 +0100 Subject: [PATCH] Fix simulation mode submit num bug (#6362) --- changes.d/6362.fix.md | 1 + cylc/flow/workflow_db_mgr.py | 5 +++-- tests/integration/test_simulation.py | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 changes.d/6362.fix.md diff --git a/changes.d/6362.fix.md b/changes.d/6362.fix.md new file mode 100644 index 00000000000..d469ede6b95 --- /dev/null +++ b/changes.d/6362.fix.md @@ -0,0 +1 @@ +Fixed simulation mode bug where the task submit number would not increment diff --git a/cylc/flow/workflow_db_mgr.py b/cylc/flow/workflow_db_mgr.py index 8e57d19292b..3bd627ad5b0 100644 --- a/cylc/flow/workflow_db_mgr.py +++ b/cylc/flow/workflow_db_mgr.py @@ -426,14 +426,15 @@ def put_update_task_state(self, itask): "status": itask.state.status, "flow_wait": itask.flow_wait, "is_manual_submit": itask.is_manual_submit, + "submit_num": itask.submit_num, } + # Note tasks_states table rows are for latest submit_num only + # (not one row per submit). where_args = { "cycle": str(itask.point), "name": itask.tdef.name, "flow_nums": serialise_set(itask.flow_nums), } - # Note tasks_states table rows are for latest submit_num only - # (not one row per submit). self.db_updates_map.setdefault(self.TABLE_TASK_STATES, []) self.db_updates_map[self.TABLE_TASK_STATES].append( (set_args, where_args)) diff --git a/tests/integration/test_simulation.py b/tests/integration/test_simulation.py index c7e1b42fe27..49bc76ce5e2 100644 --- a/tests/integration/test_simulation.py +++ b/tests/integration/test_simulation.py @@ -15,11 +15,13 @@ # along with this program. If not, see . from pathlib import Path + import pytest from pytest import param from cylc.flow import commands from cylc.flow.cycling.iso8601 import ISO8601Point +from cylc.flow.scheduler import Scheduler from cylc.flow.simulation import sim_time_check @@ -443,3 +445,15 @@ async def test_settings_broadcast( assert itask.try_timers['execution-retry'].delays == [2.0, 2.0, 2.0] # n.b. rtconfig should remain unchanged, lest we cancel broadcasts: assert itask.tdef.rtconfig['execution retry delays'] == [5.0, 5.0] + + +async def test_db_submit_num( + flow, one_conf, scheduler, run, complete, db_select +): + """Test simulation mode correctly increments the submit_num in the DB.""" + schd: Scheduler = scheduler(flow(one_conf), paused_start=False) + async with run(schd): + await complete(schd, '1/one') + assert db_select(schd, False, 'task_states', 'submit_num', 'status') == [ + (1, 'succeeded'), + ]