Skip to content

Commit

Permalink
Merge pull request #76 from NREL/UITweaks
Browse files Browse the repository at this point in the history
Misc UI Tweaks
  • Loading branch information
Myoldmopar committed Nov 5, 2021
2 parents 12d38b9 + 5d20005 commit d847321
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 29 deletions.
4 changes: 4 additions & 0 deletions epregressions/diffs/ci_compare_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def main_function(file_name, base_dir, mod_dir, base_sha, mod_sha, make_public,
has_small_diffs = True
print_message("SHD diffs.")

if entry.perf_log_diffs and (entry.perf_log_diffs.diff_type != TextDifferences.EQUAL):
has_small_diffs = True
print_message("PERF_LOG diffs.")

# numeric diff
if entry.ssz_diffs:
has_diffs, has_small_diffs = process_diffs("SSZ", entry.ssz_diffs, has_diffs, has_small_diffs)
Expand Down
48 changes: 42 additions & 6 deletions epregressions/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,43 @@ def both_files_exist(base_path_a, base_path_b, common_relative_path):
return True
return False

@staticmethod
def diff_perf_log(file_a, file_b, diff_file):
# will do a pretty simple CSV text token comparison, no numeric comparison, and omit some certain patterns
filters = [' Version ', 'YMD=', 'hr ']
with io.open(file_a, encoding='utf-8') as f_txt_1:
txt1 = f_txt_1.readlines()
with io.open(file_b, encoding='utf-8') as f_txt_2:
txt2 = f_txt_2.readlines()
txt1_cleaned = []
for line in txt1:
tokens = []
for token in line.split(','):
if any([x in token for x in filters]):
tokens.append("***")
else:
tokens.append(token)
txt1_cleaned.append(','.join(tokens))
txt2_cleaned = []
for line in txt2:
tokens = []
for token in line.split(','):
if any([x in token for x in filters]):
tokens.append("***")
else:
tokens.append(token)
txt2_cleaned.append(','.join(tokens))
if txt1_cleaned == txt2_cleaned:
return TextDifferences.EQUAL
# if we aren't equal, compute the comparison and write to the output file, return that diffs occurred
comparison = unified_diff(txt1_cleaned, txt2_cleaned)
out_file = io.open(diff_file, 'w', encoding='utf-8')
out_lines = list(comparison)
for out_line in out_lines:
out_file.write(out_line)
out_file.close()
return TextDifferences.DIFFS

@staticmethod
def diff_text_files(file_a, file_b, diff_file):
# read the contents of the two files into a list, could read it into text first
Expand Down Expand Up @@ -451,8 +488,6 @@ def diff_text_files(file_a, file_b, diff_file):
out_file = io.open(diff_file, 'w', encoding='utf-8')
out_lines = list(comparison)
for out_line in out_lines:
if sys.version_info[0] == 2:
out_line = out_line.encode('ascii', 'ignore').decode('ascii') # pragma: no cover
out_file.write(out_line)
out_file.close()
return TextDifferences.DIFFS
Expand Down Expand Up @@ -555,8 +590,6 @@ def diff_glhe_files(file_a, file_b, diff_file):
diffs.append("Key error in GLHE object named \"%s\"; something doesn't match" % glhe_name)
with io.open(diff_file, 'w', encoding='utf-8') as out_file:
my_json_str = json.dumps({"diffs": diffs}, ensure_ascii=False)
if sys.version_info[0] == 2: # python 2 unicode crap # pragma: no cover
my_json_str = my_json_str.decode("utf-8")
out_file.write(my_json_str)
return TextDifferences.DIFFS

Expand Down Expand Up @@ -651,8 +684,6 @@ def diff_json_time_series(file_a, file_b, diff_file): # eventually we will hand
{'diffs': diffs, 'num_big_diffs': num_big_diffs, 'num_small_diffs': num_small_diffs},
ensure_ascii=False
)
if sys.version_info[0] == 2: # python 2 unicode crap # pragma: no cover
my_json_str = my_json_str.decode("utf-8")
out_file.write(my_json_str)
return resulting_diff_type, num_values_checked, num_big_diffs, num_small_diffs

