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 workflow filters that map to no workloads #752

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 26 additions & 0 deletions lib/ramble/ramble/test/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2240,3 +2240,29 @@ def test_workspace_info_software(request):
assert "spack-pkg" in output
assert "pip-test" in output
assert "spack-test" not in output


def test_workspace_no_empty_workloads(request):
workspace_name = request.node.name
global_args = ["-w", workspace_name]

with ramble.workspace.create(workspace_name) as ws:
ws.write()

workspace(
"manage",
"experiments",
"basic",
"--wf",
"nothing*",
"-v",
"n_nodes=1",
"-v",
"n_ranks=1",
global_args=global_args,
)

with open(ws.config_file_path) as f:
data = f.read()
assert "basic:" not in data
assert "workloads: {}" not in data
7 changes: 5 additions & 2 deletions lib/ramble/ramble/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,8 @@ def yaml_add_comment_before_key(

import ruamel.yaml as yaml

edited = False

workspace_vars = self.get_workspace_vars()
apps_dict = self.get_applications().copy()

Expand Down Expand Up @@ -1219,6 +1221,7 @@ def yaml_add_comment_before_key(
workload_names = [ramble.expander.Expander.expansion_str(workload_name_variable)]

for workload_name in workload_names:
edited = True
if workload_name not in workloads_dict:
workloads_dict[workload_name] = syaml.syaml_dict()
workloads_dict[workload_name][namespace.experiment] = syaml.syaml_dict()
Expand Down Expand Up @@ -1301,11 +1304,11 @@ def yaml_add_comment_before_key(
if namespace.matrix not in exp_dict:
exp_dict[namespace.matrix] = exp_matrix.copy()

if not self.dry_run:
if edited and not self.dry_run:
ramble.config.config.update_config(
namespace.application, apps_dict, scope=self.ws_file_config_scope_name()
)
else:
elif edited:
workspace_dict = self._get_workspace_dict()
workspace_dict[namespace.ramble][namespace.application] = apps_dict

Expand Down