Skip to content

Commit 4d41817

Browse files
remove Cylc 7 compat mode
* Addresses cylc/cylc-flow#6849
1 parent a7e3406 commit 4d41817

7 files changed

Lines changed: 44 additions & 138 deletions

File tree

cylc/rose/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@
6565
6666
.. note::
6767
68-
For compatibility with Cylc 7, section ``[suite.rc:jinja2]`` will be
69-
processed, but is deprecated and provided for ease of porting Cylc 7
70-
workflows.
68+
The legacy ``[suite.rc:jinja2]`` section remains supported, but is
69+
deprecated, please rename it to ``[template variables]``.
7170
7271
7372
The ``global.cylc`` file

cylc/rose/platform_utils.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"""Interfaces for Cylc Platforms for use by rose apps."""
2020

2121
from optparse import Values
22-
from pathlib import Path
2322
import sqlite3
2423
import subprocess
2524
import sys
@@ -28,15 +27,13 @@
2827
Any,
2928
Dict,
3029
Tuple,
31-
Union,
3230
)
3331

3432
from cylc.flow.config import WorkflowConfig
3533
from cylc.flow.exceptions import PlatformLookupError
3634
from cylc.flow.id_cli import parse_id
3735
from cylc.flow.pathutil import (
3836
get_workflow_run_config_log_dir,
39-
get_workflow_run_dir,
4037
get_workflow_run_pub_db_path,
4138
)
4239
from cylc.flow.platforms import (
@@ -67,11 +64,7 @@ def get_platform_from_task_def(flow: str, task: str) -> Dict[str, Any]:
6764
WorkflowFiles.FLOW_FILE_PROCESSED,
6865
)
6966

70-
config = WorkflowConfig(
71-
flow,
72-
flow_file, Values(),
73-
force_compat_mode=get_compat_mode(get_workflow_run_dir(workflow_id))
74-
)
67+
config = WorkflowConfig(flow, flow_file, Values())
7568
# Get entire task spec to allow Cylc 7 platform from host guessing.
7669
task_spec = config.pcfg.get(['runtime', task])
7770
# check for subshell and evaluate
@@ -90,17 +83,6 @@ def get_platform_from_task_def(flow: str, task: str) -> Dict[str, Any]:
9083
return platform
9184

9285

93-
def get_compat_mode(run_dir: Union[str, Path]) -> bool:
94-
"""Check whether this is a Cylc 7 Back compatibility mode workflow:
95-
96-
See https://github.com/cylc/cylc-rose/issues/319
97-
98-
Args:
99-
run_dir: Cylc workflow run directory.
100-
"""
101-
return (Path(run_dir) / WorkflowFiles.SUITE_RC).exists()
102-
103-
10486
def eval_subshell(platform):
10587
"""Evaluates platforms/hosts defined as subshell"""
10688
match = HOST_REC_COMMAND.match(platform)

