Skip to content

Commit dee1183

Browse files
committed
Merge remote-tracking branch 'upstream/1.3.x' into feature.do_not_allow_--defines_no_equal
* upstream/1.3.x: make RoseStemVersionException print the correct missing variable (cylc#252) Update tests/unit/test_rose_stem_units.py Allow top level settings in CLI Config (cylc#221) Prevent accidental manual setting of project name with -s= Fix flake8 Bump dev version Add missing dependency on ansimarkup Prepare release 1.3.0 Bump pypa/gh-action-pypi-publish from 1.8.7 to 1.8.8 (cylc#236) Permitted warnings about root-dir for all versions of Cylc. (cylc#231) Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.7 (cylc#235) Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (cylc#228) 1.3.0 (cylc#219)
2 parents 9f21a2a + 7697d23 commit dee1183

14 files changed

+166
-61
lines changed

Diff for: .github/workflows/2_auto_publish_release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: cylc/release-actions/build-python-package@v1
3939

4040
- name: Publish distribution to PyPI
41-
uses: pypa/[email protected].5
41+
uses: pypa/[email protected].8
4242
with:
4343
user: __token__ # uses the API token feature of PyPI - least permissions possible
4444
password: ${{ secrets.PYPI_TOKEN }}

Diff for: CHANGES.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,28 @@ creating a new release entry be sure to copy & paste the span tag with the
66
updated. Only the first match gets replaced, so it's fine to leave the old
77
ones in. -->
88

9-
## __cylc-rose-1.3.0 (<span actions:bind='release-date'>Awaiting Release</span>)__
9+
## __cylc-rose-1.3.1 (<span actions:bind='release-date'>Upcoming</span>)__
10+
11+
### Fixes
12+
13+
[#250](https://github.com/cylc/cylc-rose/pull/250) - Prevent project
14+
name being manually set to an empty string.
15+
16+
## __cylc-rose-1.3.0 (<span actions:bind='release-date'>Released 2023-07-21</span>)__
1017

1118
### Fixes
1219

1320
[#229](https://github.com/cylc/cylc-rose/pull/229) -
1421
Fix bug which stops rose-stem suites using the new `[template variables]` section
1522
in their `rose-suite.conf` files.
1623

24+
<<<<<<< HEAD
1725
[#225](https://github.com/cylc/cylc-rose/pull/225) - Prevent totally invalid
1826
CLI --defines with no = sign.
27+
=======
28+
[#231](https://github.com/cylc/cylc-rose/pull/231) - Show warning about
29+
`root-dir` config setting in compatibility mode.
30+
>>>>>>> upstream/1.3.x
1931
2032
## __cylc-rose-1.2.0 (<span actions:bind='release-date'>Released 2023-01-16</span>)__
2133

Diff for: cylc/rose/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,4 @@
205205
206206
"""
207207

208-
__version__ = '1.2.1.dev'
208+
__version__ = '1.3.1.dev'

Diff for: cylc/rose/stem.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,17 @@ def __repr__(self):
145145
__str__ = __repr__
146146

147147

148-
class RoseStemVersionException(Exception):
148+
class RoseStemVersionException(CylcError):
149149

150150
"""Exception class when running the wrong rose-stem version."""
151151

152152
def __init__(self, version):
153+
153154
Exception.__init__(self, version)
154155
if version is None:
155156
self.suite_version = (
156-
"does not have ROSE_VERSION set in the rose-suite.conf"
157+
"does not have ROSE_STEM_VERSION set in the "
158+
"rose-suite.conf"
157159
)
158160
else:
159161
self.suite_version = "at version %s" % (version)
@@ -165,7 +167,7 @@ def __repr__(self):
165167
__str__ = __repr__
166168

167169

168-
class RoseSuiteConfNotFoundException(Exception):
170+
class RoseSuiteConfNotFoundException(CylcError):
169171

170172
"""Exception class when unable to find rose-suite.conf."""
171173

@@ -340,7 +342,7 @@ def _ascertain_project(self, item):
340342
if re.search(r'^\.', item):
341343
item = os.path.abspath(os.path.join(os.getcwd(), item))
342344

343-
if project is not None:
345+
if project:
344346
print(f"[WARN] Forcing project for '{item}' to be '{project}'")
345347
return project, item, item, '', ''
346348

Diff for: cylc/rose/utilities.py

+46-24
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from cylc.flow.hostuserutil import get_host
2727
from cylc.flow import LOG
2828
from cylc.flow.exceptions import CylcError
29-
import cylc.flow.flags as flags
29+
from cylc.flow.flags import cylc7_back_compat
3030
from cylc.rose.jinja2_parser import Parser, patch_jinja2_leading_zeros
3131
from metomi.rose import __version__ as ROSE_VERSION
3232
from metomi.isodatetime.datetimeoper import DateTimeOperator
@@ -46,6 +46,8 @@
4646
USER_IGNORE = '!'
4747
TRIGGER_IGNORE = '!!'
4848
IGNORES = (USER_IGNORE, TRIGGER_IGNORE)
49+
MESSAGE = 'message'
50+
ALL_MODES = 'all modes'
4951

5052

5153
class MultipleTemplatingEnginesError(CylcError):
@@ -413,7 +415,7 @@ def parse_cli_define(define: str) -> Union[
413415
# Doesn't have a section:
414416
match = re.match(
415417
r'^(?P<state>!{0,2})(?P<key>.*)\s*=\s*(?P<value>.*)', define)
416-
if match:
418+
if match and not match['state']:
417419
groupdict = match.groupdict()
418420
keys = [groupdict['key'].strip()]
419421
else:
@@ -744,30 +746,50 @@ def deprecation_warnings(config_tree):
744746
- "root-dir"
745747
- "jinja2:suite.rc"
746748
- "empy:suite.rc"
749+
- root-dir
747750
751+
If ALL_MODES is True this deprecation will ignore whether there is a
752+
flow.cylc or suite.rc in the workflow directory.
748753
"""
749754

750755
deprecations = {
751-
'empy:suite.rc': (
752-
"'rose-suite.conf[empy:suite.rc]' is deprecated."
753-
" Use [template variables] instead."),
754-
'jinja2:suite.rc': (
755-
"'rose-suite.conf[jinja2:suite.rc]' is deprecated."
756-
" Use [template variables] instead."),
757-
'empy:flow.cylc': (
758-
"'rose-suite.conf[empy:flow.cylc]' is not used by Cylc."
759-
" Use [template variables] instead."),
760-
'jinja2:flow.cylc': (
761-
"'rose-suite.conf[jinja2:flow.cylc]' is not used by Cylc."
762-
" Use [template variables] instead."),
763-
'root-dir': (
764-
'You have set "rose-suite.conf[root-dir]", '
765-
'which is not supported at '
766-
'Cylc 8. Use `[install] symlink dirs` in global.cylc '
767-
'instead.')
756+
'empy:suite.rc': {
757+
MESSAGE: (
758+
"'rose-suite.conf[empy:suite.rc]' is deprecated."
759+
" Use [template variables] instead."),
760+
ALL_MODES: False,
761+
},
762+
'jinja2:suite.rc': {
763+
MESSAGE: (
764+
"'rose-suite.conf[jinja2:suite.rc]' is deprecated."
765+
" Use [template variables] instead."),
766+
ALL_MODES: False,
767+
},
768+
'empy:flow.cylc': {
769+
MESSAGE: (
770+
"'rose-suite.conf[empy:flow.cylc]' is not used by Cylc."
771+
" Use [template variables] instead."),
772+
ALL_MODES: False,
773+
},
774+
'jinja2:flow.cylc': {
775+
MESSAGE: (
776+
"'rose-suite.conf[jinja2:flow.cylc]' is not used by Cylc."
777+
" Use [template variables] instead."),
778+
ALL_MODES: False,
779+
},
780+
'root-dir': {
781+
MESSAGE: (
782+
'You have set "rose-suite.conf[root-dir]", '
783+
'which is not supported at '
784+
'Cylc 8. Use `[install] symlink dirs` in global.cylc '
785+
'instead.'),
786+
ALL_MODES: True,
787+
},
768788
}
769-
if not flags.cylc7_back_compat:
770-
for string in list(config_tree.node):
771-
for deprecation in deprecations.keys():
772-
if deprecation in string.lower():
773-
LOG.warning(deprecations[deprecation])
789+
for string in list(config_tree.node):
790+
for name, info in deprecations.items():
791+
if (
792+
(info[ALL_MODES] or not cylc7_back_compat)
793+
and name in string.lower()
794+
):
795+
LOG.warning(info[MESSAGE])

Diff for: setup.cfg

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ packages = find_namespace:
5555
python_requires = >=3.7
5656
include_package_data = True
5757
install_requires =
58-
metomi-rose==2.0.*
59-
cylc-flow==8.1.*
58+
metomi-rose==2.1.*
59+
cylc-flow==8.2.*
6060
metomi-isodatetime
61+
ansimarkup
6162
jinja2
6263

6364
[options.packages.find]

Diff for: tests/conftest.py

-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def _cylc_validate_cli(capsys, caplog):
102102
def _inner(srcpath, args=None):
103103
parser = validate_gop()
104104
options = Options(parser, args)()
105-
106105
output = SimpleNamespace()
107106

108107
try:
@@ -130,7 +129,6 @@ def _inner(srcpath, args=None):
130129
args: Dictionary of arguments.
131130
"""
132131
options = Options(install_gop(), args)()
133-
134132
output = SimpleNamespace()
135133

136134
try:
@@ -156,7 +154,6 @@ def _inner(workflow_id, opts=None):
156154
args: Dictionary of arguments.
157155
"""
158156
options = Options(reinstall_gop(), opts)()
159-
160157
output = SimpleNamespace()
161158

162159
try:

Diff for: tests/functional/test_pre_configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_warn_if_old_templating_set(
157157
):
158158
"""Test using unsupported root-dir config raises error."""
159159
monkeypatch.setattr(
160-
cylc.rose.utilities.flags, 'cylc7_back_compat', compat_mode
160+
cylc.rose.utilities, 'cylc7_back_compat', compat_mode
161161
)
162162
(tmp_path / 'rose-suite.conf').write_text(f'[{rose_config}]')
163163
get_rose_vars(srcdir=tmp_path)

Diff for: tests/functional/test_reinstall.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from cylc.flow.pathutil import get_workflow_run_dir
3939
from cylc.rose.utilities import (
4040
ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING as ROHIOS)
41-
from cylc.flow.workflow_files import reinstall_workflow
41+
from cylc.flow.install import reinstall_workflow
4242

4343

4444
HOST = get_host()

Diff for: tests/functional/test_rose_stem.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def test_with_config2(self, with_config2, expected):
570570
assert expected in with_config2['jobout_content']
571571

572572

573-
def test_incompatible_versions(setup_stem_repo, monkeymodule):
573+
def test_incompatible_versions(setup_stem_repo, monkeymodule, caplog, capsys):
574574
"""It fails if trying to install an incompatible version.
575575
"""
576576
# Copy suite into working copy.
@@ -587,7 +587,8 @@ def test_incompatible_versions(setup_stem_repo, monkeymodule):
587587
str(setup_stem_repo['workingcopy']),
588588
"fcm:foo.x_tr@head",
589589
],
590-
'workflow_name': str(setup_stem_repo['suitename'])
590+
'workflow_name': str(setup_stem_repo['suitename']),
591+
'verbosity': 2,
591592
}
592593

593594
monkeymodule.setattr('sys.argv', ['stem'])

Diff for: tests/unit/test_config_node.py

+43
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""Tests the plugin with Rose suite configurations via the Python API."""
1717

1818
import pytest
19+
from types import SimpleNamespace
1920

2021
from metomi.isodatetime.datetimeoper import DateTimeOperator
2122
from metomi.rose import __version__ as ROSE_VERSION
@@ -28,6 +29,7 @@
2829
ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING,
2930
get_rose_vars_from_config_node,
3031
add_cylc_install_to_rose_conf_node_opts,
32+
deprecation_warnings,
3133
dump_rose_log,
3234
identify_templating_section,
3335
MultipleTemplatingEnginesError
@@ -285,3 +287,44 @@ def test_ROSE_ORIG_HOST_replacement_behaviour(
285287
ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING)
286288
assert not caplog.records
287289
assert node['env']['ROSE_ORIG_HOST'].value == 'IMPLAUSIBLE_HOST_NAME'
290+
291+
292+
@pytest.mark.parametrize(
293+
'compat_mode, must_include, must_exclude',
294+
(
295+
(True, None, 'Use [template variables]'),
296+
(True, 'root-dir', None),
297+
(False, 'Use [template variables]', None),
298+
(False, 'root-dir', None),
299+
)
300+
)
301+
def test_deprecation_warnings(
302+
caplog, monkeypatch, compat_mode, must_include, must_exclude
303+
):
304+
"""Method logs warnings correctly.
305+
306+
Two node items are set:
307+
308+
* ``jinja2:suite.rc`` should not cause a warning in compatibility mode.
309+
* ``root-dir=/somewhere`` should always lead to a warning being logged.
310+
311+
Error messages about
312+
"""
313+
# Create a node to pass to the method
314+
# (It's not a tree test because we can use a simpleNamespace in place of
315+
# a tree object):
316+
node = ConfigNode()
317+
node.set(['jinja2:suite.rc'])
318+
node.set(['root-dir', '~foo'])
319+
tree = SimpleNamespace(node=node)
320+
321+
# Patch compatibility mode flag and run the function under test:
322+
monkeypatch.setattr('cylc.rose.utilities.cylc7_back_compat', compat_mode)
323+
deprecation_warnings(tree)
324+
325+
# Check that warnings have/not been logged:
326+
records = '\n'.join([i.message for i in caplog.records])
327+
if must_include:
328+
assert must_include in records
329+
else:
330+
assert must_exclude not in records

Diff for: tests/unit/test_config_tree.py

-19
Original file line numberDiff line numberDiff line change
@@ -467,25 +467,6 @@ def test_merge_opts(
467467
assert merge_opts(conf, opt_conf_keys) == expected
468468

469469

470-
@pytest.mark.parametrize(
471-
'state',
472-
['!', '!!']
473-
)
474-
def test_cli_defines_ignored_are_ignored(
475-
state, caplog
476-
):
477-
opts = SimpleNamespace(
478-
opt_confs='', defines=[f'[]{state}opts=ignore me'],
479-
rose_template_vars=[]
480-
)
481-
482-
get_cli_opts_node(opts)
483-
assert (
484-
caplog.records[0].message ==
485-
'CLI opts set to ignored or trigger-ignored will be ignored.'
486-
)
487-
488-
489470
@pytest.mark.parametrize(
490471
'opt_confs, defines, rose_template_vars, expect',
491472
[

Diff for: tests/unit/test_functional_post_install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
def assert_rose_conf_full_equal(left, right, no_ignore=True):
4545
for keys_1, node_1 in left.walk(no_ignore=no_ignore):
4646
node_2 = right.get(keys_1, no_ignore=no_ignore)
47-
assert not (
47+
assert not ( # noqa: E721
4848
type(node_1) != type(node_2) or
4949
(
5050
not isinstance(node_1.value, dict) and

0 commit comments

Comments
 (0)