-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added suite state xtrigger for back commpat
extended back compat a unit test added deprecation log message refactored implementation flake8 review amends added test for warning text review amends more review ammends Replace icky unit test with functional test (#4) * Replace icky unit test with functional test * Update changelog
- Loading branch information
Mark Dawson
committed
Jan 26, 2024
1 parent
efb3016
commit 95d0e59
Showing
4 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reimplemented the `suite-state` xtrigger for interoperability with Cylc 7. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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 <http://www.gnu.org/licenses/>. | ||
|
||
from cylc.flow import LOG | ||
import cylc.flow.flags | ||
from cylc.flow.xtriggers.workflow_state import workflow_state | ||
|
||
if not cylc.flow.flags.cylc7_back_compat: | ||
LOG.warning( | ||
"The suite_state xtrigger is deprecated. " | ||
"Please use the workflow_state xtrigger instead." | ||
) | ||
|
||
|
||
def suite_state(suite, task, point, offset=None, status='succeeded', | ||
message=None, cylc_run_dir=None, debug=False): | ||
'''The suite_state xtrigger was renamed to workflow_state, | ||
this breaks Cylc 7-8 interoperability. | ||
This suite_state xtrigger replicates | ||
workflow_state - ensuring back-support''' | ||
return workflow_state( | ||
workflow=suite, | ||
task=task, | ||
point=point, | ||
offset=offset, | ||
status=status, | ||
message=message, | ||
cylc_run_dir=cylc_run_dir | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/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 <http://www.gnu.org/licenses/>. | ||
|
||
# Test that deprecation warnings are printed appropriately for the suite_state | ||
# xtrigger. | ||
|
||
. "$(dirname "$0")/test_header" | ||
|
||
set_test_number 4 | ||
|
||
init_workflow "$TEST_NAME_BASE" << __FLOW_CONFIG__ | ||
[scheduling] | ||
initial cycle point = 2000 | ||
[[dependencies]] | ||
[[[R1]]] | ||
graph = @upstream => foo | ||
[[xtriggers]] | ||
upstream = suite_state(suite=thorin/oin/gloin, task=mithril, point=1) | ||
[runtime] | ||
[[foo]] | ||
__FLOW_CONFIG__ | ||
|
||
msg='WARNING - The suite_state xtrigger is deprecated' | ||
|
||
TEST_NAME="${TEST_NAME_BASE}-val" | ||
run_ok "$TEST_NAME" cylc validate "$WORKFLOW_NAME" | ||
|
||
grep_ok "$msg" "${TEST_NAME}.stderr" | ||
|
||
# Rename flow.cylc to suite.rc: | ||
mv "${WORKFLOW_RUN_DIR}/flow.cylc" "${WORKFLOW_RUN_DIR}/suite.rc" | ||
|
||
TEST_NAME="${TEST_NAME_BASE}-val-2" | ||
run_ok "$TEST_NAME" cylc validate "$WORKFLOW_NAME" | ||
|
||
grep_fail "$msg" "${TEST_NAME}.stderr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters