Skip to content

Commit ce85dc2

Browse files
committed
Add success_criteria
1 parent 34fe6cd commit ce85dc2

File tree

1 file changed

+21
-9
lines changed
  • var/ramble/repos/builtin/modifiers/tuned-adm

1 file changed

+21
-9
lines changed

var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from ramble.modkit import *
1212

1313

14+
SUCCESS_STRING = "Status: SUCCESS"
15+
16+
1417
class TunedAdm(BasicModifier):
1518
"""Define a modifier for TunedAdm
1619
@@ -46,31 +49,40 @@ def set_tuning_profile(self):
4649
]
4750

4851
def _prepare_analysis(self, workspace):
49-
profile_path = os.path.join(
50-
self.expander.expand_var("{experiment_run_dir}"),
51-
"tuning_profile",
52-
)
52+
run_dir = self.expander.expand_var("{experiment_run_dir}")
53+
read_profile_path = os.path.join(run_dir, "tuning_profile")
5354

54-
if not os.path.exists(profile_path):
55+
if not os.path.exists(read_profile_path):
5556
return
5657

5758
profiles = set()
58-
with open(profile_path) as f:
59+
with open(read_profile_path) as f:
5960

6061
for line in f.readlines():
6162
if "active profile:" in line:
6263
profiles.add(line.split(":")[-1].strip())
6364
profiles_str = ",".join(profiles)
6465

6566
if profiles:
66-
with open(profile_path, "a") as f:
67+
expected_profile = self.expander.expand_var("{tuned-profile}")
68+
write_profile_path = os.path.join(run_dir, "all_tuning_profiles")
69+
with open(write_profile_path, "w+") as f:
6770
profiles_str = ",".join(profiles)
68-
f.write(f"Applied profiles: {profiles_str}")
71+
f.write(f"Applied profiles: {profiles_str}\n")
72+
if len(profiles) == 1 and profiles_str == expected_profile:
73+
f.write(SUCCESS_STRING)
6974

7075
figure_of_merit(
7176
"Tuning Profile",
7277
fom_regex=r"Applied profiles:\s*(?P<profile>.*)",
73-
log_file="{experiment_run_dir}/tuning_profile",
78+
log_file="{experiment_run_dir}/all_tuning_profiles",
7479
group_name="profile",
7580
units="",
7681
)
82+
83+
success_criteria(
84+
"Expected tuning profile applied",
85+
mode="string",
86+
match=SUCCESS_STRING,
87+
file="{experiment_run_dir}/all_tuning_profiles",
88+
)

0 commit comments

Comments
 (0)