cylc/rose/utilities.py

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
from cylc.flow import LOG
3838
from cylc.flow.exceptions import CylcError
39-
from cylc.flow.flags import cylc7_back_compat
4039
from cylc.flow.cfgspec.glbl_cfg import glbl_cfg
4140
from cylc.flow.hostuserutil import get_host
4241
from metomi.isodatetime.datetimeoper import DateTimeOperator
@@ -65,8 +64,6 @@
6564
ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING = (
6665
' ROSE_ORIG_HOST set by cylc install.'
6766
)
68-
MESSAGE = 'message'
69-
ALL_MODES = 'all modes'
7067
STANDARD_VARS = [
7168
('ROSE_ORIG_HOST', get_host()),
7269
('ROSE_VERSION', ROSE_VERSION),
@@ -774,42 +771,30 @@ def deprecation_warnings(config_tree):
774771
- "root-dir"
775772
- "jinja2:suite.rc"
776773
- root-dir
777-
778-
If ALL_MODES is True this deprecation will ignore whether there is a
779-
flow.cylc or suite.rc in the workflow directory.
780774
"""
781-
782-
deprecations = {
783-
'jinja2:suite.rc': {
784-
MESSAGE: (
785-
"'rose-suite.conf[jinja2:suite.rc]' is deprecated."
786-
" Use [template variables] instead."
787-
),
788-
ALL_MODES: False,
789-
},
790-
'jinja2:flow.cylc': {
791-
MESSAGE: (
792-
"'rose-suite.conf[jinja2:flow.cylc]' is not used by Cylc."
793-
" Use [template variables] instead."
794-
),
795-
ALL_MODES: False,
796-
},
797-
'root-dir': {
798-
MESSAGE: (
799-
'You have set "rose-suite.conf[root-dir]", '
800-
'which is not supported at '
801-
'Cylc 8. Use `[install] symlink dirs` in global.cylc '
802-
'instead.'
803-
),
804-
ALL_MODES: True,
805-
},
806-
}
775+
deprecations = (
776+
(
777+
'jinja2:suite.rc',
778+
"'rose-suite.conf[jinja2:suite.rc]' is deprecated."
779+
" Use [template variables] instead.",
780+
),
781+
(
782+
'jinja2:flow.cylc',
783+
"'rose-suite.conf[jinja2:flow.cylc]' is not used by Cylc."
784+
" Use [template variables] instead.",
785+
),
786+
(
787+
'root-dir',
788+
'You have set "rose-suite.conf[root-dir]", '
789+
'which is not supported at '
790+
'Cylc 8. Use `[install] symlink dirs` in global.cylc '
791+
'instead.',
792+
),
793+
)
807794
for string in list(config_tree.node):
808-
for name, info in deprecations.items():
809-
if (
810-
info[ALL_MODES] or not cylc7_back_compat
811-
) and name in string.lower():
812-
LOG.warning(info[MESSAGE])
795+
for name, info in deprecations:
796+
if name in string.lower():
797+
LOG.warning(info)
813798

814799

815800
def load_rose_config(

tests/conftest.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,12 @@ def _pytest_passed(request: pytest.FixtureRequest) -> bool:
187187
def _cylc_inspection_cli(capsys, caplog, script, gop):
188188
"""Access the CLI for cylc scripts inspecting configurations
189189
"""
190-
async def _inner(srcpath, args=None, n_args=3):
190+
async def _inner(srcpath, args=None):
191191
parser = gop()
192192
options = Options(parser, args)()
193193
output = SimpleNamespace()
194194

195-
if n_args == 3:
196-
await script(parser, options, str(srcpath))
197-
if n_args == 2:
198-
# Don't include the parser:
199-
await script(options, str(srcpath))
195+
await script(options, str(srcpath))
200196

201197
output.logging = '\n'.join([i.message for i in caplog.records])
202198
output.out, output.err = capsys.readouterr()
@@ -310,13 +306,13 @@ async def _inner(wid, args):
310306
results = {}
311307

312308
# Handle scripts taking a parser or just the output of the parser:
313-
for script_name, n_args in {
314-
'config': 3,
315-
'list': 2,
316-
'graph': 2,
317-
'view': 2,
318-
'validate': 3,
319-
}.items():
309+
for script_name in (
310+
'config',
311+
'list',
312+
'graph',
313+
'view',
314+
'validate',
315+
):
320316

321317
# Import the script modules:
322318
script_module = importlib.import_module(
@@ -330,7 +326,7 @@ async def _inner(wid, args):
330326
script = script_module.run
331327
else:
332328
raise UsageError(
333-
f'Script "{script}\'s" module does not contain a '
329+
f'"{script_name}\" does not contain a '
334330
'"_main" or "run" function'
335331
)
336332

@@ -343,7 +339,7 @@ async def _inner(wid, args):
343339
caplog,
344340
script,
345341
script_module.get_option_parser,
346-
)(wid, args, n_args=n_args)
342+
)(wid, args)
347343

348344
# Return results for more checking if required:
349345
return results

tests/functional/test_pre_configure.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,19 @@ def test_warn_if_root_dir_set(root_dir_config, tmp_path, caplog):
110110
assert msg in caplog.records[0].msg
111111

112112

113-
@pytest.mark.parametrize(
114-
'compat_mode',
115-
[
116-
pytest.param(True, id='back-compat'),
117-
pytest.param(False, id='no-back-compat')
118-
]
119-
)
120113
@pytest.mark.parametrize(
121114
'rose_config', [
122115
'jinja2:suite.rc',
123116
'jinja2:flow.cylc',
124117
'JinjA2:flOw.cylC',
125118
]
126119
)
127-
def test_warn_if_old_templating_set(
128-
compat_mode, rose_config, tmp_path, caplog, monkeypatch
129-
):
120+
def test_warn_if_old_templating_set(rose_config, tmp_path, caplog):
130121
"""Test using unsupported root-dir config raises error."""
131-
monkeypatch.setattr(
132-
'cylc.rose.utilities.cylc7_back_compat', compat_mode
133-
)
134122
(tmp_path / 'rose-suite.conf').write_text(f'[{rose_config}]')
135123
load_rose_config(tmp_path)
136124
msg = "Use [template variables]"
137-
if compat_mode:
138-
assert not caplog.records
139-
else:
140-
assert msg in caplog.records[0].message
125+
assert msg in caplog.records[0].message
141126

142127

143128
@pytest.mark.parametrize(

tests/unit/test_config_node.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -281,27 +281,8 @@ def test_ROSE_ORIG_HOST_replacement_behaviour(
281281
assert node['env']['ROSE_ORIG_HOST'].value == 'IMPLAUSIBLE_HOST_NAME'
282282

283283

284-
@pytest.mark.parametrize(
285-
'compat_mode, must_include, must_exclude',
286-
(
287-
(True, None, 'Use [template variables]'),
288-
(True, 'root-dir', None),
289-
(False, 'Use [template variables]', None),
290-
(False, 'root-dir', None),
291-
)
292-
)
293-
def test_deprecation_warnings(
294-
caplog, monkeypatch, compat_mode, must_include, must_exclude
295-
):
296-
"""Method logs warnings correctly.
297-
298-
Two node items are set:
299-
300-
* ``jinja2:suite.rc`` should not cause a warning in compatibility mode.
301-
* ``root-dir=/somewhere`` should always lead to a warning being logged.
302-
303-
Error messages about
304-
"""
284+
def test_deprecation_warnings(caplog):
285+
"""It should warn over deprecated Rose config sections."""
305286
# Create a node to pass to the method
306287
# (It's not a tree test because we can use a simpleNamespace in place of
307288
# a tree object):
@@ -310,16 +291,13 @@ def test_deprecation_warnings(
310291
node.set(['root-dir', '~foo'])
311292
tree = SimpleNamespace(node=node)
312293

313-
# Patch compatibility mode flag and run the function under test:
314-
monkeypatch.setattr('cylc.rose.utilities.cylc7_back_compat', compat_mode)
315294
deprecation_warnings(tree)
316295

317296
# Check that warnings have/not been logged:
318-
records = '\n'.join([i.message for i in caplog.records])
319-
if must_include:
320-
assert must_include in records
321-
else:
322-
assert must_exclude not in records
297+
records = '\n'.join(i.message for i in caplog.records)
298+
299+
assert 'root-dir' in records
300+
assert 'Use [template variables]' in records
323301

324302

325303
@pytest.mark.parametrize(

tests/unit/test_platform_utils.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from uuid import uuid4
2626

2727
from cylc.rose.platform_utils import (
28-
get_compat_mode,
2928
get_platform_from_task_def,
3029
get_platforms_from_task_jobs,
3130
)
@@ -215,24 +214,6 @@ def test_get_platform_from_task_def_subshell(
215214
assert platform['name'] == expected
216215

217216

218-
@pytest.mark.parametrize(
219-
'create, expect',
220-
(
221-
(['suite.rc', 'log/conf/flow-processed.cylc'], True),
222-
(['suite.rc', 'foo/bar/any-old.file'], True),
223-
(['flow.cylc', 'log/conf/flow-processed.cylc'], False),
224-
(['flow.cylc', 'where/flow-processed.cylc'], False),
225-
)
226-
)
227-
def test_get_compat_mode(tmp_path, create, expect):
228-
"""It checks whether there is a suite.rc two directories up."""
229-
for file in create:
230-
file = tmp_path / file
231-
file.parent.mkdir(parents=True, exist_ok=True)
232-
file.touch()
233-
assert get_compat_mode(tmp_path) == expect
234-
235-
236217
@pytest.mark.parametrize(
237218
'task, cycle, expect',
238219
[

0 commit comments

Comments
 (0)