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

Add an option to the workflow config to force use of compat mode #6097

Merged
merged 4 commits into from
May 13, 2024
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
10 changes: 7 additions & 3 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def __init__(
run_dir: Optional[str] = None,
log_dir: Optional[str] = None,
work_dir: Optional[str] = None,
share_dir: Optional[str] = None
share_dir: Optional[str] = None,
force_compat_mode: Optional[bool] = False,
wxtim marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
"""
Initialize the workflow config object.
Expand All @@ -226,8 +227,11 @@ def __init__(
workflow: workflow ID
fpath: workflow config file path
options: CLI options
force_compat_mode:
Override compatibility mode checks.
https://github.com/cylc/cylc-rose/issues/319
wxtim marked this conversation as resolved.
Show resolved Hide resolved
"""
check_deprecation(Path(fpath))
check_deprecation(Path(fpath), force_compat_mode=force_compat_mode)
self.mem_log = mem_log_func
if self.mem_log is None:
self.mem_log = lambda x: None
Expand Down Expand Up @@ -876,7 +880,7 @@ def _check_implicit_tasks(self) -> None:
)
# Allow implicit tasks in back-compat mode unless rose-suite.conf
# present (to maintain compat with Rose 2019)
elif not (self.fpath.parent / "rose-suite.conf").is_file():
elif not (self.fdir / "rose-suite.conf").is_file():
wxtim marked this conversation as resolved.
Show resolved Hide resolved
LOG.debug(msg)
return

Expand Down
3 changes: 2 additions & 1 deletion cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def get_workflow_title(id_):
return title


def check_deprecation(path, warn=True):
def check_deprecation(path, warn=True, force_compat_mode=False):
"""Warn and turn on back-compat flag if Cylc 7 suite.rc detected.

Path can point to config file or parent directory (i.e. workflow name).
wxtim marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -790,6 +790,7 @@ def check_deprecation(path, warn=True):
and (
path.resolve().name == WorkflowFiles.SUITE_RC
or (path / WorkflowFiles.SUITE_RC).is_file()
or force_compat_mode
)
):
cylc.flow.flags.cylc7_back_compat = True
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from cylc.flow.cycling import loader
from cylc.flow.cycling.loader import INTEGER_CYCLING_TYPE, ISO8601_CYCLING_TYPE
from cylc.flow.exceptions import (
GraphParseError,
PointParsingError,
InputError,
WorkflowConfigError,
Expand Down Expand Up @@ -1675,3 +1676,20 @@ def test_cylc_env_at_parsing(
assert var in cylc_env
else:
assert var not in cylc_env


def test_force_workflow_compat_mode(tmp_path):
fpath = (tmp_path / 'flow.cylc')
from textwrap import dedent
fpath.write_text(dedent("""
[scheduler]
allow implicit tasks = true
[scheduling]
[[graph]]
R1 = a:succeeded | a:failed => b
"""))
# It fails without compat mode:
with pytest.raises(GraphParseError, match='Opposite outputs'):
WorkflowConfig('foo', str(fpath), {})
# It succeeds with compat mode:
WorkflowConfig('foo', str(fpath), {}, force_compat_mode=True)
Loading