Skip to content

Commit

Permalink
Fix upgrader for max active cylc points to runahead limit. (#5704)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim authored Aug 25, 2023
1 parent 2888d95 commit 930758d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes.d/5704.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix off-by-one error in automatic upgrade of Cylc 7 "max active cycle points" to Cylc 8 "runahead limit".
5 changes: 4 additions & 1 deletion cylc/flow/cfgspec/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,10 @@ def upg(cfg, descr):
'8.0.0',
['scheduling', 'max active cycle points'],
['scheduling', 'runahead limit'],
cvtr=converter(lambda x: f'P{x}' if x != '' else '', '"n" -> "Pn"'),
cvtr=converter(
lambda x: f'P{int(x)-1}' if x != '' else '',
'"{old}" -> "{new}"'
),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
Expand Down
5 changes: 4 additions & 1 deletion cylc/flow/parsec/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ def upgrade(self):
if upg['new']:
msg += ' -> ' + self.show_keys(upg['new'],
upg['is_section'])
msg += " - " + upg['cvt'].describe()
msg += " - " + upg['cvt'].describe().format(
old=old,
new=upg['cvt'].convert(old)
)
if not upg['silent']:
warnings.setdefault(vn, [])
warnings[vn].append(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WARNING - * (8.0.0) [runtime][foo, cat, dog][events]mail to -> [runtime][foo, c
WARNING - * (8.0.0) [runtime][foo, cat, dog][events]mail from -> [runtime][foo, cat, dog][mail]from - value unchanged
WARNING - * (8.0.0) [cylc][events]mail smtp - DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" instead
WARNING - * (8.0.0) [runtime][foo, cat, dog][events]mail smtp - DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" instead
WARNING - * (8.0.0) [scheduling]max active cycle points -> [scheduling]runahead limit - "n" -> "Pn"
WARNING - * (8.0.0) [scheduling]max active cycle points -> [scheduling]runahead limit - "2" -> "P1"
WARNING - * (8.0.0) [scheduling]hold after point -> [scheduling]hold after cycle point - value unchanged
WARNING - * (8.0.0) [runtime][foo, cat, dog][suite state polling] -> [runtime][foo, cat, dog][workflow state polling] - value unchanged
WARNING - * (8.0.0) [runtime][foo, cat, dog][job]execution polling intervals -> [runtime][foo, cat, dog]execution polling intervals - value unchanged
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/parsec/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,17 @@ def test_expand_obsolete(self):
expanded = self.u.expand(upg)
self.assertEqual(1, len(expanded))
self.assertTrue(expanded[0]['new'] is None)


def test_template_in_converter_description(caplog, capsys):
"""Before and after values are available to the conversion descriptor"""
cfg = {'old': 42}
u = upgrader(cfg, 'Whateva')
u.deprecate(
'2.0.0', ['old'], ['new'],
cvtr=converter(lambda x: x + 20, '{old} -> {new}'),
silent=False,
)
u.upgrade()
assert cfg == {'new': 62}
assert '42 -> 62' in caplog.records[1].message
2 changes: 1 addition & 1 deletion tests/unit/test_config_upgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _cfg(dic):

@pytest.mark.parametrize(
'macp, rlim',
[(16, 'P16'),
[(16, 'P15'),
('', '')]
)
def test_upgrade_max_active_cycle_points(macp, rlim):
Expand Down

0 comments on commit 930758d

Please sign in to comment.