diff --git a/changes.d/6528.fix.md b/changes.d/6528.fix.md new file mode 100644 index 00000000000..0eca13ae2c8 --- /dev/null +++ b/changes.d/6528.fix.md @@ -0,0 +1 @@ +Make start-tasks wait on xtriggers (see "cylc play --start-task"). diff --git a/cylc/flow/scheduler.py b/cylc/flow/scheduler.py index bbb1bc38b27..dec3a279ce9 100644 --- a/cylc/flow/scheduler.py +++ b/cylc/flow/scheduler.py @@ -837,8 +837,10 @@ def _load_pool_from_tasks(self): """Load task pool with specified tasks, for a new run.""" LOG.info(f"Start task: {self.options.starttask}") # flow number set in this call: - self.pool.force_trigger_tasks( + self.pool.set_prereqs_and_outputs( self.options.starttask, + outputs=[], + prereqs=["all"], flow=[FLOW_NEW], flow_descr=f"original flow from {self.options.starttask}" ) diff --git a/cylc/flow/scheduler_cli.py b/cylc/flow/scheduler_cli.py index 14c4a7ae77c..005548a27ec 100644 --- a/cylc/flow/scheduler_cli.py +++ b/cylc/flow/scheduler_cli.py @@ -196,12 +196,13 @@ OptionSettings( ["--start-task", "--starttask", "-t"], help=( - "Start from this task instance, given by '/'." - " This can be used multiple times to start from multiple" - " tasks at once. Dependence on tasks with cycle points earlier" - " than the earliest start-task will be ignored. A" - " sub-graph of the workflow will run if selected tasks do" - " not lead on to the full graph."), + "Start from this task instance instead of the beginning of the" + " graph. Dependence on other tasks is ignored but clock and" + " xtriggers are respected. Reuse the option for multiple start" + " tasks. Any dependence on cycle points prior to the earliest" + " start task will be ignored throughout the graph. Check that" + " start tasks flow into the full downstream graph, if needed." + ), metavar="TASK_ID", action='append', dest="starttask", diff --git a/tests/functional/cylc-play/05-start-task.t b/tests/functional/cylc-play/05-start-task.t deleted file mode 100644 index 9db6c6d1165..00000000000 --- a/tests/functional/cylc-play/05-start-task.t +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. -# Copyright (C) NIWA & British Crown (Met Office) & Contributors. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# ----------------------------------------------------------------------------- -# Test start-up with --start-task - -. "$(dirname "$0")/test_header" -set_test_number 2 - -install_workflow "${TEST_NAME_BASE}" - -run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" - -workflow_run_ok "${TEST_NAME_BASE}-run" \ - cylc play --no-detach --reference-test -t 3/bar -t 3/war "${WORKFLOW_NAME}" - -purge diff --git a/tests/functional/cylc-play/05-start-task/flow.cylc b/tests/functional/cylc-play/05-start-task/flow.cylc deleted file mode 100644 index e452d459ef4..00000000000 --- a/tests/functional/cylc-play/05-start-task/flow.cylc +++ /dev/null @@ -1,12 +0,0 @@ -[scheduling] - cycling mode = integer - initial cycle point = 1 - final cycle point = 3 - [[graph]] - P1 = """ - foo => bar => baz - woo => war => waz - """ -[runtime] - [[foo, bar, baz]] - [[woo, war, waz]] diff --git a/tests/functional/cylc-play/05-start-task/reference.log b/tests/functional/cylc-play/05-start-task/reference.log deleted file mode 100644 index 50123a29da4..00000000000 --- a/tests/functional/cylc-play/05-start-task/reference.log +++ /dev/null @@ -1,7 +0,0 @@ -Start task: ['3/bar', '3/war'] -Initial point: 1 -Final point: 3 -3/bar -triggered off [] -3/war -triggered off [] -3/baz -triggered off ['3/bar'] -3/waz -triggered off ['3/war'] diff --git a/tests/integration/test_task_pool.py b/tests/integration/test_task_pool.py index 94eb780a177..ffb255c0cf5 100644 --- a/tests/integration/test_task_pool.py +++ b/tests/integration/test_task_pool.py @@ -2305,3 +2305,80 @@ async def test_job_insert_on_crash(one_conf, flow, scheduler, start): # and a job entry should be added assert len(task_1.jobs) == 1 + + +async def test_start_tasks( + flow, + scheduler, + start, + log_filter, + capture_submission, +): + """Check starting from "start-tasks" with and without clock-triggers. + + """ + id_ = flow( + { + 'scheduler': { + 'cycle point format': '%Y', + }, + 'scheduling': { + 'initial cycle point': '2040', + 'runahead limit': 'P0Y', + 'xtriggers': { + 'wall_clock_satisfied': "wall_clock(offset='-P100Y')" + }, + 'graph': { + 'P1Y': """ + foo + @wall_clock => bar + @wall_clock_satisfied => baz + qux + """ + } + } + } + ) + schd = scheduler( + id_, + starttask=['2050/foo', '2050/bar', '2050/baz'], + paused_start=False + ) + + async with start(schd) as log: + # capture any job submissions + submitted_tasks = capture_submission(schd) + assert submitted_tasks == set() + + # It should start up with: + # - 2050/foo and 2051/foo (spawned to runahead limit) + # - 2050/bar waiting on its (unsatisfied) clock-trigger + # - 2050/baz waiting on its (satisfied) clock-trigger + # - no qux instances (not listed as a start-task) + itasks = schd.pool.get_tasks() + assert ( + set(itask.identity for itask in itasks) == set([ + "2050/foo", + "2051/foo", + "2050/bar", + "2050/baz", + ]) + ) + + # Check xtriggers + for itask in itasks: + schd.pool.xtrigger_mgr.call_xtriggers_async(itask) + schd.pool.rh_release_and_queue(itask) + + # Release tasks that are ready to run. + schd.release_tasks_to_run() + + # It should submit 2050/foo, 2051/foo, 2050/baz + # It should not submit 2050/bar (waiting on clock trigger) + assert ( + set(itask.identity for itask in submitted_tasks) == set([ + "2050/foo", + "2051/foo", + "2050/baz", + ]) + )