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 all commits
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: 8 additions & 2 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: bool = False,
) -> None:
"""
Initialize the workflow config object.
Expand All @@ -226,8 +227,13 @@ def __init__(
workflow: workflow ID
fpath: workflow config file path
options: CLI options
force_compat_mode:
If True, forces Cylc to use compatibility mode
overriding compatibility mode checks.
See https://github.com/cylc/cylc-rose/issues/319

"""
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
12 changes: 11 additions & 1 deletion cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,17 +779,27 @@
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

Args:
warn:
If True, then a warning will be logged when compatibility

Check warning on line 789 in cylc/flow/workflow_files.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/workflow_files.py#L789

Added line #L789 was not covered by tests
mode is activated.
force_compat_mode:
If True, forces Cylc to use compatibility mode
overriding compatibility mode checks.
See https://github.com/cylc/cylc-rose/issues/319

Check warning on line 794 in cylc/flow/workflow_files.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/workflow_files.py#L794

Added line #L794 was not covered by tests
"""
if (
# Don't want to log if it's already been set True.
not cylc.flow.flags.cylc7_back_compat
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