示例#1
0
def run():

    # parse arguments
    args = parse_arguments()
    workflow_dir = args.workflow_dir
    task_dir = args.task_dir

    # get branch meta data
    branch_meta_file = os.path.join(workflow_dir, 'branch_meta.json')
    with open(branch_meta_file, 'r') as f_in:
        branch_meta = json.load(f_in)

    # get predictor, training/test
    # datasets data
    task_meta = get_task_meta_data(task_dir)

    # get evaluation data
    evaluation_results_file = os.path.join(task_dir, 'evaluation_results.json')
    with open(evaluation_results_file, 'r') as f_in:
        evaluation_results = json.load(f_in)

    # compile and add timestamp, date
    timestamp = time.time()
    record = {
        "timestamp": time.time(),
        "date": datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")
    }

    record.update(branch_meta)
    record.update(task_meta)
    record.update({"evaluation_results": evaluation_results})

    # save record to json for backup
    with open('record_to_push.json', 'w') as f_out:
        json.dump(record, f_out, indent=4, sort_keys=True)

    # connect to db and table
    performance_db = connector.connect_to_db('PredictorPerformanceDatabase')
    task_name = task_meta['predictor_input']['prediction_task'].split('(')[0]
    performance_table = getattr(performance_db,
                                'cnn_{0}_table'.format(task_name))

    # insert the record
    performance_table.insert_one(record)
示例#2
0
from connector import connect_to_db


con = connect_to_db()
cur = con.cursor()
insert_in_test1 = "UPDATE TEST1 set NAME = 'Vasya' where ADMISSION = 1"
cur.execute(insert_in_test1)
con.commit()
con.close()