Skip to content

Commit

Permalink
Cylc 728 (with linter) (#4900)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim authored Jul 27, 2022
1 parent 323567d commit 1fad73f
Show file tree
Hide file tree
Showing 8 changed files with 937 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Jinja2 used by Cylc from 2.11 to 3.0.
[#4896](https://github.com/cylc/cylc-flow/pull/4896) - Allow the setting of
default job runner directives for platforms.

[#4900](https://github.com/cylc/cylc-flow/pull/4900) - Added a command to assist
with upgrading Cylc 7 workflows to Cylc 8: Try `cylc lint <workflow-dir>`.

[#5009](https://github.com/cylc/cylc-flow/pull/5009) - Added new job
environment variable `$CYLC_WORKFLOW_NAME_BASE` as the basename of
`$CYLC_WORKFLOW_NAME`.
Expand Down
14 changes: 10 additions & 4 deletions cylc/flow/cfgspec/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ def upg(cfg, descr):
u.obsolete('7.8.1', ['cylc', 'events', 'reset inactivity timer'])
u.obsolete('8.0.0', ['cylc', 'force run mode'])
u.obsolete('7.8.1', ['runtime', '__MANY__', 'events', 'reset timer'])
u.obsolete('8.0.0', ['cylc', 'authentication'])
u.obsolete('8.0.0', ['cylc', 'authentication'], is_section=True)
u.obsolete('8.0.0', ['cylc', 'include at start-up'])
u.obsolete('8.0.0', ['cylc', 'exclude at start-up'])
u.obsolete('8.0.0', ['cylc', 'log resolved dependencies'])
Expand All @@ -1721,13 +1721,13 @@ def upg(cfg, descr):
)
u.obsolete('8.0.0', ['cylc', 'abort if any task fails'])
u.obsolete('8.0.0', ['cylc', 'disable automatic shutdown'])
u.obsolete('8.0.0', ['cylc', 'environment'])
u.obsolete('8.0.0', ['cylc', 'environment'], is_section=True)
u.obsolete('8.0.0', ['cylc', 'reference test'])
u.obsolete(
'8.0.0',
['cylc', 'simulation', 'disable suite event handlers'])
u.obsolete('8.0.0', ['cylc', 'simulation'])
u.obsolete('8.0.0', ['visualization'])
u.obsolete('8.0.0', ['cylc', 'simulation'], is_section=True)
u.obsolete('8.0.0', ['visualization'], is_section=True)
u.obsolete('8.0.0', ['scheduling', 'spawn to max active cycle points']),
u.deprecate(
'8.0.0',
Expand All @@ -1740,12 +1740,14 @@ def upg(cfg, descr):
['cylc', 'parameters'],
['task parameters'],
silent=cylc.flow.flags.cylc7_back_compat,
is_section=True,
)
u.deprecate(
'8.0.0',
['cylc', 'parameter templates'],
['task parameters', 'templates'],
silent=cylc.flow.flags.cylc7_back_compat,
is_section=True,
)
# Whole workflow task mail settings
for mail_setting in ['to', 'from', 'footer']:
Expand Down Expand Up @@ -1802,6 +1804,7 @@ def upg(cfg, descr):
['runtime', '__MANY__', 'suite state polling'],
['runtime', '__MANY__', 'workflow state polling'],
silent=cylc.flow.flags.cylc7_back_compat,
is_section=True
)

for job_setting in [
Expand Down Expand Up @@ -1875,6 +1878,7 @@ def upg(cfg, descr):
['cylc'],
['scheduler'],
silent=cylc.flow.flags.cylc7_back_compat,
is_section=True,
)
u.upgrade()

Expand All @@ -1884,6 +1888,8 @@ def upg(cfg, descr):
warn_about_depr_platform(cfg)
warn_about_depr_event_handler_tmpl(cfg)

return u


def upgrade_graph_section(cfg: Dict[str, Any], descr: str) -> None:
"""Upgrade Cylc 7 `[scheduling][dependencies][X]graph` format to
Expand Down
23 changes: 18 additions & 5 deletions cylc/flow/parsec/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def __init__(self, cfg, descr):
# upgrades must be ordered in case several act on the same item
self.upgrades = OrderedDict()

def deprecate(self, vn, oldkeys, newkeys=None, cvtr=None, silent=False):
def deprecate(
self, vn, oldkeys, newkeys=None,
cvtr=None, silent=False, is_section=False,
):
"""Replace a deprecated key from a config
Args:
vn (str):
Expand All @@ -62,17 +65,22 @@ def deprecate(self, vn, oldkeys, newkeys=None, cvtr=None, silent=False):
cvtr (cylc.flow.parsec.upgrade.Converter):
Converter object containing a conversion function and a
description of that function.
silent:
silent (bool):
Set silent mode for this upgrade.
is_section (bool):
Is a section heading.
"""
if vn not in self.upgrades:
self.upgrades[vn] = []
if cvtr is None:
cvtr = converter(lambda x: x, "value unchanged") # identity
self.upgrades[vn].append(
{'old': oldkeys, 'new': newkeys, 'cvt': cvtr, 'silent': silent})
{
'old': oldkeys, 'new': newkeys, 'cvt': cvtr,
'silent': silent, 'is_section': is_section
})

def obsolete(self, vn, oldkeys, silent=False):
def obsolete(self, vn, oldkeys, silent=False, is_section=False):
"""Remove an obsolete key from a config
Args:
vn (str):
Expand All @@ -81,12 +89,17 @@ def obsolete(self, vn, oldkeys, silent=False):
Path within config to be removed.
silent:
Set silent mode for this upgrade.
is_section (bool):
Is a section heading.
"""
if vn not in self.upgrades:
self.upgrades[vn] = []
cvtr = converter(lambda x: x, "DELETED (OBSOLETE)") # identity
self.upgrades[vn].append(
{'old': oldkeys, 'new': None, 'cvt': cvtr, 'silent': silent})
{
'old': oldkeys, 'new': None, 'cvt': cvtr, 'silent': silent,
'is_section': is_section
})

def get_item(self, keys):
item = self.cfg
Expand Down
Loading

0 comments on commit 1fad73f

Please sign in to comment.