Skip to content

Commit 958bbf1

Browse files
Fix workload string representation printing repeated vars
This commit fixes an issue that was introduced with the `when` argument on variable directives. After `when` was added, variables were placed in a list within the workloads (instead of a dict, which they were in before that change). This change meant that variables were now able to be defined multiple times within the workload, with the understanding that the last definition is the one that would actually apply to the workload. This commit updates this by building a temporary dictionary of variables in a workload, and using that to print as a string. Additionally, the variables are now sorted by name instead of being printed by insertion order.
1 parent b62b0d7 commit 958bbf1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/ramble/ramble/workload.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ def as_str(self, n_indent: int = 0):
193193
out_str += f"{indentation} {variant}\n"
194194
else:
195195
out_str += rucolor.nested_2(f"{indentation} Unconditional\n")
196+
197+
var_dict = {}
196198
for var in var_list:
197-
out_str += var.as_str(n_indent + 12)
199+
var_dict[var.name] = var
200+
for var_name in sorted(var_dict.keys()):
201+
out_str += var_dict[var_name].as_str(n_indent + 12)
198202

199203
if self.environment_variables:
200204
out_str += rucolor.nested_1(f"{indentation} Environment Variables:\n")

0 commit comments

Comments
 (0)