Skip to content

Commit 173b223

Browse files
committed
[Format] Fixed python linting error
1 parent f496af3 commit 173b223

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

vtr_flow/scripts/run_vtr_flow.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@ def format_human_readable_memory(num_kbytes):
422422
return value
423423

424424

425+
def get_memory_usage(logfile):
426+
"""Extrats the memory usage from the *.out log files"""
427+
with open(logfile, "r") as fpmem:
428+
for line in fpmem.readlines():
429+
if "Maximum resident set size" in line:
430+
return format_human_readable_memory(int(line.split()[-1]))
431+
return "--"
432+
433+
425434
# pylint: enable=too-many-statements
426435

427436

@@ -499,13 +508,12 @@ def vtr_command_main(arg_list, prog=None):
499508

500509
finally:
501510
seconds = datetime.now() - start
502-
with open(temp_dir / "vpr.out", "r") as fpmem:
503-
for line in fpmem.readlines():
504-
if "Maximum resident set size" in line:
505-
mem_usage = format_human_readable_memory(int(line.split()[-1]))
511+
506512
print(
507513
"{status} (took {time}, vpr run consumed {max_mem} memory)".format(
508-
status=error_status, time=vtr.format_elapsed_time(seconds), max_mem=mem_usage
514+
status=error_status,
515+
time=vtr.format_elapsed_time(seconds),
516+
max_mem=get_memory_usage(temp_dir / "vpr.out"),
509517
)
510518
)
511519
temp_dir.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)