diff --git a/changes.d/6036.fix.md b/changes.d/6036.fix.md new file mode 100644 index 00000000000..6609a349505 --- /dev/null +++ b/changes.d/6036.fix.md @@ -0,0 +1 @@ +Fixed bug in simulation mode where repeated submissions were not displaying correctly in TUI/GUI. \ No newline at end of file diff --git a/cylc/flow/task_events_mgr.py b/cylc/flow/task_events_mgr.py index 189193541a2..14f376dfb74 100644 --- a/cylc/flow/task_events_mgr.py +++ b/cylc/flow/task_events_mgr.py @@ -1528,7 +1528,7 @@ def _insert_task_job( # And transient tasks, used for setting outputs and spawning children, # do not submit jobs. if (itask.tdef.run_mode == RunMode.SIMULATION) or forced: - job_conf = {"submit_num": 0} + job_conf = {"submit_num": itask.submit_num} else: job_conf = itask.jobs[-1] diff --git a/tests/integration/test_task_events_mgr.py b/tests/integration/test_task_events_mgr.py index 5798b0c3d2a..7f3fa488162 100644 --- a/tests/integration/test_task_events_mgr.py +++ b/tests/integration/test_task_events_mgr.py @@ -64,3 +64,37 @@ async def test__reset_job_timers( 'polling intervals=PT25S,PT15S,PT10S,...' in caplog.records[0].msg ) + + +async def test__insert_task_job(flow, one_conf, scheduler, start, validate): + """Simulation mode tasks are inserted into the Data Store, + with correct submit number. + """ + conf = { + 'scheduling': {'graph': {'R1': 'rhenas'}}, + 'runtime': {'rhenas': {'simulation': { + 'fail cycle points': '1', + 'fail try 1 only': False, + }}}} + id_ = flow(conf) + schd = scheduler(id_) + async with start(schd): + # Set task to running: + itask = schd.pool.get_tasks()[0] + itask.state.status = 'running' + itask.submit_num += 1 + + # Not run _insert_task_job yet: + assert not schd.data_store_mgr.added['jobs'].keys() + + # Insert task (twice): + schd.task_events_mgr._insert_task_job(itask, 'now', 1) + itask.submit_num += 1 + schd.task_events_mgr._insert_task_job(itask, 'now', 1) + + # Check that there are two entries with correct submit + # numbers waiting for data-store insertion: + assert [ + i.submit_num for i + in schd.data_store_mgr.added['jobs'].values() + ] == [1, 2]