def lambda_handler()

in repos/serving/lambdas/functions/processing-job-status-check/lambda_function.py [0:0]


def lambda_handler(event, context):
    """Calls custom job waiter 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, Key(s) and Job Details
    """
    try:

        logger.info("Lambda event is [{}]".format(event))

        job_details = event["body"]["job"]["Payload"]["jobDetails"]

        logger.info("Checking Job Status with user custom code")
        # transform_handler = TransformHandler().stage_transform(team, dataset, stage)
        response = check_job_status(job_details)  # custom user code called

        if response["jobDetails"]["jobStatus"] == "SUCCEEDED":
            send_pipeline_execution_success(job_details["token"])
        elif response["jobDetails"]["jobStatus"] == "FAILED":
            sagemaker.send_pipeline_execution_step_failure(
                CallbackToken=job_details["token"], FailureReason="unknown reason"
            )

        logger.info("Response is [{}]".format(response))

    except Exception as e:
        logger.error("Fatal error", exc_info=True)
        sagemaker.send_pipeline_execution_step_failure(
            CallbackToken=job_details["token"], FailureReason=str(e)
        )

        raise e
    return response