Skip to content

Commit 930758d

Browse files
authored
Fix upgrader for max active cylc points to runahead limit. (#5704)
1 parent 2888d95 commit 930758d

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

changes.d/5704.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix off-by-one error in automatic upgrade of Cylc 7 "max active cycle points" to Cylc 8 "runahead limit".

cylc/flow/cfgspec/workflow.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,10 @@ def upg(cfg, descr):
18461846
'8.0.0',
18471847
['scheduling', 'max active cycle points'],
18481848
['scheduling', 'runahead limit'],
1849-
cvtr=converter(lambda x: f'P{x}' if x != '' else '', '"n" -> "Pn"'),
1849+
cvtr=converter(
1850+
lambda x: f'P{int(x)-1}' if x != '' else '',
1851+
'"{old}" -> "{new}"'
1852+
),
18501853
silent=cylc.flow.flags.cylc7_back_compat,
18511854
)
18521855
u.deprecate(

cylc/flow/parsec/upgrade.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ def upgrade(self):
212212
if upg['new']:
213213
msg += ' -> ' + self.show_keys(upg['new'],
214214
upg['is_section'])
215-
msg += " - " + upg['cvt'].describe()
215+
msg += " - " + upg['cvt'].describe().format(
216+
old=old,
217+
new=upg['cvt'].convert(old)
218+
)
216219
if not upg['silent']:
217220
warnings.setdefault(vn, [])
218221
warnings[vn].append(msg)

tests/functional/deprecations/01-cylc8-basic/validation.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ WARNING - * (8.0.0) [runtime][foo, cat, dog][events]mail to -> [runtime][foo, c
2222
WARNING - * (8.0.0) [runtime][foo, cat, dog][events]mail from -> [runtime][foo, cat, dog][mail]from - value unchanged
2323
WARNING - * (8.0.0) [cylc][events]mail smtp - DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" instead
2424
WARNING - * (8.0.0) [runtime][foo, cat, dog][events]mail smtp - DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" instead
25-
WARNING - * (8.0.0) [scheduling]max active cycle points -> [scheduling]runahead limit - "n" -> "Pn"
25+
WARNING - * (8.0.0) [scheduling]max active cycle points -> [scheduling]runahead limit - "2" -> "P1"
2626
WARNING - * (8.0.0) [scheduling]hold after point -> [scheduling]hold after cycle point - value unchanged
2727
WARNING - * (8.0.0) [runtime][foo, cat, dog][suite state polling] -> [runtime][foo, cat, dog][workflow state polling] - value unchanged
2828
WARNING - * (8.0.0) [runtime][foo, cat, dog][job]execution polling intervals -> [runtime][foo, cat, dog]execution polling intervals - value unchanged

tests/unit/parsec/test_upgrade.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,17 @@ def test_expand_obsolete(self):
275275
expanded = self.u.expand(upg)
276276
self.assertEqual(1, len(expanded))
277277
self.assertTrue(expanded[0]['new'] is None)
278+
279+
280+
def test_template_in_converter_description(caplog, capsys):
281+
"""Before and after values are available to the conversion descriptor"""
282+
cfg = {'old': 42}
283+
u = upgrader(cfg, 'Whateva')
284+
u.deprecate(
285+
'2.0.0', ['old'], ['new'],
286+
cvtr=converter(lambda x: x + 20, '{old} -> {new}'),
287+
silent=False,
288+
)
289+
u.upgrade()
290+
assert cfg == {'new': 62}
291+
assert '42 -> 62' in caplog.records[1].message

tests/unit/test_config_upgrader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _cfg(dic):
108108

109109
@pytest.mark.parametrize(
110110
'macp, rlim',
111-
[(16, 'P16'),
111+
[(16, 'P15'),
112112
('', '')]
113113
)
114114
def test_upgrade_max_active_cycle_points(macp, rlim):

0 commit comments

Comments
 (0)