From b43d296c69ba875afecf2f5eeb93567965b9271c Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 28 Mar 2024 08:53:51 +0000 Subject: [PATCH] added skip mode tests back in --- cylc/flow/task_events_mgr.py | 19 +++++++++++-------- cylc/flow/task_job_mgr.py | 14 +++++++++++--- cylc/flow/task_state.py | 7 +++++++ .../run_modes/06-run-mode-overrides/flow.cylc | 4 ++-- .../run_modes/test_mode_overrides.py | 2 +- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/cylc/flow/task_events_mgr.py b/cylc/flow/task_events_mgr.py index a7f16e04498..e6adf1dec78 100644 --- a/cylc/flow/task_events_mgr.py +++ b/cylc/flow/task_events_mgr.py @@ -78,7 +78,10 @@ TASK_STATUS_FAILED, TASK_STATUS_EXPIRED, TASK_STATUS_SUCCEEDED, - TASK_STATUS_WAITING + TASK_STATUS_WAITING, + MODES_GHOST, + MODE_LIVE, + MODES_LIVE, ) from cylc.flow.task_outputs import ( TASK_OUTPUT_EXPIRED, @@ -769,7 +772,7 @@ def process_message( # ... but either way update the job ID in the job proxy (it only # comes in via the submission message). - if itask.tdef.run_mode != 'simulation': + if itask.tdef.run_mode not in MODES_GHOST: job_tokens = itask.tokens.duplicate( job=str(itask.submit_num) ) @@ -887,7 +890,7 @@ def _process_message_check( if ( itask.state(TASK_STATUS_WAITING) - and itask.tdef.run_mode == 'live' # Polling in live mode only. + and itask.tdef.run_mode == MODE_LIVE # Polling in live mode only. and ( ( # task has a submit-retry lined up @@ -932,7 +935,7 @@ def _process_message_check( def setup_event_handlers(self, itask, event, message): """Set up handlers for a task event.""" - if itask.tdef.run_mode != 'live': + if itask.tdef.run_mode not in MODES_LIVE: return msg = "" if message != f"job {event}": @@ -1457,7 +1460,7 @@ def _process_message_submitted( ) itask.set_summary_time('submitted', event_time) - if itask.tdef.run_mode == 'simulation': + if itask.tdef.run_mode in MODES_GHOST: # Simulate job started as well. itask.set_summary_time('started', event_time) if itask.state_reset(TASK_STATUS_RUNNING, forced=forced): @@ -1494,7 +1497,7 @@ def _process_message_submitted( 'submitted', event_time, ) - if itask.tdef.run_mode == 'simulation': + if itask.tdef.run_mode in MODES_GHOST: # Simulate job started as well. self.data_store_mgr.delta_job_time( job_tokens, @@ -1527,8 +1530,8 @@ def _insert_task_job( # not see previous submissions (so can't use itask.jobs[submit_num-1]). # And transient tasks, used for setting outputs and spawning children, # do not submit jobs. - if itask.tdef.run_mode == "simulation" or forced: - job_conf = {"submit_num": 0} + if itask.tdef.run_mode in MODES_GHOST or forced: + job_conf = {"submit_num": itask.submit_num} else: job_conf = itask.jobs[-1] diff --git a/cylc/flow/task_job_mgr.py b/cylc/flow/task_job_mgr.py index 007faef41fb..f49e73192a0 100644 --- a/cylc/flow/task_job_mgr.py +++ b/cylc/flow/task_job_mgr.py @@ -65,6 +65,8 @@ from cylc.flow.remote import construct_ssh_cmd from cylc.flow.run_modes.simulation import ( submit_task_job as simulation_submit_task_job) +from cylc.flow.run_modes.skip import ( + submit_task_job as skip_submit_task_job) from cylc.flow.run_modes.dummy import ( submit_task_job as dummy_submit_task_job) from cylc.flow.subprocctx import SubProcContext @@ -106,7 +108,10 @@ TASK_STATUS_SUBMITTED, TASK_STATUS_RUNNING, TASK_STATUS_WAITING, - TASK_STATUSES_ACTIVE + TASK_STATUSES_ACTIVE, + MODE_SKIP, + MODE_SIMULATION, + MODE_DUMMY ) from cylc.flow.wallclock import ( get_current_time_string, @@ -1038,12 +1043,15 @@ def _ghost_submit_task_jobs( # Submit ghost tasks, or add live-like tasks to list # of tasks to put through live submission pipeline: is_done = False - if run_mode == 'dummy': + if run_mode == MODE_DUMMY: is_done = dummy_submit_task_job( self, itask, rtconfig, workflow, now) - elif run_mode == 'simulation': + elif run_mode == MODE_SIMULATION: is_done = simulation_submit_task_job( self, itask, rtconfig, workflow, now) + elif run_mode == MODE_SKIP: + is_done = skip_submit_task_job( + self, itask, rtconfig, workflow, now) # Assign task to list: if is_done: diff --git a/cylc/flow/task_state.py b/cylc/flow/task_state.py index ebb3dbc985b..45b662632a3 100644 --- a/cylc/flow/task_state.py +++ b/cylc/flow/task_state.py @@ -153,6 +153,13 @@ TASK_STATUS_FAILED, } +MODE_LIVE = 'live' +MODE_SIMULATION = 'simulation' +MODE_DUMMY = 'dummy' +MODE_SKIP = 'skip' +MODES_LIVE = {MODE_LIVE, MODE_DUMMY} +MODES_GHOST = {MODE_SKIP, MODE_SIMULATION} + def status_leq(status_a, status_b): """"Return True if status_a <= status_b""" diff --git a/tests/functional/run_modes/06-run-mode-overrides/flow.cylc b/tests/functional/run_modes/06-run-mode-overrides/flow.cylc index 13e79a4eb9c..b7693232149 100644 --- a/tests/functional/run_modes/06-run-mode-overrides/flow.cylc +++ b/tests/functional/run_modes/06-run-mode-overrides/flow.cylc @@ -10,7 +10,7 @@ live_ dummy_ simulation_ - # skip_ + skip_ """ [runtime] @@ -26,4 +26,4 @@ [[simulation_]] run mode = simulation [[skip_]] - # run mode = skip + run mode = skip diff --git a/tests/integration/run_modes/test_mode_overrides.py b/tests/integration/run_modes/test_mode_overrides.py index b76b0082ee2..8199162155f 100644 --- a/tests/integration/run_modes/test_mode_overrides.py +++ b/tests/integration/run_modes/test_mode_overrides.py @@ -46,7 +46,7 @@ async def test_run_mode_override( "run mode": "simulation", 'simulation': {'default run length': 'PT0S'} }, - # "skip_": {"run mode": "skip"} + "skip_": {"run mode": "skip"}, } } id_ = flow(cfg)