Beispiel #1
0
def get_superpixels_callback(result):
    # update the job status in the database:
    update_completed_job_status(result)

    retval, jobid = result
    engine = sqlalchemy.create_engine(get_database_uri())

    dbretval = engine.connect().execute(
        f"select procout from jobid_{jobid} where procout like 'RETVAL:%'"
    ).first()
    if dbretval is None:
        # no retval, indicating superpixel didn't get to the end, leave everything as is
        engine.dispose()
        return

    retvaldict = json.loads(dbretval[0].replace("RETVAL: ", ""))
    if "model" in retvaldict:  # for DL approach
        modelid = retvaldict["model"].split("/")[4]
    else:
        modelid = -1

    for img in retvaldict["output_file"]:
        engine.connect().execute(
            f"update image set superpixel_time = datetime(), superpixel_modelid = :modelid where path= :img",
            img=img,
            modelid=modelid)

    engine.dispose()
Beispiel #2
0
def make_embed_callback(result):
    # update the job status in the database:
    update_completed_job_status(result)

    jobid = result[1]
    engine = sqlalchemy.create_engine(get_database_uri())

    dbretval = engine.connect().execute(
        f"select procout from jobid_{jobid} where procout like 'RETVAL:%'"
    ).first()
    if dbretval is None:
        # no retval, indicating superpixel didn't get to the end, leave everything as is
        engine.dispose()
        return

    retvaldict = json.loads(dbretval[0].replace("RETVAL: ", ""))
    projname = retvaldict["project_name"]
    modelid = retvaldict["modelid"]

    engine.connect().execute(
        f"update project set embed_iteration = :modelid where name = :projname",
        projname=projname,
        modelid=modelid)

    engine.dispose()
Beispiel #3
0
def make_patches_callback(result):
    # update the job status in the database:
    update_completed_job_status(result)

    retval, jobid = result
    engine = sqlalchemy.create_engine(get_database_uri())
    dbretval = engine.connect().execute(
        f"select procout from jobid_{jobid} where procout like 'RETVAL:%'"
    ).first()
    if dbretval is None:
        # no retval, indicating make_patches didn't get to the end, leave everything as is
        engine.dispose()
        return

    retvaldict = json.loads(dbretval[0].replace("RETVAL: ", ""))
    for img in retvaldict["image_list"]:
        engine.connect().execute(
            f"update image set make_patches_time = datetime() where path= :img",
            img=img)

    # if it was successful, mark the training time in the database:

    if retval == 0:
        jobs_logger.info('Marking make_patches time in database:')
        projid = engine.connect().execute(
            f"select projId from job where id = :jobid",
            jobid=jobid).first()[0]
        engine.connect().execute(
            f"update project set make_patches_time = datetime() where id = :projid",
            projid=projid)

    engine.dispose()
Beispiel #4
0
def train_autoencoder_callback(result):
    # update the job status in the database:
    update_completed_job_status(result)

    # if it was successful, mark the training time in the database:
    retval, jobid = result
    if retval == 0:
        jobs_logger.info('Marking training ae time in database:')
        engine = sqlalchemy.create_engine(get_database_uri())
        projid = engine.connect().execute(
            f"select projId from job where id = :jobid",
            jobid=jobid).first()[0]
        engine.connect().execute(
            f"update project set train_ae_time = datetime(), iteration = CASE WHEN iteration<0 then 0 else iteration end where id = :projid",
            projid=projid)
        engine.dispose()