Add step info and timestamp to get actions command
Adds an execution start time and a summary of steps that have succeeded, failed, or otherwise. Change-Id: I8aaaa45b9c3e00aaf3ae428911dc522509dec694
This commit is contained in:
parent
29d8810465
commit
70e451dce3
@ -122,20 +122,43 @@ def gen_action_table(action_list):
|
||||
'action_lifecycle'
|
||||
"""
|
||||
actions = format_utils.table_factory(
|
||||
field_names=['Name', 'Action', 'Lifecycle'])
|
||||
field_names=['Name', 'Action', 'Lifecycle', 'Execution Time',
|
||||
'Step Succ/Fail/Oth'])
|
||||
if action_list:
|
||||
# sort by id, which is ULID - chronological.
|
||||
for action in sorted(action_list, key=lambda k: k['id']):
|
||||
actions.add_row([
|
||||
action.get('name'), 'action/{}'.format(action.get('id')),
|
||||
action.get('action_lifecycle')
|
||||
action.get('name'),
|
||||
'action/{}'.format(action.get('id')),
|
||||
action.get('action_lifecycle'),
|
||||
action.get('dag_execution_date'),
|
||||
_step_summary(action.get('steps', []))
|
||||
])
|
||||
else:
|
||||
actions.add_row(['None', '', ''])
|
||||
actions.add_row(['None', '', '', '', ''])
|
||||
|
||||
return format_utils.table_get_string(actions)
|
||||
|
||||
|
||||
def _step_summary(step_list):
|
||||
"""Creates a single string representation of the step status
|
||||
|
||||
Success/Failed/Other counts in each position
|
||||
"""
|
||||
successes = 0
|
||||
failures = 0
|
||||
other = 0
|
||||
for s in step_list:
|
||||
state = s.get('state')
|
||||
if state in ['success']:
|
||||
successes += 1
|
||||
elif state in ['failed']:
|
||||
failures += 1
|
||||
else:
|
||||
other += 1
|
||||
return "{}/{}/{}".format(successes, failures, other)
|
||||
|
||||
|
||||
def gen_collection_table(collection_list):
|
||||
"""Generates a list of collections and their status
|
||||
|
||||
|
@ -55,6 +55,7 @@ def test_create_action(*args):
|
||||
assert 'Lifecycle' in response
|
||||
assert 'action/01BTTMFVDKZFRJM80FGD7J1AKN' in response
|
||||
assert 'Error:' not in response
|
||||
assert '0/0/0' in response
|
||||
|
||||
|
||||
@responses.activate
|
||||
|
@ -77,6 +77,7 @@ def test_get_actions(*args):
|
||||
assert 'deploy_site' in response
|
||||
assert 'action/01BTP9T2WCE1PAJR2DWYXG805V' in response
|
||||
assert 'Lifecycle' in response
|
||||
assert '2/1/0' in response
|
||||
|
||||
|
||||
@responses.activate
|
||||
|
Loading…
x
Reference in New Issue
Block a user