diff --git a/cylc/flow/scripts/validate_reinstall.py b/cylc/flow/scripts/validate_reinstall.py index 2ea753820d0..38ed78aaed2 100644 --- a/cylc/flow/scripts/validate_reinstall.py +++ b/cylc/flow/scripts/validate_reinstall.py @@ -47,6 +47,14 @@ from cylc.flow import LOG from cylc.flow.exceptions import ServiceFileError +from cylc.flow.id_cli import parse_id +from cylc.flow.option_parsers import ( + WORKFLOW_ID_ARG_DOC, + CylcOptionParser as COP, + combine_options, + log_subcommand, + cleanup_sysargv +) from cylc.flow.scheduler_cli import PLAY_OPTIONS, scheduler_cli from cylc.flow.scripts.validate import ( VALIDATE_OPTIONS, @@ -58,14 +66,6 @@ from cylc.flow.scripts.reload import ( reload_cli as cylc_reload ) -from cylc.flow.option_parsers import ( - WORKFLOW_ID_ARG_DOC, - CylcOptionParser as COP, - combine_options, - log_subcommand, - cleanup_sysargv -) -from cylc.flow.id_cli import parse_id from cylc.flow.terminal import cli_function from cylc.flow.workflow_files import detect_old_contact_file @@ -135,10 +135,15 @@ def vro_cli(parser: COP, options: 'Values', workflow_id: str): try: detect_old_contact_file(workflow_id) except ServiceFileError: - # Workflow is definately running: + # Workflow is definitely running: workflow_running = True + except Exception: + LOG.critical( + 'Cannot tell if the workflow is running' + '\nNote, Cylc 8 cannot restart Cylc 7 workflows.' + ) else: - # Workflow is definately stopped: + # Workflow is definitely stopped: workflow_running = False # options.tvars and tvars_file are _only_ valid when playing a stopped diff --git a/cylc/flow/templatevars.py b/cylc/flow/templatevars.py index a3c9b790fd4..74e58ba01c2 100644 --- a/cylc/flow/templatevars.py +++ b/cylc/flow/templatevars.py @@ -21,17 +21,16 @@ from cylc.flow.exceptions import InputError from cylc.flow.rundb import CylcWorkflowDAO -from cylc.flow.workflow_files import check_deprecation +from cylc.flow.workflow_db_mgr import WorkflowDatabaseManager def get_template_vars_from_db(run_dir): """Get template vars stored in a workflow run database. """ template_vars = {} - if check_deprecation(run_dir): - # Check whether we are trying to open a Cylc 7 Database. - return template_vars if (run_dir / 'log/db').exists(): + WorkflowDatabaseManager( + str(run_dir / 'log')).check_workflow_db_compatibility() dao = CylcWorkflowDAO(str(run_dir / 'log/db'), is_public=True) dao.select_workflow_template_vars( lambda _, row: template_vars.__setitem__(row[0], eval_var(row[1])) diff --git a/cylc/flow/workflow_files.py b/cylc/flow/workflow_files.py index 9418c3b5ace..52e1f38cf45 100644 --- a/cylc/flow/workflow_files.py +++ b/cylc/flow/workflow_files.py @@ -1226,8 +1226,6 @@ def check_deprecation(path, warn=True): cylc.flow.flags.cylc7_back_compat = True if warn: LOG.warning(SUITERC_DEPR_MSG) - return True - return False def validate_workflow_name( diff --git a/tests/unit/parsec/test_fileparse.py b/tests/unit/parsec/test_fileparse.py index 8a972ae9b5c..fde67099c0a 100644 --- a/tests/unit/parsec/test_fileparse.py +++ b/tests/unit/parsec/test_fileparse.py @@ -22,6 +22,7 @@ import sqlite3 from types import SimpleNamespace +from cylc.flow import __version__ as cylc_version from cylc.flow.parsec.exceptions import ( FileParseError, IncludeFileNotFoundError, @@ -627,6 +628,14 @@ def _inner(create_srclink=True): "INSERT INTO workflow_template_vars VALUES" " ('Marius', '\"Consul\"')" ) + conn.execute( + "CREATE TABLE workflow_params" + "(key TEXT, value TEXT, PRIMARY KEY(key)) ;" + ) + conn.execute( + "INSERT INTO workflow_params VALUES" + f" ('cylc_version', '{cylc_version}')" + ) conn.commit() conn.close() @@ -658,7 +667,7 @@ def _inner(create_srclink=True): ), ] ) -def test__prepend_old_templatevars2(_mock_old_template_vars_db, expect, tvars): +def test__prepend_old_templatevars(_mock_old_template_vars_db, expect, tvars): # Create a target for a source symlink result = _prepend_old_templatevars( _mock_old_template_vars_db(), tvars) diff --git a/tests/unit/test_templatevars.py b/tests/unit/test_templatevars.py index e327aae1ee1..39246caeba9 100644 --- a/tests/unit/test_templatevars.py +++ b/tests/unit/test_templatevars.py @@ -22,6 +22,7 @@ from types import SimpleNamespace +from cylc.flow import __version__ as cylc_version from cylc.flow.exceptions import PluginError from cylc.flow.templatevars import ( get_template_vars_from_db, @@ -125,6 +126,21 @@ def _setup_db(tmp_path_factory): ) ''' ) + conn.execute( + r''' + CREATE TABLE workflow_params ( + key, + value + ) + ''' + ) + conn.execute( + rf''' + INSERT INTO workflow_params + VALUES + ("cylc_version", "{cylc_version}") + ''' + ) conn.execute( r''' INSERT INTO workflow_template_vars