Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: suppress config deprecation warnings in compat mode #4829

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Third Release Candidate for Cylc 8 suitable for acceptance testing.

### Fixes

[#4829](https://github.com/cylc/cylc-flow/pull/4829) -
Suppress deprecated configuration warnings in Cylc 7 compatibility mode.

[#4554](https://github.com/cylc/cylc-flow/pull/4554) - Fix incorrect
implementation of the ISO 8601 recurrence format no. 1
(`R<number>/<start-point>/<second-point>`)
Expand Down
79 changes: 56 additions & 23 deletions cylc/flow/cfgspec/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from cylc.flow import LOG
from cylc.flow.cfgspec.globalcfg import EVENTS_DESCR, REPLACES
import cylc.flow.flags
from cylc.flow.parsec.exceptions import UpgradeError
from cylc.flow.parsec.config import ParsecConfig, ConfigNode as Conf
from cylc.flow.parsec.OrderedDict import OrderedDictWithDefaults
Expand Down Expand Up @@ -107,9 +108,10 @@ def get_script_common_text(this: str, example: Optional[str] = None):
.. versionchanged:: 8.0.0

The configuration file was previously named ``suite.rc``, but that
name is now deprecated. Please take action on any deprecation
warnings before renaming ``suite.rc`` configuration files
to ``flow.cylc``.
name is now deprecated.

The ``suite.rc`` file name now activates :ref:`cylc_7_compat_mode`,
to turn off compatibility mode rename to ``flow.cylc``.
'''
) as SPEC:

Expand Down Expand Up @@ -1631,7 +1633,14 @@ def get_script_common_text(this: str, example: Optional[str] = None):


def upg(cfg, descr):
"""Upgrade old workflow configuration."""
"""Upgrade old workflow configuration.

NOTE: We are silencing deprecation (and only deprecation) warnings
when in Cylc 7 compat mode to help support Cylc 7/8 compatible workflows
(which would loose Cylc 7 compatibility if users were to follow the
warnings and upgrade the syntax).

"""
u = upgrader(cfg, descr)
u.obsolete(
'7.8.0',
Expand Down Expand Up @@ -1668,60 +1677,76 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['cylc', 'task event mail interval'],
['cylc', 'mail', 'task event batch interval']
['cylc', 'mail', 'task event batch interval'],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['cylc', 'parameters'],
['task parameters'],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate('8.0.0', ['cylc', 'parameters'], ['task parameters'])
u.deprecate(
'8.0.0',
['cylc', 'parameter templates'],
['task parameters', 'templates']
['task parameters', 'templates'],
silent=cylc.flow.flags.cylc7_back_compat,
)
# Whole workflow task mail settings
for mail_setting in ['to', 'from', 'footer']:
u.deprecate(
'8.0.0',
['cylc', 'events', f'mail {mail_setting}'],
['cylc', 'mail', mail_setting]
['cylc', 'mail', mail_setting],
silent=cylc.flow.flags.cylc7_back_compat,
)
# Task mail settings in [runtime][TASK]
for mail_setting in ['to', 'from']:
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', f'mail {mail_setting}'],
['runtime', '__MANY__', 'mail', mail_setting]
['runtime', '__MANY__', 'mail', mail_setting],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['cylc', 'events', 'mail smtp'],
None, # This is really a .obsolete(), just with a custom message
cvtr=converter(lambda x: x, (
'DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" '
'instead'))
'instead')
),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', 'mail smtp'],
None,
cvtr=converter(lambda x: x, (
'DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" '
'instead'))
'instead')
),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'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{x}' if x != '' else '', '"n" -> "Pn"'),
silent=cylc.flow.flags.cylc7_back_compat,
)
u.deprecate(
'8.0.0',
['scheduling', 'hold after point'],
['scheduling', 'hold after cycle point']
['scheduling', 'hold after cycle point'],
silent=cylc.flow.flags.cylc7_back_compat,
)

u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'suite state polling'],
['runtime', '__MANY__', 'workflow state polling'],
silent=cylc.flow.flags.cylc7_back_compat,
)

for job_setting in [
Expand All @@ -1734,7 +1759,8 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'job', job_setting],
['runtime', '__MANY__', job_setting]
['runtime', '__MANY__', job_setting],
silent=cylc.flow.flags.cylc7_back_compat,
)

# Workflow timeout is now measured from start of run.
Expand All @@ -1754,7 +1780,8 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['cylc', 'events', old],
['cylc', 'events', new]
['cylc', 'events', new],
silent=cylc.flow.flags.cylc7_back_compat,
)

for old in [
Expand All @@ -1776,7 +1803,8 @@ def upg(cfg, descr):
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', old],
['runtime', '__MANY__', 'events', f"{old}s"]
['runtime', '__MANY__', 'events', f"{old}s"],
silent=cylc.flow.flags.cylc7_back_compat,
)

u.obsolete('8.0.0', ['cylc', 'events', 'abort on stalled'])
Expand All @@ -1787,7 +1815,12 @@ def upg(cfg, descr):
'abort if inactivity handler fails'])
u.obsolete('8.0.0', ['cylc', 'events', 'abort if stalled handler fails'])

u.deprecate('8.0.0', ['cylc'], ['scheduler'])
u.deprecate(
'8.0.0',
['cylc'],
['scheduler'],
silent=cylc.flow.flags.cylc7_back_compat,
)
u.upgrade()

upgrade_graph_section(cfg, descr)
Expand All @@ -1797,7 +1830,7 @@ def upg(cfg, descr):
warn_about_depr_event_handler_tmpl(cfg)

# Warn about config items moved to global.cylc.
if 'runtime' in cfg:
if not cylc.flow.flags.cylc7_back_compat and 'runtime' in cfg:
for job_setting, task in product(
[
'execution polling intervals',
Expand All @@ -1810,10 +1843,10 @@ def upg(cfg, descr):
LOG.warning(
f"* (8.0.0) '[runtime][{task}]{job_setting}' - this "
"setting is deprecated; use "
f"'global.cylc[platforms][<platform name>]{job_setting}' "
"instead. "
"Currently, this item will override the corresponding "
"item in global.cylc, "
"'global.cylc[platforms][<platform name>]"
f"{job_setting}' "
"instead. Currently, this item will override"
" the corresponding item in global.cylc, "
"but support for this will be removed in Cylc 9."
)

Expand Down Expand Up @@ -1845,7 +1878,7 @@ def upgrade_graph_section(cfg: Dict[str, Any], descr: str) -> None:
elif key == 'graph' and isinstance(value, str):
graphdict[key] = value
keys.add(key)
if keys:
if keys and not cylc.flow.flags.cylc7_back_compat:
LOG.warning(
'deprecated graph items were automatically upgraded '
f'in "{descr}":\n'
Expand Down
1 change: 0 additions & 1 deletion cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ def _check_implicit_tasks(self) -> None:
not cylc.flow.flags.cylc7_back_compat
):
raise WorkflowConfigError(msg)
LOG.warning(msg)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log message says "to allow implicit tasks ..." which isn't appropriate in Cylc 7 compat mode (as implicit tasks are already allowed by exception), if users followed this advice they would make the workflow Cylc 7 incompatible.


def _check_circular(self):
"""Check for circular dependence in graph."""
Expand Down
4 changes: 1 addition & 3 deletions cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,7 @@ class RemoteCleanQueueTuple(NamedTuple):
"""

SUITERC_DEPR_MSG = (
f"Backward compatibility mode ON for CYLC 7 '{WorkflowFiles.SUITE_RC}'"
" files: please address deprecation warnings and upgrade to Cylc 8 graph"
f" syntax BEFORE renaming the file to '{WorkflowFiles.FLOW_FILE}'.\n"
f"Backward compatibility mode ON for CYLC 7 '{WorkflowFiles.SUITE_RC}'."
)

NO_FLOW_FILE_MSG = (
Expand Down
18 changes: 5 additions & 13 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,22 +1096,22 @@ def test_success_after_optional_submit(tmp_flow_config, graph):
]
)
@pytest.mark.parametrize(
'cylc7_compat, rose_suite_conf, expected_exc, expected_log_level',
'cylc7_compat, rose_suite_conf, expected_exc',
[
pytest.param(
False, False, WorkflowConfigError, None,
False, False, WorkflowConfigError,
id="Default"
),
pytest.param(
False, True, WorkflowConfigError, None,
False, True, WorkflowConfigError,
id="rose-suite.conf present"
),
pytest.param(
True, False, None, logging.WARNING,
True, False, None,
id="Cylc 7 back-compat"
),
pytest.param(
True, True, WorkflowConfigError, None,
True, True, WorkflowConfigError,
id="Cylc 7 back-compat, rose-suite.conf present"
),
]
Expand All @@ -1121,7 +1121,6 @@ def test_implicit_tasks(
cylc7_compat: bool,
rose_suite_conf: bool,
expected_exc: Optional[Type[Exception]],
expected_log_level: Optional[int],
caplog: pytest.LogCaptureFixture,
log_filter: Callable,
monkeypatch: pytest.MonkeyPatch,
Expand All @@ -1136,9 +1135,6 @@ def test_implicit_tasks(
rose_suite_conf: Whether a rose-suite.conf file is present in run dir.
expected_exc: Exception expected to be raised only when
"[scheduler]allow implicit tasks" is not set.
expected_log_level: Expected logging severity level for the
"implicit tasks detected" message only when
"[scheduler]allow implicit tasks" is not set.
"""
# Setup
reg = 'rincewind'
Expand All @@ -1158,7 +1154,6 @@ def test_implicit_tasks(
caplog.set_level(logging.DEBUG, CYLC_LOG)
if allow_implicit_tasks is True:
expected_exc = None
expected_log_level = logging.DEBUG
elif allow_implicit_tasks is False:
expected_exc = WorkflowConfigError
# Test
Expand All @@ -1170,9 +1165,6 @@ def test_implicit_tasks(
assert expected_msg in str(exc.value)
else:
WorkflowConfig(**args)
assert log_filter(
caplog, level=expected_log_level, contains=expected_msg
)


@pytest.mark.parametrize('workflow_meta', [True, False])
Expand Down