in amazon_polly_async_batch/setcompletionwaiter.py [0:0]
def load_set_details(event, context):
"""
Loads details of a set (in `SET_TABLE`) and calculates how many tasks remain. This is the first step of a set of
lambda step functions; it simply passes the current status to the next step.
:param event: the event
:param context: ignored
"""
try:
s = dynamo.SetTable(SET_TABLE).get_set(event['setName'])
remaining = int(s['items']['N']) - int(s['successes']['N']) - int(s['failures']['N'])
last_updated = datetime.fromisoformat(s['updatedTime']['S'])
utc_now = datetime.utcnow()
minutes_since_last_update = (utc_now - last_updated).total_seconds() / 60
return {
'setName': s['setName']['S'],
'originalName': s['originalName']['S'],
'description': s['description']['S'],
'outputPrefix': s['outputPrefix']['S'],
'successes': s['successes']['N'],
'failures': s['failures']['N'],
'updatedTime': s['updatedTime']['S'],
'minutesSinceLastUpdate': minutes_since_last_update,
'remaining': remaining
}
except Exception as e:
logger.error('Failed to load set details because {}'.format(str(e)))
raise e