Skip to content

Commit 6a5bf18

Browse files
Ensure workspace manage doesn't create empty dicts
This commit fixes an issue where `ramble workspace manage experiments` would create an empty workloads dict for an application, when a workload filter was provided that would add no workloads.
1 parent 88834df commit 6a5bf18

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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)