diff --git a/CHANGES.md b/CHANGES.md index 4594cc21cd3..7d96d537e79 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,6 @@ enhancements to ``cylc lint``: * __Only__ check for missing Jinja2 shebangs in ``flow.cylc`` and ``suite.rc`` files. -### Fixes ### Breaking Changes [#5600](https://github.com/cylc/cylc-flow/pull/5600) - @@ -53,6 +52,9 @@ for `cylc play` when called by `cylc vip` or `cylc vr`. Enabled the "stop", "poll", "kill" and "message" commands to be issued from the UI whilst the workflow is in the process of shutting down. +[#5582](https://github.com/cylc/cylc-flow/pull/5582) - Set Cylc 7 compatibility +mode before running pre-configure plugins. + ## __cylc-8.1.4 (Released 2023-05-04)__ ### Fixes diff --git a/cylc/flow/scripts/install.py b/cylc/flow/scripts/install.py index e6813b641b2..b195af66538 100755 --- a/cylc/flow/scripts/install.py +++ b/cylc/flow/scripts/install.py @@ -108,7 +108,8 @@ from cylc.flow.workflow_files import ( install_workflow, parse_cli_sym_dirs, - search_install_source_dirs + search_install_source_dirs, + check_deprecation, ) from cylc.flow.terminal import cli_function @@ -291,6 +292,11 @@ def install( "options --no-run-name and --run-name are mutually exclusive." ) source = get_source_location(reg) + + # Check deprecation to allow plugins to have access to correct flags + # for compatibility mode: + check_deprecation(source) + for entry_point in iter_entry_points( 'cylc.pre_configure' ): diff --git a/cylc/flow/scripts/validate_install_play.py b/cylc/flow/scripts/validate_install_play.py index 36597fd20d3..4ad66b5c454 100644 --- a/cylc/flow/scripts/validate_install_play.py +++ b/cylc/flow/scripts/validate_install_play.py @@ -28,6 +28,8 @@ """ +import sys + from cylc.flow.scripts.validate import ( VALIDATE_OPTIONS, _main as validate_main @@ -111,5 +113,5 @@ def main(parser: COP, options: 'Values', workflow_id: Optional[str] = None): ) set_timestamps(LOG, options.log_timestamp) - log_subcommand('play', workflow_id) + log_subcommand(*sys.argv[1:]) _play(parser, options, workflow_id) diff --git a/cylc/flow/workflow_files.py b/cylc/flow/workflow_files.py index f74bed8f7c0..db3f78ccda7 100644 --- a/cylc/flow/workflow_files.py +++ b/cylc/flow/workflow_files.py @@ -1237,8 +1237,12 @@ def check_deprecation(path, warn=True): Path can point to config file or parent directory (i.e. workflow name). """ if ( - path.resolve().name == WorkflowFiles.SUITE_RC - or (path / WorkflowFiles.SUITE_RC).is_file() + # 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() + ) ): cylc.flow.flags.cylc7_back_compat = True if warn: diff --git a/tests/integration/test_install.py b/tests/integration/test_install.py index 22ff88a55ba..85246170cc6 100644 --- a/tests/integration/test_install.py +++ b/tests/integration/test_install.py @@ -148,3 +148,43 @@ def test_install_scan_ping( out = capsys.readouterr().out assert INSTALLED_MSG.format(wfrun='w2/run1') in out assert WF_ACTIVE_MSG.format(wf='w2') not in out + + +def test_install_gets_back_compat_mode_for_plugins( + src_run_dirs: Callable, + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture, +): + """Assert that pre cylc install will detect whether a workflow + should use back compat mode _before_ running pre_configure plugins + so that those plugins can use that information. + """ + class failIfDeprecated: + """A fake Cylc Plugin entry point""" + @staticmethod + def resolve(): + return failIfDeprecated.raiser + + @staticmethod + def raiser(*_, **__): + import cylc.flow.flags + if cylc.flow.flags.cylc7_back_compat: + print('Plugin:True') + return True + print('Plugin:False') + return False + + # Monkeypatch our fake entry point into iter_entry_points: + monkeypatch.setattr( + 'cylc.flow.scripts.install.iter_entry_points', + lambda x: [failIfDeprecated] + ) + opts = InstallOptions() + + monkeypatch.setattr('cylc.flow.flags.cylc7_back_compat', False) + install_cli(opts, reg='w1') + assert capsys.readouterr()[0].split('\n')[0] == 'Plugin:False' + + monkeypatch.setattr('cylc.flow.flags.cylc7_back_compat', True) + install_cli(opts, reg='w1') + assert capsys.readouterr()[0].split('\n')[0] == 'Plugin:True'