Skip to content

Commit 76a6e63

Browse files
committed
clean linter
1 parent f79f4d1 commit 76a6e63

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

toolchain/mfc/bench.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os, sys, uuid, subprocess, dataclasses, typing, math
1+
import os, sys, uuid, subprocess, dataclasses, typing, math, traceback
22

33
import rich.table
44

@@ -209,7 +209,6 @@ def diff():
209209
cons.print(f"[bold red]Error[/bold red]: Benchmarking failed since grind time speedup for {target.name} below acceptable threshold (<0.95) - Case: {slug}")
210210
err = 1
211211
except Exception as e:
212-
import traceback
213212
cons.print(
214213
f"[bold red]ERROR[/bold red]: Failed to compute speedup for {target.name} in {slug}: {e}\n"
215214
f"{traceback.format_exc()}"

toolchain/mfc/test/test.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,36 @@ def test():
206206

207207

208208
# pylint: disable=too-many-locals, too-many-branches, too-many-statements, trailing-whitespace
209+
def _process_silo_file(silo_filepath: str, case: TestCase, out_filepath: str):
210+
"""Process a single silo file with h5dump and check for NaNs/Infinities."""
211+
h5dump = f"{HDF5.get_install_dirpath(case.to_input_file())}/bin/h5dump"
212+
213+
if not os.path.exists(h5dump or ""):
214+
if not does_command_exist("h5dump"):
215+
raise MFCException("h5dump couldn't be found.")
216+
h5dump = shutil.which("h5dump")
217+
218+
output, err = get_program_output([h5dump, silo_filepath])
219+
220+
if err != 0:
221+
raise MFCException(
222+
f"Test {case}: Failed to run h5dump. You can find the run's output in {out_filepath}, "
223+
f"and the case dictionary in {case.get_filepath()}."
224+
)
225+
226+
if "nan," in output:
227+
raise MFCException(
228+
f"Test {case}: Post Process has detected a NaN. You can find the run's output in {out_filepath}, "
229+
f"and the case dictionary in {case.get_filepath()}."
230+
)
231+
232+
if "inf," in output:
233+
raise MFCException(
234+
f"Test {case}: Post Process has detected an Infinity. You can find the run's output in {out_filepath}, "
235+
f"and the case dictionary in {case.get_filepath()}."
236+
)
237+
238+
209239
def _handle_case(case: TestCase, devices: typing.Set[int]):
210240
# pylint: disable=global-statement, global-variable-not-assigned
211241
global current_test_number
@@ -287,24 +317,7 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
287317
if os.path.isdir(silo_dir):
288318
for silo_filename in os.listdir(silo_dir):
289319
silo_filepath = os.path.join(silo_dir, silo_filename)
290-
h5dump = f"{HDF5.get_install_dirpath(case.to_input_file())}/bin/h5dump"
291-
292-
if not os.path.exists(h5dump or ""):
293-
if not does_command_exist("h5dump"):
294-
raise MFCException("h5dump couldn't be found.")
295-
296-
h5dump = shutil.which("h5dump")
297-
298-
output, err = get_program_output([h5dump, silo_filepath])
299-
300-
if err != 0:
301-
raise MFCException(f"Test {case}: Failed to run h5dump. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
302-
303-
if "nan," in output:
304-
raise MFCException(f"Test {case}: Post Process has detected a NaN. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
305-
306-
if "inf," in output:
307-
raise MFCException(f"Test {case}: Post Process has detected an Infinity. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
320+
_process_silo_file(silo_filepath, case, out_filepath)
308321

309322
case.delete_output()
310323

0 commit comments

Comments
 (0)