Commit ae01af34 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Move print functions to jflow_cli

parent f0beb466
......@@ -60,6 +60,48 @@ class JflowArgumentParser (argparse.ArgumentParser):
return new_arg_strings
def print_workflow_outputs(the_workflow, logs):
outputs = the_workflow.get_outputs_per_components()
descriptions = the_workflow.get_description_per_components()
idx = 1
for output in outputs:
name = output[:output.index(".")]
component = str(idx) + ". "
if output in descriptions and descriptions[output] is not None:
component += descriptions[output]
else:
component += name
component += ":\n"
has_outputs = False
for output_file in outputs[output]:
if logs or (not output_file.endswith(".stdout") and not output_file.endswith(".stderr")):
has_outputs = True
component += " - " + outputs[output][output_file] + "\n"
if has_outputs:
print(component)
idx += 1
def print_workflow_programs(the_workflow):
programs = the_workflow.get_workflow_programs()
descriptions = the_workflow.get_description_per_components()
idx = 1
for component, program in programs.items():
name = component
component_str = str(idx) + ". "
if component in descriptions and descriptions[component] is not None:
component_str += descriptions[component]
else:
component_str += name
component_str += ":\n"
component_str += "\t- Program: {0}\n".format(program["name"])
component_str += "\t- Version: {0}\n".format(program["version"])
component_str += "\t- Parameters: {0}\n".format(", ".join(program["parameters"])
if len(program["parameters"]) > 0 else "None")
print(component_str)
idx += 1
if __name__ == '__main__':
# Create a workflow manager to get access to our workflows
......@@ -167,7 +209,7 @@ if __name__ == '__main__':
if args["what"] in ["outputs", "outputs_logs"]:
try:
my_workflow = wfmanager.get_workflow(args["workflow_id"])
my_workflow.print_workflow_outputs(args["what"] == "outputs_logs")
print_workflow_outputs(my_workflow, args["what"] == "outputs_logs")
except Exception as e:
utils.display_error_message(str(e))
elif args["what"] == "execution_graph":
......@@ -191,7 +233,7 @@ if __name__ == '__main__':
print(("edges: ", gr.edges()))
elif args["what"] == "programs":
my_workflow = wfmanager.get_workflow(args["workflow_id"])
my_workflow.print_workflow_programs()
print_workflow_programs(my_workflow)
elif args["cmd_object"] == "status":
if args["workflow_id"]:
try:
......
......@@ -585,46 +585,6 @@ class Workflow(threading.Thread):
else:
return None
def print_workflow_outputs(self, logs):
outputs = self.get_outputs_per_components()
descriptions = self.get_description_per_components()
idx = 1
for output in outputs:
name = output[:output.index(".")]
component = str(idx) + ". "
if output in descriptions and descriptions[output] is not None:
component += descriptions[output]
else:
component += name
component += ":\n"
has_outputs = False
for output_file in outputs[output]:
if logs or (not output_file.endswith(".stdout") and not output_file.endswith(".stderr")):
has_outputs = True
component += " - " + outputs[output][output_file] + "\n"
if has_outputs:
print(component)
idx += 1
def print_workflow_programs(self):
programs = self.get_workflow_programs()
descriptions = self.get_description_per_components()
idx = 1
for component, program in programs.items():
name = component
component_str = str(idx) + ". "
if component in descriptions and descriptions[component] is not None:
component_str += descriptions[component]
else:
component_str += name
component_str += ":\n"
component_str += "\t- Program: {0}\n".format(program["name"])
component_str += "\t- Version: {0}\n".format(program["version"])
component_str += "\t- Parameters: {0}\n".format(", ".join(program["parameters"])
if len(program["parameters"]) > 0 else "None")
print(component_str)
idx += 1
def get_description_per_components(self):
dag = self.get_execution_graph()
descriptions = {}
......
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