Commit 99f7d3cd authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

Add option to display failed commands lines in status.

parent f9f4c22e
......@@ -55,7 +55,7 @@ class JflowArgumentParser (argparse.ArgumentParser):
# return the modified argument list
return new_arg_strings
def display_workflow_status(workflow, detailed=False):
def display_workflow_status(workflow, detailed=False, display_errors=False):
if workflow.start_time: start_time = time.asctime(time.localtime(workflow.start_time))
else: start_time = "-"
if workflow.start_time and workflow.end_time: elapsed_time = str(workflow.end_time-workflow.start_time)
......@@ -64,6 +64,7 @@ def display_workflow_status(workflow, detailed=False):
if workflow.end_time: end_time = time.asctime(time.localtime(workflow.end_time))
else: end_time = "-"
if detailed:
error = ""
status = "Workflow #" + utils.get_nb_string(workflow.id) + " (" + workflow.name + ") is " + \
workflow.get_status() + ", time elapsed: " + str(elapsed_time) + " (from " + start_time + \
" to " + end_time + "):\n"
......@@ -90,12 +91,14 @@ def display_workflow_status(workflow, detailed=False):
else: aborted = "aborted:" + str(status_info["aborted"])
if status_info["completed"] == status_info["tasks"] and status_info["completed"] > 0: completed = "\033[92mcompleted:" + str(status_info["completed"]) + "\033[0m"
else: completed = "completed:" + str(status_info["completed"])
if display_errors and len(status_info["failed_commands"]) > 0:
error += "\n\nFailed Commands : \n - " + component + " :\n > " + "\n > ".join(status_info["failed_commands"])
status += " - " + component + ", time elapsed " + time_format(status_info["time"]) + \
" (total:" + str(status_info["tasks"]) + ", " + waiting + ", " + running + ", " + failed + \
", " + aborted + ", " + completed + ")"
if i<len(workflow.get_components_nameid())-1: status += "\n"
return status
return status + error
else:
return utils.get_nb_string(workflow.id) + "\t" + workflow.name + "\t" + workflow.get_status() + \
"\t" + elapsed_time + "\t" + start_time + "\t" + end_time
......@@ -121,6 +124,8 @@ if __name__ == '__main__':
default=None, dest="workflow_id")
sub_parser.add_argument("--all", action="store_true", help="Display all workflows status",
default=False, dest="all")
sub_parser.add_argument("--errors", action="store_true", help="Display failed commands",
default=False, dest="display_errors")
sub_parser.set_defaults(cmd_object="status")
# Add available pipelines
......@@ -132,7 +137,7 @@ if __name__ == '__main__':
sub_parser = subparsers.add_parser(instance.name, help=instance.description, fromfile_prefix_chars='@')
sub_parser.convert_arg_line_to_args = instance.__class__.config_parser
[parameters_groups, parameters_order] = instance.get_parameters_per_groups()
for group in parameters_order:
for group in parameters_order:
if group == "default":
for param in parameters_groups[group]:
sub_parser.add_argument(param.flag, **param.export_to_argparse())
......@@ -152,7 +157,7 @@ if __name__ == '__main__':
pgroup.add_argument(param.flag, **param.export_to_argparse())
sub_parser.set_defaults(cmd_object=instance.__class__.__name__)
args = vars(parser.parse_args())
if args["cmd_object"] in wf_classes:
wfmanager.run_workflow(args["cmd_object"], args)
elif args["cmd_object"] == "rerun":
......@@ -160,7 +165,7 @@ if __name__ == '__main__':
elif args["cmd_object"] == "status":
if args["workflow_id"]:
workflow = wfmanager.get_workflow(args["workflow_id"])
print display_workflow_status(workflow, True)
print display_workflow_status(workflow, True, args["display_errors"])
else:
workflows = wfmanager.get_workflows()
if len(workflows) > 0:
......
......@@ -571,7 +571,8 @@ class Workflow(threading.Thread):
"running": 0,
"failed":0,
"aborted": 0,
"completed": 0}
"completed": 0,
"failed_commands": list() }
try:
log = MakeflowLog(self.component_nameids[component_nameid])
log.parse()
......@@ -588,6 +589,7 @@ class Workflow(threading.Thread):
status["running"] += 1
elif n.state == Node.FAILED:
status["failed"] += 1
status["failed_commands"].append( n.command )
elif n.state == Node.ABORTED:
status["aborted"] += 1
elif n.state == Node.COMPLETED:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment