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

Fix Validation using old tvars fails for Cylc 7 workflows #5313

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ updated. Only the first match gets replaced, so it's fine to leave the old
ones in. -->

-------------------------------------------------------------------------------

## __cylc-8.1.1 (<span actions:bind='release-date'>Coming Soon</span>)__

### Fixes

[#5313](https://github.com/cylc/cylc-flow/pull/5313) - Fix a bug
causing Cylc to be unable to parse previously played Cylc 7 workflows.


## __cylc-8.1.0 (<span actions:bind='release-date'>Released 2023-01-16</span>)__

### Breaking Changes
Expand Down
26 changes: 16 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,16 @@ 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:
MetRonnie marked this conversation as resolved.
Show resolved Hide resolved
LOG.critical(
'Cannot tell if the workflow is running'
'\nNote, Cylc 8 cannot restart Cylc 7 workflows.'
)
wxtim marked this conversation as resolved.
Show resolved Hide resolved
raise
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: 4 additions & 3 deletions cylc/flow/templatevars.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
from typing import Any, Dict

from cylc.flow.exceptions import InputError


from cylc.flow.rundb import CylcWorkflowDAO
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 (run_dir / 'log/db').exists():
dao = CylcWorkflowDAO(str(run_dir / 'log/db'))
WorkflowDatabaseManager(
str(run_dir / 'log')).check_workflow_db_compatibility()
wxtim marked this conversation as resolved.
Show resolved Hide resolved
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
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
23 changes: 23 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 Expand Up @@ -153,3 +169,10 @@ def test_get_old_tvars(key, expect, _setup_db):
"""It can extract a variety of items from a workflow database.
"""
assert _setup_db[key] == expect


def test_dont_get_old_tvars_back_compat(tmp_path):
"""It won't even try to extract workflow_template_vars in compat mode.
"""
tmp_path.touch('suite.rc')
assert get_template_vars_from_db(tmp_path) == {}
wxtim marked this conversation as resolved.
Show resolved Hide resolved