def update_job_status(job_id, status, conn=None):
    """Updates a job to a new status

    :param job_id: <str> the id of the job
    :param status: <str> new status
    :param conn: <connection> a database connection (default: {None})

    :return: <dict> the update dicts for the job and the output
    """
    if status not in VALID_STATES:
        raise ValueError("Invalid status")
    job_update = RBJ.get(job_id).update({STATUS_FIELD: status}).run(conn)
    if job_update["replaced"] == 0 and job_update["unchanged"] == 0:
        raise ValueError("Unknown job_id: {}".format(job_id))
    output_job_status = {OUTPUTJOB_FIELD: {STATUS_FIELD: status}}
    if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn):
        # NEW
        output_update = RBO.get_all(job_id, index=IDX_OUTPUT_JOB_ID).update(output_job_status).run(conn)
    else:
        # OLD
        id_filter = (r.row[OUTPUTJOB_FIELD][ID_FIELD] == job_id)
        output_update = RBO.filter(id_filter).update(output_job_status).run(conn)
    return {str(RBJ): job_update, str(RBO): output_update}
Updates a job to a new status

    :param job_id: <str> the id of the job
    :param status: <str> new status
    :param conn: <connection> a database connection (default: {None})

    :return: <dict> the update dicts for the job and the output