def AutoApproveJob(job):
    cluster_status = get_cluster_status()
    jobUser = getAlias(job["userName"])
    jobParams = json.loads(base64.b64decode(job["jobParams"]))
    jobGPU = int(jobParams["resourcegpu"])

    currentGPU = 0
    for user in cluster_status["user_status"]:
        if user["userName"] == jobUser:
            currentGPU = int(user["userGPU"])

    if currentGPU == 0 or currentGPU + jobGPU <= 4:
        ApproveJob(job)
def AutoApproveJob(job):

    cluster_status = get_cluster_status()
    jobUser = getAlias(job["userName"])
    jobParams = json.loads(base64.b64decode(job["jobParams"]))
    jobGPU = int(jobParams["resourcegpu"])

    logging.info("start to autoApprove job...")
    currentGPU = 0
    logging.info("currentGPU: " + str(currentGPU) + " jobGPU: " + str(jobGPU))

    for user in cluster_status["user_status"]:
        if user["userName"] == jobUser:
            currentGPU = int(user["userGPU"])

    # Default Auto approval changed to 2GPU
    # if currentGPU == 0 or currentGPU + jobGPU <= 2:
    if currentGPU + jobGPU <= 1:
        ApproveJob(job)