Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fom units to be expanded by regex group #790

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
6 changes: 4 additions & 2 deletions lib/ramble/ramble/test/end_to_end/expanded_fom_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class ExpandedFoms(ExecutableApplication):

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

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