Skip to content

Commit 6a78c74

Browse files
committed
Add test that cylc set does not affect task timings
1 parent 7b69615 commit 6a78c74

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

cylc/flow/data_store_mgr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
from cylc.flow.flow_mgr import FlowNums
135135
from cylc.flow.prerequisite import Prerequisite
136136
from cylc.flow.scheduler import Scheduler
137+
from cylc.flow.taskdef import TaskDef
137138

138139
EDGES = 'edges'
139140
FAMILIES = 'families'
@@ -256,7 +257,7 @@ def generate_checksum(in_strings):
256257
return zlib.adler32(''.join(sorted(in_strings)).encode()) & 0xffffffff
257258

258259

259-
def task_mean_elapsed_time(tdef):
260+
def task_mean_elapsed_time(tdef: 'TaskDef') -> float | None:
260261
"""Calculate task mean elapsed time."""
261262
if tdef.elapsed_times:
262263
return round(sum(tdef.elapsed_times) / len(tdef.elapsed_times))

tests/integration/scripts/test_set.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from cylc.flow.data_store_mgr import (
3737
JOBS,
3838
TASK_PROXIES,
39+
task_mean_elapsed_time,
3940
)
4041
from cylc.flow.id import TaskTokens
4142
from cylc.flow.scheduler import Scheduler
@@ -48,6 +49,7 @@
4849
from cylc.flow.task_proxy import TaskProxy
4950
from cylc.flow.task_state import (
5051
TASK_STATUS_FAILED,
52+
TASK_STATUS_PREPARING,
5153
TASK_STATUS_SUCCEEDED,
5254
TASK_STATUS_WAITING,
5355
)
@@ -430,3 +432,31 @@ def data_store_task_state(itask: TaskProxy):
430432
await schd.update_data_structure()
431433
assert db_task_states(foo) == expected
432434
assert data_store_task_state(foo) == TASK_STATUS_SUCCEEDED
435+
436+
437+
async def test_timings(one_conf, flow, scheduler, start, caplog):
438+
"""Test that setting outputs does not change the task timings."""
439+
wid = flow({
440+
**one_conf,
441+
'runtime': {
442+
'one': {
443+
'execution time limit': 'PT100S',
444+
},
445+
},
446+
})
447+
schd: Scheduler = scheduler(wid)
448+
async with start(schd):
449+
itask = schd.pool.get_tasks()[0]
450+
451+
def check_times():
452+
assert not itask.tdef.elapsed_times
453+
assert task_mean_elapsed_time(itask.tdef) == 100
454+
455+
itask.state_reset(TASK_STATUS_PREPARING)
456+
schd.task_events_mgr.process_message(
457+
itask, 'INFO', TASK_OUTPUT_STARTED
458+
)
459+
check_times()
460+
461+
await run_cmd(set_prereqs_and_outputs(schd, [itask.identity], []))
462+
check_times()

0 commit comments

Comments
 (0)