Skip to content

Commit

Permalink
prevent use of validation on installed Cylc 7 workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Jan 24, 2023
1 parent c672c85 commit 79ee9c3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 17 deletions.
25 changes: 15 additions & 10 deletions cylc/flow/scripts/validate_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions cylc/flow/templatevars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
2 changes: 0 additions & 2 deletions cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,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(
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/parsec/test_fileparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_templatevars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79ee9c3

Please sign in to comment.