diff --git a/lib/ramble/ramble/application.py b/lib/ramble/ramble/application.py index 23d6e9631..a1d64bd44 100644 --- a/lib/ramble/ramble/application.py +++ b/lib/ramble/ramble/application.py @@ -1705,9 +1705,12 @@ def format_context(context_match, context_format): if context not in fom_values: fom_values[context] = {} fom_val = fom_match.group(fom_conf["group"]) + fom_unit = self.expander.expand_var( + fom_conf["units"], extra_vars=fom_vars + ) fom_values[context][fom_name] = { "value": fom_val, - "units": fom_conf["units"], + "units": fom_unit, "origin": fom_conf["origin"], "origin_type": fom_conf["origin_type"], "fom_type": fom_conf["fom_type"], diff --git a/lib/ramble/ramble/test/end_to_end/expanded_fom_dry_run.py b/lib/ramble/ramble/test/end_to_end/expanded_fom_dry_run.py index 21456cd2b..5e6a796b0 100644 --- a/lib/ramble/ramble/test/end_to_end/expanded_fom_dry_run.py +++ b/lib/ramble/ramble/test/end_to_end/expanded_fom_dry_run.py @@ -67,9 +67,11 @@ def test_expanded_foms_dry_run(mutable_config, mutable_mock_workspace_path, mock exp_dir = os.path.join(ws1.root, "experiments", "expanded_foms", "test_wl", "single_exp") fom_out_file = os.path.join(exp_dir, "single_exp.out") + + unit = "seconds" with open(fom_out_file, "w+") as f: for expected in expected_expansions: - f.write(f"Collect FOM {expected} = 567.8 seconds\n") + f.write(f"Collect FOM {expected} = 567.8 {unit}\n") ws1._re_read() 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 with open(text_results_files[0]) as f: data = f.read() for expected in expected_expansions: - assert f"test_fom {expected} = 567.8" in data + assert f"test_fom {expected} = 567.8 {unit}" in data diff --git a/var/ramble/repos/builtin.mock/applications/expanded_foms/application.py b/var/ramble/repos/builtin.mock/applications/expanded_foms/application.py index 2d28583bd..3931cf174 100644 --- a/var/ramble/repos/builtin.mock/applications/expanded_foms/application.py +++ b/var/ramble/repos/builtin.mock/applications/expanded_foms/application.py @@ -31,10 +31,10 @@ class ExpandedFoms(ExecutableApplication): figure_of_merit( "test_fom {var}", - fom_regex=r"Collect FOM (?P\w+)\s=\s(?P[0-9]+\.[0-9]+) seconds", + fom_regex=r"Collect FOM (?P\w+)\s=\s(?P[0-9]+\.[0-9]+) (?P\w+)", log_file="{log_file}", group_name="test", - units="s", + units="{unit}", ) success_criteria("Run", mode="string", match=r"Collect", file="{log_file}")