Skip to content

Commit 7439ee3

Browse files
authored
Merge pull request #752 from douglasjacobsen/manage-empty-filter
Fix workflow filters that map to no workloads
2 parents f6f61d2 + 2bcbe22 commit 7439ee3

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

lib/ramble/ramble/test/cmd/workspace.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,3 +2240,29 @@ def test_workspace_info_software(request):
22402240
assert "spack-pkg" in output
22412241
assert "pip-test" in output
22422242
assert "spack-test" not in output
2243+
2244+
2245+
def test_workspace_no_empty_workloads(request):
2246+
workspace_name = request.node.name
2247+
global_args = ["-w", workspace_name]
2248+
2249+
with ramble.workspace.create(workspace_name) as ws:
2250+
ws.write()
2251+
2252+
workspace(
2253+
"manage",
2254+
"experiments",
2255+
"basic",
2256+
"--wf",
2257+
"nothing*",
2258+
"-v",
2259+
"n_nodes=1",
2260+
"-v",
2261+
"n_ranks=1",
2262+
global_args=global_args,
2263+
)
2264+
2265+
with open(ws.config_file_path) as f:
2266+
data = f.read()
2267+
assert "basic:" not in data
2268+
assert "workloads: {}" not in data

lib/ramble/ramble/workspace/workspace.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,8 @@ def yaml_add_comment_before_key(
11411141

11421142
import ruamel.yaml as yaml
11431143

1144+
edited = False
1145+
11441146
workspace_vars = self.get_workspace_vars()
11451147
apps_dict = self.get_applications().copy()
11461148

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

12211223
for workload_name in workload_names:
1224+
edited = True
12221225
if workload_name not in workloads_dict:
12231226
workloads_dict[workload_name] = syaml.syaml_dict()
12241227
workloads_dict[workload_name][namespace.experiment] = syaml.syaml_dict()
@@ -1301,11 +1304,11 @@ def yaml_add_comment_before_key(
13011304
if namespace.matrix not in exp_dict:
13021305
exp_dict[namespace.matrix] = exp_matrix.copy()
13031306

1304-
if not self.dry_run:
1307+
if edited and not self.dry_run:
13051308
ramble.config.config.update_config(
13061309
namespace.application, apps_dict, scope=self.ws_file_config_scope_name()
13071310
)
1308-
else:
1311+
elif edited:
13091312
workspace_dict = self._get_workspace_dict()
13101313
workspace_dict[namespace.ramble][namespace.application] = apps_dict
13111314

0 commit comments

Comments
 (0)