Skip to content

Commit

Permalink
Response to review
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Nov 14, 2024
1 parent 3f96ce7 commit 995ab27
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
2 changes: 0 additions & 2 deletions cylc/flow/run_modes/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def submit_task_job(
'name': RunMode.SIMULATION.value,
'install target': 'localhost',
'hosts': ['localhost'],
'disable task event handlers':
rtconfig['simulation']['disable task event handlers'],
'submission retry delays': [],
'execution retry delays': []
}
Expand Down
4 changes: 2 additions & 2 deletions cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
from cylc.flow.workflow_db_mgr import WorkflowDatabaseManager
from cylc.flow.workflow_events import WorkflowEventHandler
from cylc.flow.workflow_status import StopMode, AutoRestartMode
from cylc.flow.run_modes import RunMode, WORKFLOW_ONLY_MODES
from cylc.flow.run_modes import RunMode
from cylc.flow.taskdef import TaskDef
from cylc.flow.task_events_mgr import TaskEventsManager
from cylc.flow.task_job_mgr import TaskJobManager
Expand Down Expand Up @@ -1264,7 +1264,7 @@ def run_event_handlers(self, event, reason=""):
Run workflow events only in live mode or skip mode.
"""
if self.get_run_mode().value in WORKFLOW_ONLY_MODES:
if self.get_run_mode() in {RunMode.SIMULATION, RunMode.DUMMY}:
return
self.workflow_event_handler.handle(self, event, str(reason))

Expand Down
11 changes: 3 additions & 8 deletions cylc/flow/task_job_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,14 +1074,9 @@ def submit_nonlive_task_jobs(
# submission pipeline - We decide based on the output
# of the submit method:
submit_func = run_mode.get_submit_method()
if not submit_func:
# Return to nonlive.
nonlive_mode = False
else:
nonlive_mode = submit_func(
self, itask, rtconfig, workflow, now)

if nonlive_mode:
if submit_func and submit_func(
self, itask, rtconfig, workflow, now
):
self.workflow_db_mgr.put_insert_task_states(
itask,
{
Expand Down
6 changes: 3 additions & 3 deletions cylc/flow/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1993,12 +1993,12 @@ def _set_outputs_itask(
# Check for broadcasts to task:
bc_mgr = self.task_events_mgr.broadcast_mgr
rtconfig = bc_mgr.get_updated_rtconfig(itask)
outputs.remove(RunMode.SKIP.value)
skips = get_skip_mode_outputs(itask, rtconfig)
itask.run_mode = RunMode.SKIP
outputs = self._standardise_outputs(
itask.point, itask.tdef, outputs)
outputs = list(set(outputs + skips))
itask.point, itask.tdef, outputs
)
outputs = list(set(outputs + skips) - {RunMode.SKIP.value})

for output in sorted(outputs, key=itask.state.outputs.output_sort_key):
if itask.state.outputs.is_message_complete(output):
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/taskdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def is_parentless(self, point):
def __repr__(self) -> str:
"""
>>> TaskDef(
... name='oliver', rtcfg={}, run_mode='fake', start_point='1',
... name='oliver', rtcfg={}, start_point='1',
... initial_point='1'
... )
<TaskDef 'oliver'>
Expand Down
17 changes: 11 additions & 6 deletions tests/unit/run_modes/test_skip_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Unit tests for utilities supporting skip modes
"""
import logging
import pytest
from pytest import param, raises
from types import SimpleNamespace
Expand Down Expand Up @@ -105,7 +106,7 @@ def test_process_outputs(outputs, required, expect):
assert process_outputs(itask, rtconf) == ['submitted', 'started'] + expect


def test_skip_mode_validate(monkeypatch, caplog):
def test_skip_mode_validate(caplog, log_filter):
"""It warns us if we've set a task config to nonlive mode.
(And not otherwise)
Expand All @@ -128,8 +129,12 @@ def test_skip_mode_validate(monkeypatch, caplog):

skip_mode_validate(taskdefs)

message = caplog.messages[0]

assert 'skip mode:\n * skip_task' in message
assert ' live mode' not in message # Avoid matching "non-live mode"
assert 'workflow mode' not in message
assert len(caplog.records) == 1
assert log_filter(
level=logging.WARNING,
exact_match=(
"The following tasks are set to run in skip mode:\n"
" * skip_task"
),
log=caplog
)
8 changes: 4 additions & 4 deletions tests/unit/test_task_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)
def test_state_comparison(state, is_held):
"""Test the __call__ method."""
tdef = TaskDef('foo', {}, 'live', '123', '123')
tdef = TaskDef('foo', {}, '123', '123')
tstate = TaskState(tdef, '123', state, is_held)

assert tstate(state, is_held=is_held)
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_state_comparison(state, is_held):
)
def test_reset(state, is_held, should_reset):
"""Test that tasks do or don't have their state changed."""
tdef = TaskDef('foo', {}, 'live', '123', '123')
tdef = TaskDef('foo', {}, '123', '123')
# create task state:
# * status: waiting
# * is_held: true
Expand All @@ -96,7 +96,7 @@ def test_task_prereq_duplicates(set_cycling_type):

dep = Dependency([trig], [trig], False)

tdef = TaskDef('foo', {}, 'live', IntegerPoint("1"), IntegerPoint("1"))
tdef = TaskDef('foo', {}, IntegerPoint("1"), IntegerPoint("1"))
tdef.add_dependency(dep, seq1)
tdef.add_dependency(dep, seq2) # duplicate!

Expand All @@ -110,7 +110,7 @@ def test_task_prereq_duplicates(set_cycling_type):
def test_task_state_order():
"""Test is_gt and is_gte methods."""

tdef = TaskDef('foo', {}, 'live', IntegerPoint("1"), IntegerPoint("1"))
tdef = TaskDef('foo', {}, IntegerPoint("1"), IntegerPoint("1"))
tstate = TaskState(tdef, IntegerPoint("1"), TASK_STATUS_SUBMITTED, False)

assert tstate.is_gt(TASK_STATUS_WAITING)
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test_xtrigger_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def test_housekeeping_with_xtrigger_satisfied(xtrigger_mgr):
tdef = TaskDef(
name="foo",
rtcfg={'completion': None},
run_mode="live",
start_point=1,
initial_point=1,
)
Expand Down Expand Up @@ -232,7 +231,6 @@ def test__call_xtriggers_async(xtrigger_mgr):
tdef = TaskDef(
name="foo",
rtcfg={'completion': None},
run_mode="live",
start_point=1,
initial_point=1
)
Expand Down

0 comments on commit 995ab27

Please sign in to comment.