|
11 | 11 | from ramble.modkit import *
|
12 | 12 |
|
13 | 13 |
|
| 14 | +SUCCESS_STRING = "Status: SUCCESS" |
| 15 | + |
| 16 | + |
14 | 17 | class TunedAdm(BasicModifier):
|
15 | 18 | """Define a modifier for TunedAdm
|
16 | 19 |
|
@@ -46,31 +49,40 @@ def set_tuning_profile(self):
|
46 | 49 | ]
|
47 | 50 |
|
48 | 51 | 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") |
53 | 54 |
|
54 |
| - if not os.path.exists(profile_path): |
| 55 | + if not os.path.exists(read_profile_path): |
55 | 56 | return
|
56 | 57 |
|
57 | 58 | profiles = set()
|
58 |
| - with open(profile_path) as f: |
| 59 | + with open(read_profile_path) as f: |
59 | 60 |
|
60 | 61 | for line in f.readlines():
|
61 | 62 | if "active profile:" in line:
|
62 | 63 | profiles.add(line.split(":")[-1].strip())
|
63 | 64 | profiles_str = ",".join(profiles)
|
64 | 65 |
|
65 | 66 | 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: |
67 | 70 | 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) |
69 | 74 |
|
70 | 75 | figure_of_merit(
|
71 | 76 | "Tuning Profile",
|
72 | 77 | 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", |
74 | 79 | group_name="profile",
|
75 | 80 | units="",
|
76 | 81 | )
|
| 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