Skip to content

Commit

Permalink
Merge pull request #752 from douglasjacobsen/manage-empty-filter
Browse files Browse the repository at this point in the history
Fix workflow filters that map to no workloads
  • Loading branch information
linsword13 authored Nov 7, 2024
2 parents f6f61d2 + 2bcbe22 commit 7439ee3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
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

0 comments on commit 7439ee3

Please sign in to comment.