From fcfe4007179dc20d954a965947182e66dafc05ae Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Mon, 16 Aug 2021 15:25:45 +0100 Subject: [PATCH 1/2] tests/f: simplify api-workflow-info * replace custom script with the cylc client command --- .../00-get-graph-raw-1/flow.cylc | 16 ++++++-- .../01-get-graph-raw-2/flow.cylc | 20 +++++++--- .../02-get-graph-raw-3/flow.cylc | 20 +++++++--- .../03-get-graph-raw-4/flow.cylc | 22 ++++++---- .../api-workflow-info/bin/ctb-get-graph-raw | 40 ------------------- 5 files changed, 54 insertions(+), 64 deletions(-) delete mode 100755 tests/functional/api-workflow-info/bin/ctb-get-graph-raw diff --git a/tests/functional/api-workflow-info/00-get-graph-raw-1/flow.cylc b/tests/functional/api-workflow-info/00-get-graph-raw-1/flow.cylc index 19c60dd40fe..f36c48b9eed 100644 --- a/tests/functional/api-workflow-info/00-get-graph-raw-1/flow.cylc +++ b/tests/functional/api-workflow-info/00-get-graph-raw-1/flow.cylc @@ -4,10 +4,18 @@ [runtime] [[t1]] script = """ -python3 ${CYLC_WORKFLOW_RUN_DIR}/bin/ctb-get-graph-raw \ - 'start_point_str=1' 'stop_point_str=1' 'grouping=' \ - >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" -""" + cylc client \ + "$CYLC_WORKFLOW_NAME" \ + get_graph_raw \ + >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" \ + <<__HERE__ + { + "start_point_str": "1", + "stop_point_str": "1", + "grouping": [""] + } + __HERE__ + """ [[T]] script = true [[t2, t3]] diff --git a/tests/functional/api-workflow-info/01-get-graph-raw-2/flow.cylc b/tests/functional/api-workflow-info/01-get-graph-raw-2/flow.cylc index 1fa8df7369f..71040e367c4 100644 --- a/tests/functional/api-workflow-info/01-get-graph-raw-2/flow.cylc +++ b/tests/functional/api-workflow-info/01-get-graph-raw-2/flow.cylc @@ -8,9 +8,17 @@ [runtime] [[t1]] script = """ -if [[ "${CYLC_TASK_CYCLE_POINT}" == '2020' ]]; then - python3 ${CYLC_WORKFLOW_RUN_DIR}/bin/ctb-get-graph-raw \ - 'start_point_str=2020' 'stop_point_str=2021' 'grouping=' \ - >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" -fi -""" + if [[ "${CYLC_TASK_CYCLE_POINT}" == '2020' ]]; then + cylc client \ + "$CYLC_WORKFLOW_NAME" \ + get_graph_raw \ + >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" \ + <<__HERE__ + { + "start_point_str": "2020", + "stop_point_str": "2021", + "grouping": [""] + } + __HERE__ + fi + """ diff --git a/tests/functional/api-workflow-info/02-get-graph-raw-3/flow.cylc b/tests/functional/api-workflow-info/02-get-graph-raw-3/flow.cylc index 1fa8df7369f..71040e367c4 100644 --- a/tests/functional/api-workflow-info/02-get-graph-raw-3/flow.cylc +++ b/tests/functional/api-workflow-info/02-get-graph-raw-3/flow.cylc @@ -8,9 +8,17 @@ [runtime] [[t1]] script = """ -if [[ "${CYLC_TASK_CYCLE_POINT}" == '2020' ]]; then - python3 ${CYLC_WORKFLOW_RUN_DIR}/bin/ctb-get-graph-raw \ - 'start_point_str=2020' 'stop_point_str=2021' 'grouping=' \ - >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" -fi -""" + if [[ "${CYLC_TASK_CYCLE_POINT}" == '2020' ]]; then + cylc client \ + "$CYLC_WORKFLOW_NAME" \ + get_graph_raw \ + >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" \ + <<__HERE__ + { + "start_point_str": "2020", + "stop_point_str": "2021", + "grouping": [""] + } + __HERE__ + fi + """ diff --git a/tests/functional/api-workflow-info/03-get-graph-raw-4/flow.cylc b/tests/functional/api-workflow-info/03-get-graph-raw-4/flow.cylc index 13528558f6a..de6b72558e3 100644 --- a/tests/functional/api-workflow-info/03-get-graph-raw-4/flow.cylc +++ b/tests/functional/api-workflow-info/03-get-graph-raw-4/flow.cylc @@ -8,11 +8,17 @@ [runtime] [[t1]] script = """ -if [[ "${CYLC_TASK_CYCLE_POINT}" == '20200202T0000Z' ]]; then - python3 ${CYLC_WORKFLOW_RUN_DIR}/bin/ctb-get-graph-raw \ - 'start_point_str=20200202T0000Z' \ - 'stop_point_str=20200203T0000Z' \ - 'grouping=' \ - >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" -fi -""" + if [[ "${CYLC_TASK_CYCLE_POINT}" == '20200202T0000Z' ]]; then + cylc client \ + "$CYLC_WORKFLOW_NAME" \ + get_graph_raw \ + >"${CYLC_WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" \ + <<__HERE__ + { + "start_point_str": "20200202T0000Z", + "stop_point_str": "20200203T0000Z", + "grouping": [""] + } + __HERE__ + fi + """ diff --git a/tests/functional/api-workflow-info/bin/ctb-get-graph-raw b/tests/functional/api-workflow-info/bin/ctb-get-graph-raw deleted file mode 100755 index 49e9267bd10..00000000000 --- a/tests/functional/api-workflow-info/bin/ctb-get-graph-raw +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 - -# 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 . -"""Workflow Info API test, get_graph_raw.""" - -import json -import os -import sys - -from cylc.flow.network.client import WorkflowRuntimeClient - - -def main(): - kwargs = {} - for item in sys.argv[1:]: - key, value = item.split('=', 1) - if key == "grouping": - kwargs[key] = [value] - else: - kwargs[key] = value - client = WorkflowRuntimeClient(os.environ['CYLC_WORKFLOW_NAME']) - print(json.dumps(client('get_graph_raw', kwargs), indent=4)) - - -if __name__ == "__main__": - main() From 954b5ced3da7e50672696f82904c74bf4d7f1358 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Mon, 16 Aug 2021 16:04:17 +0100 Subject: [PATCH 2/2] tests/f: api-suite-info/00 - de-flaky test * fix sort order of config items in output --- cylc/flow/config.py | 9 +++++++-- cylc/flow/scheduler.py | 3 ++- tests/functional/api-workflow-info/00-get-graph-raw-1.t | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cylc/flow/config.py b/cylc/flow/config.py index 21c43cc7a56..d3b65af4850 100644 --- a/cylc/flow/config.py +++ b/cylc/flow/config.py @@ -480,6 +480,7 @@ def __init__( else: if foot not in self.feet: self.feet.append(foot) + self.feet.sort() # sort effects get_graph_raw output # Replace workflow and task name in workflow and task URLs. self.cfg['meta']['URL'] = self.cfg['meta']['URL'] % { @@ -1434,8 +1435,12 @@ def _check_explicit_cycling(self): taskdef.check_for_explicit_cycling() def get_task_name_list(self): - # return a list of all tasks used in the dependency graph - return list(self.taskdefs) + """Return a sorted list of all tasks used in the dependency graph. + + Note: the sort order may effect get_graph_raw ouput. + + """ + return sorted(self.taskdefs) def generate_edges(self, lexpr, orig_lexpr, left_nodes, right, seq, suicide=False): diff --git a/cylc/flow/scheduler.py b/cylc/flow/scheduler.py index 6316c926e51..5213c80627c 100644 --- a/cylc/flow/scheduler.py +++ b/cylc/flow/scheduler.py @@ -814,7 +814,8 @@ def info_get_graph_raw(self, cto, ctn, grouping=None): self.config.get_graph_raw(cto, ctn, grouping), self.config.workflow_polling_tasks, self.config.leaves, - self.config.feet) + self.config.feet + ) def command_stop( self, diff --git a/tests/functional/api-workflow-info/00-get-graph-raw-1.t b/tests/functional/api-workflow-info/00-get-graph-raw-1.t index 2225973929b..824d49522a3 100644 --- a/tests/functional/api-workflow-info/00-get-graph-raw-1.t +++ b/tests/functional/api-workflow-info/00-get-graph-raw-1.t @@ -64,8 +64,8 @@ cmp_ok "${WORKFLOW_RUN_DIR}/ctb-get-graph-raw.out" <<'__OUT__' "t3" ], [ - "t1", - "T" + "T", + "t1" ] ] __OUT__