def getLabelsFunction()

in servicelambda/index.py [0:0]


def getLabelsFunction(image):

    key = image['key']

    # Instantiate a table resource object
    imageLabelsTable = os.environ['TABLE']
    table = dynamodb.Table(imageLabelsTable)

    # Get item from table

    try:
        response = table.get_item(Key={'image': key})
        item = response['Item']
        return item
        
    except ClientError as e:
        logging.error(e)
        return "No labels or error"