Update scripts to allow vtr test .. -v3 to show tool logs in case of error
diff --git a/vtr_flow/scripts/python_libs/verilogtorouting/util.py b/vtr_flow/scripts/python_libs/verilogtorouting/util.py
index fae2a38..a7ac559 100644
--- a/vtr_flow/scripts/python_libs/verilogtorouting/util.py
+++ b/vtr_flow/scripts/python_libs/verilogtorouting/util.py
@@ -21,7 +21,7 @@
class CommandRunner(object):
- def __init__(self, timeout_sec=None, max_memory_mb=None, track_memory=True, verbose=False, echo_cmd=False, indent="\t"):
+ def __init__(self, timeout_sec=None, max_memory_mb=None, track_memory=True, verbose_error=False, verbose=False, echo_cmd=False, indent="\t"):
"""
An object for running system commands with timeouts, memory limits and varying verbose-ness
@@ -30,6 +30,7 @@
timeout_sec: maximum walk-clock-time of the command in seconds. Default: None
max_memory_mb: maximum memory usage of the command in megabytes (if supported). Default: None
track_memory: Whether to track usage of the command (disabled if not supported). Default: True
+ verbose_error: Produce more verbose output if the commadn fails. Default: False
verbose: Produce more verbose output. Default: False
echo_cmd: Echo the command before running. Default: False
indent: The string specifying a single indent (used in verbose mode)
@@ -37,11 +38,12 @@
self._timeout_sec = timeout_sec
self._max_memory_mb = max_memory_mb
self._track_memory = track_memory
+ self._verbose_error = verbose_error
self._verbose = verbose
self._echo_cmd = echo_cmd
self._indent = indent
- def run_system_command(self, cmd, work_dir, log_filename=None, exepcted_return_code=0, indent_depth=0):
+ def run_system_command(self, cmd, work_dir, log_filename=None, expected_return_code=0, indent_depth=0):
"""
Runs the specified command in the system shell.
@@ -117,10 +119,6 @@
#Save the output
cmd_output.append(line)
- #Send to stdout
- if self._verbose:
- print indent_depth*self._indent + line,
-
#Abort if over time limit
elapsed_time = time.time() - start_time
if self._timeout_sec and elapsed_time > self._timeout_sec:
@@ -139,7 +137,15 @@
cmd_returncode = proc.returncode
- if cmd_returncode != exepcted_return_code:
+ cmd_errored = (cmd_returncode != expected_return_code)
+
+ #Send to stdout
+ if self._verbose or (cmd_errored and self._verbose_error):
+ for line in cmd_output:
+ print indent_depth*self._indent + line,
+
+
+ if cmd_errored:
raise CommandError(msg="Executable {exec_name} failed".format(exec_name=os.path.basename(orig_cmd[0])),
cmd=cmd,
log=os.path.join(work_dir, log_filename),
diff --git a/vtr_flow/scripts/vtr-flow.py b/vtr_flow/scripts/vtr-flow.py
index 708faf3..dc0bbd6 100755
--- a/vtr_flow/scripts/vtr-flow.py
+++ b/vtr_flow/scripts/vtr-flow.py
@@ -197,7 +197,8 @@
command_runner = CommandRunner(track_memory=args.track_memory_usage,
max_memory_mb=args.memory_limit,
timeout_sec=args.timeout,
- verbose=True if args.verbosity >= 2 else False,
+ verbose_error=True if args.verbosity == 2 else False,
+ verbose=True if args.verbosity > 2 else False,
echo_cmd=True if args.verbosity >= 4 else False)
exit_status = 0
try:
@@ -247,7 +248,7 @@
exit_status = 2
finally:
- print_verbose(BASIC_VERBOSITY, args.verbosity, "\n{} took {}".format(prog, format_elapsed_time(datetime.now() - start)))
+ print_verbose(BASIC_VERBOSITY, args.verbosity, "\n# {} took {} (exiting {})".format(prog, format_elapsed_time(datetime.now() - start), exit_status))
sys.exit(exit_status)
def process_unkown_args(unkown_args):
diff --git a/vtr_flow/scripts/vtr-task.py b/vtr_flow/scripts/vtr-task.py
index ca88242..1df01ad 100755
--- a/vtr_flow/scripts/vtr-task.py
+++ b/vtr_flow/scripts/vtr-task.py
@@ -198,7 +198,7 @@
print "Error:", e.msg
finally:
if args.print_metadata:
- print "\n{} took {} (exiting {})".format(prog, format_elapsed_time(datetime.now() - start), num_failed)
+ print "\n# {} took {} (exiting {})".format(prog, format_elapsed_time(datetime.now() - start), num_failed)
sys.exit(num_failed)
def run_tasks(args, configs):
@@ -258,7 +258,7 @@
#Re-run parsing only
cmd = job.command()
cmd += ['--parse']
- cmd += ['-v', str(max(0, args.verbosity-2))]
+ cmd += ['-v', str(max(0, args.verbosity-3))]
subprocess.check_call(cmd, cwd=job.work_dir(run_dir))
if task_metrics_filepath is None:
@@ -414,7 +414,7 @@
reason = e.msg
if not metric_passed:
- print_verbose(BASIC_VERBOSITY, args.verbosity, " FAILED {} {}/{}: {} {}".format(config.task_name, arch, circuit, metric, reason))
+ print_verbose(BASIC_VERBOSITY, args.verbosity, " FAILED {} {} {}/{}: {} {}".format(os.path.basename(run_dir), config.task_name, arch, circuit, metric, reason))
num_qor_failures += 1
if num_qor_failures == 0:
diff --git a/vtr_flow/scripts/vtr-test.py b/vtr_flow/scripts/vtr-test.py
index 8c0a59a..0a0748e 100755
--- a/vtr_flow/scripts/vtr-test.py
+++ b/vtr_flow/scripts/vtr-test.py
@@ -71,7 +71,7 @@
help="How many processors to use for execution.")
parser.add_argument("-v", "--verbosity",
- choices=VERBOSITY_CHOICES,
+ choices=VERBOSITY_CHOICES + [5],
default=2,
type=int,
help="Sets the verbosity of the script. Higher values produce more output.")
@@ -142,7 +142,7 @@
sys.exit(num_func_failures + num_qor_failures)
finally:
- print_verbose(BASIC_VERBOSITY, args.verbosity, "\n{} took {}".format(prog, format_elapsed_time(datetime.now() - start)))
+ print_verbose(BASIC_VERBOSITY, args.verbosity, "\n# {} took {} (exiting {})".format(prog, format_elapsed_time(datetime.now() - start), num_func_failures + num_qor_failures))
def run_odin_test(args, test_name):
odin_reg_script = None