in pipe-cli/pipe.py [0:0]
def view_run(run_id, node_details, parameters_details, tasks_details, tags_details):
run_model = PipelineRun.get(run_id)
if not run_model.pipeline and run_model.pipeline_id is not None:
pipeline_model = Pipeline.get(run_model.pipeline_id)
if pipeline_model is not None:
run_model.pipeline = pipeline_model.name
run_model_price = PipelineRun.get_estimated_price(run_id)
run_main_info_table = prettytable.PrettyTable()
run_main_info_table.field_names = ["key", "value"]
run_main_info_table.align = "l"
run_main_info_table.set_style(12)
run_main_info_table.header = False
run_main_info_table.add_row(['ID:', run_model.identifier])
run_main_info_table.add_row(['Pipeline:', run_model.pipeline])
run_main_info_table.add_row(['Version:', run_model.version])
if run_model.owner is not None:
run_main_info_table.add_row(['Owner:', run_model.owner])
if run_model.endpoints is not None and len(run_model.endpoints) > 0:
endpoint_index = 0
for endpoint in run_model.endpoints:
if endpoint_index == 0:
run_main_info_table.add_row(['Endpoints:', endpoint])
else:
run_main_info_table.add_row(['', endpoint])
endpoint_index = endpoint_index + 1
if not run_model.scheduled_date:
run_main_info_table.add_row(['Scheduled', 'N/A'])
else:
run_main_info_table.add_row(['Scheduled:', run_model.scheduled_date])
if not run_model.start_date:
run_main_info_table.add_row(['Started', 'N/A'])
else:
run_main_info_table.add_row(['Started:', run_model.start_date])
if not run_model.end_date:
run_main_info_table.add_row(['Completed', 'N/A'])
else:
run_main_info_table.add_row(['Completed:', run_model.end_date])
run_main_info_table.add_row(['Status:', state_utilities.color_state(run_model.status)])
run_main_info_table.add_row(['ParentID:', run_model.parent_id])
if run_model_price.total_price > 0:
run_main_info_table.add_row(['Estimated price:', '{} $'.format(round(run_model_price.total_price, 2))])
else:
run_main_info_table.add_row(['Estimated price:', 'N/A'])
run_main_info_table.add_row(['Tags:', run_model.tags_str])
click.echo(run_main_info_table)
click.echo()
if node_details:
node_details_table = prettytable.PrettyTable()
node_details_table.field_names = ["key", "value"]
node_details_table.align = "l"
node_details_table.set_style(12)
node_details_table.header = False
for key, value in run_model.instance:
if key == PriceType.SPOT:
node_details_table.add_row(['price-type', PriceType.SPOT if value else PriceType.ON_DEMAND])
else:
node_details_table.add_row([key, value])
echo_title('Node details:')
click.echo(node_details_table)
click.echo()
if parameters_details:
echo_title('Parameters:')
if len(run_model.parameters) > 0:
for parameter in run_model.parameters:
click.echo('{}={}'.format(parameter.name, parameter.value))
else:
click.echo('No parameters are configured')
click.echo()
if tasks_details:
echo_title('Tasks:', line=False)
if len(run_model.tasks) > 0:
tasks_table = prettytable.PrettyTable()
tasks_table.field_names = ['Task', 'State', 'Scheduled', 'Started', 'Finished']
tasks_table.align = "r"
for task in run_model.tasks:
scheduled = 'N/A'
started = 'N/A'
finished = 'N/A'
if task.created is not None:
scheduled = task.created
if task.started is not None:
started = task.started
if task.finished is not None:
finished = task.finished
tasks_table.add_row(
[task.name, state_utilities.color_state(task.status), scheduled, started, finished])
click.echo(tasks_table)
else:
click.echo('No tasks are available for the run')
click.echo()
if tags_details:
echo_title('Tags:')
if len(run_model.tags) > 0:
for tag_name in run_model.tags:
click.echo('{}={}'.format(tag_name, run_model.tags[tag_name]))
else:
click.echo('No tags are configured')
click.echo()