Skip to content

Commit 69765cb

Browse files
Merge pull request #790 from rfbgo/expand_unit
Allow fom units to be expanded by regex group
2 parents bb30651 + c0fcac9 commit 69765cb

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/ramble/ramble/application.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1705,9 +1705,12 @@ def format_context(context_match, context_format):
17051705
if context not in fom_values:
17061706
fom_values[context] = {}
17071707
fom_val = fom_match.group(fom_conf["group"])
1708+
fom_unit = self.expander.expand_var(
1709+
fom_conf["units"], extra_vars=fom_vars
1710+
)
17081711
fom_values[context][fom_name] = {
17091712
"value": fom_val,
1710-
"units": fom_conf["units"],
1713+
"units": fom_unit,
17111714
"origin": fom_conf["origin"],
17121715
"origin_type": fom_conf["origin_type"],
17131716
"fom_type": fom_conf["fom_type"],

lib/ramble/ramble/test/end_to_end/expanded_fom_dry_run.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ def test_expanded_foms_dry_run(mutable_config, mutable_mock_workspace_path, mock
6767

6868
exp_dir = os.path.join(ws1.root, "experiments", "expanded_foms", "test_wl", "single_exp")
6969
fom_out_file = os.path.join(exp_dir, "single_exp.out")
70+
71+
unit = "seconds"
7072
with open(fom_out_file, "w+") as f:
7173
for expected in expected_expansions:
72-
f.write(f"Collect FOM {expected} = 567.8 seconds\n")
74+
f.write(f"Collect FOM {expected} = 567.8 {unit}\n")
7375

7476
ws1._re_read()
7577
output = workspace("analyze", global_args=["-w", workspace_name])
@@ -79,4 +81,4 @@ def test_expanded_foms_dry_run(mutable_config, mutable_mock_workspace_path, mock
7981
with open(text_results_files[0]) as f:
8082
data = f.read()
8183
for expected in expected_expansions:
82-
assert f"test_fom {expected} = 567.8" in data
84+
assert f"test_fom {expected} = 567.8 {unit}" in data

var/ramble/repos/builtin.mock/applications/expanded_foms/application.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class ExpandedFoms(ExecutableApplication):
3131

3232
figure_of_merit(
3333
"test_fom {var}",
34-
fom_regex=r"Collect FOM (?P<var>\w+)\s=\s(?P<test>[0-9]+\.[0-9]+) seconds",
34+
fom_regex=r"Collect FOM (?P<var>\w+)\s=\s(?P<test>[0-9]+\.[0-9]+) (?P<unit>\w+)",
3535
log_file="{log_file}",
3636
group_name="test",
37-
units="s",
37+
units="{unit}",
3838
)
3939

4040
success_criteria("Run", mode="string", match=r"Collect", file="{log_file}")

0 commit comments

Comments
 (0)