Beispiel #1
0
def getExperimentsNames(project, dataset, exp_kind):
    db.commit()
    mysql_tools.useDatabase(cursor, project, dataset)
    experiments = experiment_db_tools.getExperiments(cursor, exp_kind)
    experience_dict = {}
    for e in experiments:
        experience_dict[e] = experiment_db_tools.getExperimentId(cursor, e)
    return jsonify(experience_dict)
Beispiel #2
0
def addLabel(project, dataset, experiment_label_id, iteration_number,
             instance_id, label, family, method, annotation):
    annotation = annotation == 'true'
    mysql_tools.useDatabase(cursor, project, dataset)
    labels_tools.addLabel(cursor, experiment_label_id, instance_id, label,
                          family, iteration_number, method, annotation)
    db.commit()
    return ''
Beispiel #3
0
def removeClusterLabel(project, dataset, experiment_id, selected_cluster, num_results):
    selected_cluster = int(selected_cluster)
    num_results = int(num_results)
    experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id,
            db, cursor)
    clustering = Clustering.fromJson(experiment)
    clustering.removeClusterLabel(selected_cluster, num_results)
    db.commit()
    return ''
Beispiel #4
0
def getLabelsFamilies(project, dataset, experiment_label_id, iteration_max):
    if iteration_max == 'None':
        iteration_max = None
    else:
        iteration_max = int(iteration_max)
    mysql_tools.useDatabase(cursor, project, dataset)
    db.commit()
    labels_families = labels_tools.getLabelsFamilies(
        cursor, experiment_label_id, iteration_max=iteration_max)
    return jsonify(labels_families)
Beispiel #5
0
def addClusterLabel(project, dataset, experiment_id, selected_cluster, num_results, label, family,
        label_iteration, label_method):
    selected_cluster = int(selected_cluster)
    num_results = int(num_results)
    experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id,
            db, cursor)
    clustering = Clustering.fromJson(experiment)
    clustering.addClusterLabel(selected_cluster, num_results,
            label, family, label_iteration, label_method)
    db.commit()
    return ''
Beispiel #6
0
def getFamiliesInstances(project, dataset, experiment_label_id, label,
                         iteration_max):
    if iteration_max == 'None':
        iteration_max = None
    else:
        iteration_max = int(iteration_max)
    mysql_tools.useDatabase(cursor, project, dataset)
    db.commit()
    families = labels_tools.getLabelsFamilies(
        cursor, experiment_label_id, iteration_max=iteration_max)[label]
    families_instances = {}
    for f in families:
        families_instances[f] = labels_tools.getLabelFamilyIds(
            cursor,
            experiment_label_id,
            label,
            family=f,
            iteration_max=iteration_max)
    return jsonify(families_instances)
Beispiel #7
0
def removeLabel(project, dataset, experiment_id, inst_dataset,
                inst_experiment_label_id, iteration_number, instance_id):
    mysql_tools.useDatabase(cursor, project, inst_dataset)
    labels_tools.removeLabel(cursor, inst_experiment_label_id, instance_id)
    db.commit()
    if user_exp:
        experiment = ExperimentFactory.getFactory().fromJson(
            project, dataset, experiment_id, db, cursor)
        filename = dir_tools.getExperimentOutputDirectory(experiment)
        filename += 'user_actions.log'
        file_exists = dir_tools.checkFileExists(filename)
        mode = 'a' if file_exists else 'w'
        to_print = [
            datetime.datetime.now(), 'removeLabel', project, dataset,
            instance_id
        ]
        to_print = map(str, to_print)
        to_print = ','.join(to_print)
        with open(filename, mode) as f:
            print >> f, to_print
    return ''
Beispiel #8
0
def currentAnnotationIteration(project, dataset, experiment_id):
    db.commit()
    experiment = ExperimentFactory.getFactory().fromJson(
        project, dataset, experiment_id, db, cursor)
    return str(experiment.getCurrentIteration())
Beispiel #9
0
def getChildren(project, dataset, experiment_id):
    db.commit()
    mysql_tools.useDatabase(cursor, project, dataset)
    return ' '.join(
        map(str, experiment_db_tools.getChildren(cursor, experiment_id)))
Beispiel #10
0
def getExperimentLabelId(project, dataset, experiment_id):
    db.commit()
    experiment = ExperimentFactory.getFactory().fromJson(
        project, dataset, experiment_id, db, cursor)
    experiment_label_id = str(experiment.experiment_label_id)
    return experiment_label_id
Beispiel #11
0
def getExperimentId(project, dataset, experiment_name):
    db.commit()
    mysql_tools.useDatabase(cursor, project, dataset)
    return str(experiment_db_tools.getExperimentId(cursor, experiment_name))
Beispiel #12
0
def getExperimentName(project, dataset, experiment_id):
    db.commit()
    mysql_tools.useDatabase(cursor, project, dataset)
    return experiment_db_tools.getExperimentName(cursor, experiment_id)
Beispiel #13
0
def removeLabel(project, dataset, experiment, instance_id):
    mysql_tools.useDatabase(cursor, project, dataset)
    labels_tools.removeLabel(cursor, experiment, instance_id)
    db.commit()
    return ''