Skip to content

Commit

Permalink
scheduler, task_pool, task_proxy refactor
Browse files Browse the repository at this point in the history
Test `cylc reset --output=OUTPUT ...`.
Test `cylc submit FAM.CYCLE` - multi-level family.
  • Loading branch information
matthewrmshin committed Mar 29, 2017
1 parent e5eeeb3 commit db0b2c6
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 13 deletions.
13 changes: 8 additions & 5 deletions bin/cylc-reset
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def main():
help="Reset task state to STATE, can be %s" % (
', '.join(TASK_STATUSES_CAN_RESET_TO)),
choices=list(TASK_STATUSES_CAN_RESET_TO),
action="store", default=None, dest="state")
action="store", dest="state")

parser.add_option(
"--output", "-O",
metavar="MESSAGE|TRIGGER",
metavar="OUTPUT",
help=("Find task output by message string or trigger string, " +
"set complete or incomplete with !MESSAGE or !TRIGGER, " +
"set complete or incomplete with !OUTPUT, " +
"'*' to set all complete, '!*' to set all incomplete. " +
"Can be used more than once to reset multiple task outputs."),
action="append", default=[], dest="outputs")
Expand All @@ -70,6 +70,9 @@ def main():

suite = args.pop(0)

if not options.state and not options.outputs:
parser.error("Neither --state=STATE nor --output=OUTPUT is set")

