Skip to content

Commit

Permalink
added skip mode tests back in
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Mar 28, 2024
1 parent fb0e3d4 commit b43d296
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
19 changes: 11 additions & 8 deletions cylc/flow/task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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
Expand Down Expand 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}":
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]

Expand Down
14 changes: 11 additions & 3 deletions cylc/flow/task_job_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions cylc/flow/task_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/run_modes/06-run-mode-overrides/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
live_
dummy_
simulation_
# skip_
skip_
"""

[runtime]
Expand All @@ -26,4 +26,4 @@
[[simulation_]]
run mode = simulation
[[skip_]]
# run mode = skip
run mode = skip
2 changes: 1 addition & 1 deletion tests/integration/run_modes/test_mode_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b43d296

Please sign in to comment.