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

Delete opts after post install #312

Merged
merged 20 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions cylc/rose/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def post_install(srcdir=None, opts=None, rundir=None):
if results['fileinstall']:
dump_rose_log(rundir=rundir, node=results['fileinstall'])

# Having dumped the config we clear rose options:
wxtim marked this conversation as resolved.
Show resolved Hide resolved
opts.rose_template_vars = []
opts.opt_conf_keys = []
opts.defines = []
wxtim marked this conversation as resolved.
Show resolved Hide resolved

return results


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ python_requires = >=3.7
include_package_data = True
install_requires =
metomi-rose>=2.1.0, <2.3.0
cylc-flow==8.2.*
cylc-flow>=8.2.6
wxtim marked this conversation as resolved.
Show resolved Hide resolved
metomi-isodatetime
ansimarkup
jinja2
Expand Down
44 changes: 37 additions & 7 deletions tests/unit/test_functional_post_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,43 @@ def test_no_rose_suite_conf_in_devdir(tmp_path):
assert result is False


def test_post_install_clears_rose_opts(tmp_path, monkeypatch):
"""Ensure that rose opts are cleared after being dumped to
rose-suite-cylc-install.conf - we don't want them polluting downstream
Cylc configurations.
"""
# Mock functions which would otherwise fail, but we aren't interested
# in here:
for func in ['rose_config_exists', 'copy_config_file']:
monkeypatch.setattr(
f'cylc.rose.entry_points.{func}', lambda *_, **__: True)

# Setup opts-like object
opts = SimpleNamespace(
rose_template_vars=['FOO=42'],
defines=['[section]BAR="MOUTH"'],
opt_conf_keys=['gules'],
elephants=['Dumbo', 'BaBar']
)

# Setup workflow folder:
opt = (tmp_path / 'opt')
opt.mkdir(parents=True)
(opt / 'rose-suite-gules.conf').touch()
(tmp_path / 'rose-suite.conf').touch()

# Function under test
post_install(rundir=tmp_path, opts=opts, srcdir=tmp_path)

# All the opts values for Rose Have been cleared:
assert opts.rose_template_vars == []
assert opts.opt_conf_keys == []
assert opts.defines == []

# All the non-rose opts have been left alone:
assert opts.elephants == ['Dumbo', 'BaBar']


def test_rose_fileinstall_no_config_in_folder():
# It returns false if no rose-suite.conf
assert rose_fileinstall(Path('/dev/null')) is False
Expand Down Expand Up @@ -353,10 +390,3 @@ def broken():
(tmp_path / 'rose-suite.conf').touch()
with pytest.raises(FileNotFoundError):
rose_fileinstall(srcdir=tmp_path, rundir=tmp_path)


def test_cylc_no_rose(tmp_path):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precisely duplicated test_no_rose_suite_conf_in_devdir at line 60.

"""A Cylc workflow that contains no ``rose-suite.conf`` installs OK.
"""
from cylc.rose.entry_points import post_install
assert post_install(srcdir=tmp_path, rundir=tmp_path) is False
Loading