def lambda_handler()

in ApplicationCode/dockerfiles/stage-b-process-data/src/lambda_function.py [0:0]


def lambda_handler(event, context):
    """Calls custom transform developed by user
    
    Arguments:
        event {dict} -- Dictionary with details on previous processing step
        context {dict} -- Dictionary with details on Lambda context
    
    Returns:
        {dict} -- Dictionary with Processed Bucket and Key(s)
    """ 
    try:
        logger.info('Stage B Transformation Lambda')
        component = context.function_name.split('-')[-2].title()
        peh_id = octagon_client.start_pipeline_execution(pipeline_name='{}-{}-post-stage'.format(event['body']['team'], event['body']['pipeline']), comment=event)
        octagon_client.update_pipeline_execution(status="Post-Stage {} Processing".format(component), component=component)

        logger.info('Fetching bucket and key(s) from previous step')
        bucket = event['body']['bucket']
        keys_to_process = event['body']['keysToProcess']
        team= event['body']['team']
        dataset = event['body']['dataset']
        
        ## Call custom transform created by user and process the file
        logger.info('Custom Processing Objects')
        response = TransformHandler().stage_b_transform(bucket, keys_to_process, team, dataset)
        response['peh_id'] = peh_id
        remove_content_tmp()
    except Exception as e:
        logger.error("Fatal error", exc_info=True)
        octagon_client.end_pipeline_execution_failed(component=component,
                                                     issue_comment="Post-Stage {} Error: {}".format(component, repr(e)))
        remove_content_tmp()
        raise e
    return response