Expand Down Expand Up @@ -839,6 +870,11 @@ def process_diffs_for_one_case(
join(case_result_dir_1, 'eplusout.eio'),
join(case_result_dir_2, 'eplusout.eio'),
join(out_dir, 'eplusout.eio.diff'))), TextDifferences.EIO)
if SuiteRunner.both_files_exist(case_result_dir_1, case_result_dir_2, 'eplusout_perflog.csv'):
this_entry.add_text_differences(TextDifferences(SuiteRunner.diff_perf_log(
join(case_result_dir_1, 'eplusout_perflog.csv'),
join(case_result_dir_2, 'eplusout_perflog.csv'),
join(out_dir, 'eplusout_perflog.csv.diff'))), TextDifferences.PERF_LOG)
if SuiteRunner.both_files_exist(case_result_dir_1, case_result_dir_2, 'eplusout.mdd'):
this_entry.add_text_differences(TextDifferences(SuiteRunner.diff_text_files(
join(case_result_dir_1, 'eplusout.mdd'),
Expand Down
7 changes: 7 additions & 0 deletions epregressions/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class TextDifferences:
IDF = 21
STDOUT = 22
STDERR = 23
PERF_LOG = 24
# diff types
EQUAL = 1
DIFFS = 2
Expand Down Expand Up @@ -215,6 +216,7 @@ def __init__(self, name_relative_to_testfiles_dir, epw):
self.idf_diffs = None
self.stdout_diffs = None
self.stderr_diffs = None
self.perf_log_diffs = None

def add_summary_result(self, end_err_summary):
self.summary_result = end_err_summary
Expand Down Expand Up @@ -278,6 +280,8 @@ def add_text_differences(self, diffs, diff_type):
self.stdout_diffs = diffs
elif diff_type == TextDifferences.STDERR:
self.stderr_diffs = diffs
elif diff_type == TextDifferences.PERF_LOG:
self.perf_log_diffs = diffs

def add_table_differences(self, diffs):
self.table_diffs = diffs
Expand Down Expand Up @@ -348,6 +352,8 @@ def to_dict(self):
response['stdout_diffs'] = self.stdout_diffs.to_dict()
if self.stderr_diffs:
response['stderr_diffs'] = self.stderr_diffs.to_dict()
if self.perf_log_diffs:
response['perf_log_diffs'] = self.perf_log_diffs.to_dict()
return response


Expand Down Expand Up @@ -439,6 +445,7 @@ def add_test_entry(self, this_entry):
this_entry.glhe_diffs: "glhe",
this_entry.stdout_diffs: "stdout",
this_entry.stderr_diffs: "stderr",
this_entry.perf_log_diffs: "perf_log"
}
for diff in text_diff_hash:
file_type = text_diff_hash[diff]
Expand Down
6 changes: 4 additions & 2 deletions epregressions/tests/diffs/test_ci_compare_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_main_function(self):
# now write out a bunch of diff files and make sure the output is good to go
end_string = 'EnergyPlus Completed Successfully-- 0 Warning; 0 Severe Errors; Elapsed Time=00hr 00min 3.06sec'
self._write_files_to_both_folders('eplusout.end', end_string, end_string)
# test one set of results there there is just table small diffs
# test one set of results where there is just table small diffs
shutil.copy(
os.path.join(self.tbl_resource_dir, 'eplustbl.htm'),
os.path.join(self.temp_base_dir, 'eplustbl.htm')
Expand Down Expand Up @@ -217,6 +217,7 @@ def test_main_function(self):
self._write_files_to_both_folders('in.idf', 'base idf content', 'mod idf content')
self._write_files_to_both_folders('eplusout.stdout', 'base standard output', 'mod standard output')
self._write_files_to_both_folders('eplusout.stderr', 'base standard error', 'mod standard error')
self._write_files_to_both_folders('eplusout_perflog.csv', 'a,b,c\nd,e,f', 'a,b,c\nd,e,g')
with captured_output() as (out, err):
# should fail if we don't have any .end files
main_function(
Expand Down Expand Up @@ -259,7 +260,8 @@ def test_main_function(self):
'[decent_ci:test_result:warn]',
'IDF diffs',
'StdOut diffs',
'StdErr diffs'
'StdErr diffs',
'PERF_LOG diffs'
]
output = out.getvalue().strip()
for token in expected_tokens:
Expand Down
2 changes: 2 additions & 0 deletions epregressions/tests/resources/eplusout_perflog_base.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Program, Version, TimeStamp,Use Coil Direct Solution,Zone Radiant Exchange Algorithm,Override Mode,Number of Timesteps per Hour,Minimum Number of Warmup Days,SuppressAllBeginEnvironmentResets,Minimum System Timestep,MaxZoneTempDiff,MaxAllowedDelTemp,Electricity ABUPS Total [J],Natural Gas ABUPS Total [J],Gasoline ABUPS Total [J],Diesel ABUPS Total [J],Coal ABUPS Total [J],Fuel Oil No 1 ABUPS Total [J],Fuel Oil No 2 ABUPS Total [J],Propane ABUPS Total [J],Other Fuel 1 ABUPS Total [J],Other Fuel 2 ABUPS Total [J],District Cooling ABUPS Total [J],District Heating ABUPS Total [J],Water ABUPS Total [m3],Values Gathered Over [hours],Facility Any Zone Oscillating Temperatures Time [hours],Facility Any Zone Oscillating Temperatures During Occupancy Time [hours],Facility Any Zone Oscillating Temperatures in Deadband Time [hours],Run Time [seconds],Run Time [string],Number of Warnings,Number of Severe,
EnergyPlus, Version 9.4.0-734af19f9a, YMD=2020.12.02 13:45,False,CarrollMRT,Normal,6,1,False,2.0,0.30,2.0000E-003,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.00,16.32,7.58,0.00,17.66,00hr 00min 17.66sec,6,0,
2 changes: 2 additions & 0 deletions epregressions/tests/resources/eplusout_perflog_mod.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Program, Version, TimeStamp,Use Coil Direct Solution,Zone Radiant Exchange Algorithm,Override Mode,Number of Timesteps per Hour,Minimum Number of Warmup Days,SuppressAllBeginEnvironmentResets,Minimum System Timestep,MaxZoneTempDiff,MaxAllowedDelTemp,Electricity ABUPS Total [J],Natural Gas ABUPS Total [J],Gasoline ABUPS Total [J],Diesel ABUPS Total [J],Coal ABUPS Total [J],Fuel Oil No 1 ABUPS Total [J],Fuel Oil No 2 ABUPS Total [J],Propane ABUPS Total [J],Other Fuel 1 ABUPS Total [J],Other Fuel 2 ABUPS Total [J],District Cooling ABUPS Total [J],District Heating ABUPS Total [J],Water ABUPS Total [m3],Values Gathered Over [hours],Facility Any Zone Oscillating Temperatures Time [hours],Facility Any Zone Oscillating Temperatures During Occupancy Time [hours],Facility Any Zone Oscillating Temperatures in Deadband Time [hours],Run Time [seconds],Run Time [string],Number of Warnings,Number of Severe,
EnergyPlus, Version 9.5.0-dfdff19f9a, YMD=2020.12.31 14:45,True,CarrollMRT,Normal,6,1,False,2.0,0.30,2.0000E-003,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.00,16.32,7.58,0.00,17.66,01hr 00min 17.66sec,6,0,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Program, Version, TimeStamp,Use Coil Direct Solution,Zone Radiant Exchange Algorithm,Override Mode,Number of Timesteps per Hour,Minimum Number of Warmup Days,SuppressAllBeginEnvironmentResets,Minimum System Timestep,MaxZoneTempDiff,MaxAllowedDelTemp,Electricity ABUPS Total [J],Natural Gas ABUPS Total [J],Gasoline ABUPS Total [J],Diesel ABUPS Total [J],Coal ABUPS Total [J],Fuel Oil No 1 ABUPS Total [J],Fuel Oil No 2 ABUPS Total [J],Propane ABUPS Total [J],Other Fuel 1 ABUPS Total [J],Other Fuel 2 ABUPS Total [J],District Cooling ABUPS Total [J],District Heating ABUPS Total [J],Water ABUPS Total [m3],Values Gathered Over [hours],Facility Any Zone Oscillating Temperatures Time [hours],Facility Any Zone Oscillating Temperatures During Occupancy Time [hours],Facility Any Zone Oscillating Temperatures in Deadband Time [hours],Run Time [seconds],Run Time [string],Number of Warnings,Number of Severe,
EnergyPlus, Version 9.4.0-1234567890, YMD=2021.12.02 13:45,False,CarrollMRT,Normal,6,1,False,2.0,0.30,2.0000E-003,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.00,16.32,7.58,0.00,17.66,00hr 00min 18.66sec,6,0,
12 changes: 12 additions & 0 deletions epregressions/tests/test_runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,18 @@ def test_err_diff_equal_with_ignored_differences(self):
diff_file = os.path.join(self.temp_base_build_dir, 'err.diff')
self.assertEqual(TextDifferences.EQUAL, SuiteRunner.diff_text_files(base_err, mod_err, diff_file))

def test_perf_log_equal_with_ignored_differences(self):
base_perf_log = os.path.join(self.resources, 'eplusout_perflog_base.csv')
mod_perf_log = os.path.join(self.resources, 'eplusout_perflog_same_except_times.csv')
diff_file = os.path.join(self.temp_base_build_dir, 'perf_log.diff')
self.assertEqual(TextDifferences.EQUAL, SuiteRunner.diff_perf_log(base_perf_log, mod_perf_log, diff_file))

def test_perf_log_diffs(self):
base_perf_log = os.path.join(self.resources, 'eplusout_perflog_base.csv')
mod_perf_log = os.path.join(self.resources, 'eplusout_perflog_mod.csv')
diff_file = os.path.join(self.temp_base_build_dir, 'perf_log.diff')
self.assertEqual(TextDifferences.DIFFS, SuiteRunner.diff_perf_log(base_perf_log, mod_perf_log, diff_file))

def test_audit_diff_equal_with_ignored_differences(self):
base_audit = os.path.join(self.resources, 'eplusout_base.audit')
mod_audit = os.path.join(self.resources, 'eplusout_mod.audit')
Expand Down
49 changes: 28 additions & 21 deletions epregressions/tk_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def init_window(self):
group_idf_tools = LabelFrame(pane_idfs, text="IDF Selection Tools")
group_idf_tools.pack(fill=X, padx=5)
self.idf_select_all_button = Button(
group_idf_tools, text="Refresh", command=self.client_idf_refresh
group_idf_tools, text="Refresh", command=self.build_idf_listing
)
self.idf_select_all_button.pack(side=LEFT, expand=1)
self.idf_select_all_button = Button(
Expand All @@ -252,7 +252,7 @@ def init_window(self):
group_full_idf_list = LabelFrame(pane_idfs, text="Full IDF List")
group_full_idf_list.pack(fill=BOTH, expand=True, padx=5)
scrollbar = Scrollbar(group_full_idf_list)
self.full_idf_listbox = Listbox(group_full_idf_list, yscrollcommand=scrollbar.set)
self.full_idf_listbox = Listbox(group_full_idf_list, yscrollcommand=scrollbar.set, selectmode="extended")
self.full_idf_listbox.bind('<Double-1>', self.idf_move_to_active)
self.full_idf_listbox.pack(fill=BOTH, side=LEFT, expand=True)
scrollbar.pack(fill=Y, side=LEFT)
Expand All @@ -273,7 +273,7 @@ def init_window(self):
group_active_idf_list = LabelFrame(pane_idfs, text="Active IDF List")
group_active_idf_list.pack(fill=BOTH, expand=True, padx=5)
scrollbar = Scrollbar(group_active_idf_list)
self.active_idf_listbox = Listbox(group_active_idf_list, yscrollcommand=scrollbar.set)
self.active_idf_listbox = Listbox(group_active_idf_list, yscrollcommand=scrollbar.set, selectmode="extended")
self.active_idf_listbox.bind('<Double-1>', self.idf_remove_from_active)
self.active_idf_listbox.pack(fill=BOTH, side=LEFT, expand=True)
scrollbar.pack(fill=Y, side=LEFT)
Expand Down Expand Up @@ -595,9 +595,6 @@ def copy_log(self):
self.root.clipboard_clear()
self.root.clipboard_append(message_string)

def client_idf_refresh(self):
self.build_idf_listing()

def idf_move_to_active(self, _=None):
if self.long_thread:
return
Expand All @@ -608,15 +605,19 @@ def idf_move_to_active(self, _=None):
if not current_selection:
simpledialog.messagebox.showerror("IDF Selection Error", "No IDF Selected")
return
currently_selected_idf = self.full_idf_listbox.get(current_selection)
try:
self.active_idf_listbox.get(0, END).index(currently_selected_idf)
simpledialog.messagebox.showwarning("IDF Selection Warning", "IDF already exists in active list")
return
except ValueError:
pass # the value error indicates it was _not_ found, so this is success
self.active_idf_listbox.insert(END, currently_selected_idf)
self.idf_refresh_count_status(currently_selected_idf, True)
already_exist_count = 0
for selection in current_selection:
currently_selected_idf = self.full_idf_listbox.get(selection)
try:
self.active_idf_listbox.get(0, END).index(currently_selected_idf)
already_exist_count += 1
continue
except ValueError:
pass # the value error indicates it was _not_ found, so this is success
self.active_idf_listbox.insert(END, currently_selected_idf)
self.idf_refresh_count_status(currently_selected_idf, True)
if already_exist_count > 0:
simpledialog.messagebox.showwarning("IDF Selection Warning", "At least one IDF was already in active list")

def idf_remove_from_active(self, event=None):
if self.long_thread:
Expand All @@ -630,8 +631,11 @@ def idf_remove_from_active(self, event=None):
return
simpledialog.messagebox.showerror("IDF Selection Error", "No IDF Selected")
return
self.active_idf_listbox.delete(current_selection)
self.idf_refresh_count_status(current_selection, False)
for selection in reversed(current_selection):
currently_selected_idf = self.active_idf_listbox.get(selection)
item_index = self.active_idf_listbox.get(0, END).index(currently_selected_idf)
self.active_idf_listbox.delete(item_index)
self.idf_refresh_count_status(currently_selected_idf, False)

def idf_select_all(self):
self.idf_deselect_all()
Expand Down Expand Up @@ -801,21 +805,24 @@ def client_run(self):
if not self.build_1:
messagebox.showerror("Build folder 1 problem", "Select a valid build folder 1 prior to running")
return
ok_or_cancel_msg = "Press OK to continue anyway (risky!), or press Cancel to abort"
build_1_valid = self.build_1.verify()
build_1_problem_files = [b[1] for b in build_1_valid if not b[2]]
if len(build_1_problem_files):
missing_files = '\n'.join(build_1_problem_files)
messagebox.showerror("Build folder 1 problem", f"Missing files:\n{missing_files}")
return
r = messagebox.askokcancel("Build folder 1 problem", f"Missing files:\n{missing_files}\n{ok_or_cancel_msg}")
if not r:
return
if not self.build_2:
messagebox.showerror("Build folder 2 problem", "Select a valid build folder 2 prior to running")
return
build_2_valid = self.build_2.verify()
build_2_problem_files = [b[1] for b in build_2_valid if not b[2]]
if len(build_2_problem_files):
missing_files = '\n'.join(build_2_problem_files)
messagebox.showerror("Build folder 2 problem", f"Missing files:\n{missing_files}")
return
r = messagebox.askokcancel("Build folder 2 problem", f"Missing files:\n{missing_files}\n{ok_or_cancel_msg}")
if not r:
return
run_configuration = TestRunConfiguration(
force_run_type=self.run_period_option.get(),
num_threads=num_threads,
Expand Down

0 comments on commit d847321

Please sign in to comment.