if options.state == "spawn":
# Back compat.
sys.stderr.write(
Expand All @@ -82,8 +85,8 @@ def main():
exc.filename = cmd
raise SystemExit(exc)

if options.state not in TASK_STATUSES_CAN_RESET_TO:
parser.error("Illegal STATE value: " + options.state)
if not options.state:
options.state = ''

prompt('Reset task(s) %s in %s' % (args, suite), options.force)
pclient = SuiteCommandClient(
Expand Down
2 changes: 2 additions & 0 deletions lib/cylc/network/https/suite_command_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def set_verbosity(self, level):
def reset_task_states(self, items, state=None, outputs=None):
if not isinstance(items, list):
items = [items]
if outputs and not isinstance(outputs, list):
outputs = [outputs]
return self._put(
"reset_task_states",
(items,), {"state": state, "outputs": outputs})
Expand Down
13 changes: 7 additions & 6 deletions lib/cylc/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,18 +1077,19 @@ def reset_task_states(self, items, status, outputs):
ret = itask.state.outputs.set_completed(
message=output, is_completed=is_completed)
if ret is None:
itask.state.outputs.set_completed(
ret = itask.state.outputs.set_completed(
trigger=output, is_completed=is_completed)
if ret is None:
LOG.warning(
"cannot reset output %s" % output, itask=itask)
elif ret and is_completed:
LOG.info(
"reset output to complete %s" % output,
"cannot reset output: %s" % output,
itask=itask)
elif ret:
LOG.info(
"reset output to incomplete %s" % output,
"reset output to complete: %s" % output,
itask=itask)
else:
LOG.info(
"reset output to incomplete: %s" % output,
itask=itask)
return len(bad_items)

Expand Down
28 changes: 28 additions & 0 deletions tests/cylc-reset/02-output-1.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2017 NIWA
#
# 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 <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test "cylc reset --output='TRIGGER|MESSAGE' 'SUITE' 'TASK.ID'".
. "$(dirname "$0")/test_header"

set_test_number 2
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
run_ok "${TEST_NAME_BASE}" cylc run --reference-test --debug "${SUITE_NAME}"

purge_suite "${SUITE_NAME}"
exit
6 changes: 6 additions & 0 deletions tests/cylc-reset/02-output-1/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
2016-01-14T11:55:10Z INFO - Initial point: 1
2016-01-14T11:55:10Z INFO - Final point: 1
2016-01-14T11:55:10Z INFO - [t1.1] -triggered off []
2016-01-14T11:55:10Z INFO - [t2.1] -triggered off []
2016-01-14T11:55:10Z INFO - [t3.1] -triggered off ['t1.1', 't2.1']
2016-01-14T11:55:13Z INFO - [t4.1] -triggered off ['t1.1', 't2.1']
39 changes: 39 additions & 0 deletions tests/cylc-reset/02-output-1/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[cylc]
UTC mode = True
[[events]]
abort on stalled = True
[[reference test]]
live mode suite timeout = PT1M
required run mode = live
[scheduling]
[[dependencies]]
graph = """
t1 => t3
t2 => t3
t1:hello & t2:greet => t4
"""
[runtime]
[[t1]]
script=true
[[[outputs]]]
hello = Hello World
[[t2]]
script=true
[[[outputs]]]
greet = Greet World
[[t3]]
script = """
LOG="${CYLC_SUITE_LOG_DIR}/log"
cylc reset --debug --output=hello "${CYLC_SUITE_NAME}" 't1.1'
while ! grep -qF '[t1.1] -reset output to complete: hello' "${LOG}"; do
sleep 1 # make sure reset completes
done
cylc reset --debug --output='Greet World' "${CYLC_SUITE_NAME}" 't2.1'
while ! grep -qF '[t2.1] -reset output to complete: Greet World' "${LOG}"; do
sleep 1 # make sure reset completes
done
"""
[[[job]]]
execution time limit = PT30S
[[t4]]
script = true
41 changes: 41 additions & 0 deletions tests/cylc-reset/03-output-2.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2017 NIWA
#
# 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 <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test "cylc reset --output='!OUTPUT' 'SUITE' 'TASK.ID'".
. "$(dirname "$0")/test_header"

set_test_number 3
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
run_ok "${TEST_NAME_BASE}" cylc run --reference-test --debug "${SUITE_NAME}"
cmp_ok "${SUITE_RUN_DIR}/cylc-show.out" <<'__OUT__'
title: (not given)
description: (not given)
prerequisites (- => not satisfied):
(None)
outputs (- => not completed):
+ t1.1 submitted
+ t1.1 started
+ t1.1 succeeded
- t1.1 Greet World
- t1.1 Hello World
__OUT__
purge_suite "${SUITE_NAME}"
exit
4 changes: 4 additions & 0 deletions tests/cylc-reset/03-output-2/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2016-01-14T11:55:10Z INFO - Initial point: 1
2016-01-14T11:55:10Z INFO - Final point: 1
2016-01-14T11:55:10Z INFO - [t1.1] -triggered off []
2016-01-14T11:55:10Z INFO - [t2.1] -triggered off ['t1.1']
30 changes: 30 additions & 0 deletions tests/cylc-reset/03-output-2/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[cylc]
UTC mode = True
[[events]]
abort on stalled = True
[[reference test]]
live mode suite timeout = PT1M
required run mode = live
[scheduling]
[[dependencies]]
graph = t1 => t2
[runtime]
[[t1]]
script=true
[[[outputs]]]
hello = Hello World
greet = Greet World
[[t2]]
script = """
LOG="${CYLC_SUITE_LOG_DIR}/log"
cylc reset --output='!hello' --output='!Greet World' "${CYLC_SUITE_NAME}" 't1.1'
while ! grep -qF -e '[t1.1] -reset output to incomplete: hello' "${LOG}"; do
sleep 1 # make sure reset completes
done
while ! grep -qF '[t1.1] -reset output to incomplete: Greet World' "${LOG}"; do
sleep 1 # make sure reset completes
done
cylc show "${CYLC_SUITE_NAME}" 't1.1' >"${CYLC_SUITE_RUN_DIR}/cylc-show.out"
"""
[[[job]]]
execution time limit = PT30S
10 changes: 8 additions & 2 deletions tests/cylc-submit/11-multi.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ init_suite "${TEST_NAME_BASE}" <<'__SUITE_RC__'
[runtime]
[[FOO]]
script = echo "${CYLC_TASK_ID}"
[[foo1, foo2, foo3]]
[[FOO1, FOO2, FOO3]]
inherit = FOO
[[food]]
inherit = FOO1
[[fool]]
inherit = FOO2
[[foot]]
inherit = FOO3
[[bar]]
script = echo "${CYLC_TASK_ID}"
__SUITE_RC__

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
run_ok "${TEST_NAME_BASE}" cylc submit "${SUITE_NAME}" 'FOO.2020' 'bar.2021'
for TASK_ID in 'foo1.2020' 'foo2.2020' 'foo3.2020' 'bar.2021'; do
for TASK_ID in 'food.2020' 'fool.2020' 'foot.2020' 'bar.2021'; do
POINT="${TASK_ID#*.}"
NAME="${TASK_ID%.*}"
ST_FILE="${SUITE_RUN_DIR}/log/job/${POINT}/${NAME}/01/job.status"
Expand Down

0 comments on commit db0b2c6

Please sign in to comment.