Exemplo n.º 1
0
def connect_and_delete_old_lists():
    config = parse_config(CONFIG_FILENAME)
    db = create_db_connection(config.dbconfig)
    cur = db.cursor()
    delete_old_items(cur)
    cur.close()
    db.commit()
    db.close()
Exemplo n.º 2
0
    create_sql_for_predictions(config, sql_builder, DataType.PREFERENCE, update_progress)
    update_progress("STAGE: Executing preferences SQL files.")
    run_sql_pipeline(config, sql_builder.sql_pipeline)


def run_sql_pipeline(config, sql_pipeline):
    """
    Run all the sql commands in sql_pipeline against the database.
    :param config: pred.Config: global configuration containing what data to download/convert/load.
    :param sql_pipeline: loaddatabase.SQLPipeline: list of sql commands to be run
    """
    runner = SqlRunner(config, update_progress)
    sql_pipeline.run(runner.execute)
    runner.close()


if __name__ == '__main__':
    funcs = {
        'all': run_all_command,
        'download': download_files_command,
        'download_models': download_models_command,
        'run_sql': run_sql_command,
        'run_sql_models' : run_sql_models_command,
        'run_sql_predictions': run_sql_predictions,
        'run_sql_preferences': run_sql_preferences,
    }
    parser = argparse.ArgumentParser(description='Loads prediction database based on imadsconf.yaml')
    parser.add_argument('command', choices=funcs.keys())
    args = parser.parse_args()
    funcs[args.command](parse_config(CONFIG_FILENAME))
Exemplo n.º 3
0
    update_progress("STAGE: Executing preferences SQL files.")
    run_sql_pipeline(config, sql_builder.sql_pipeline)


def run_sql_pipeline(config, sql_pipeline):
    """
    Run all the sql commands in sql_pipeline against the database.
    :param config: pred.Config: global configuration containing what data to download/convert/load.
    :param sql_pipeline: loaddatabase.SQLPipeline: list of sql commands to be run
    """
    runner = SqlRunner(config, update_progress)
    sql_pipeline.run(runner.execute)
    runner.close()


if __name__ == '__main__':
    funcs = {
        'all': run_all_command,
        'download': download_files_command,
        'download_models': download_models_command,
        'run_sql': run_sql_command,
        'run_sql_models': run_sql_models_command,
        'run_sql_predictions': run_sql_predictions,
        'run_sql_preferences': run_sql_preferences,
    }
    parser = argparse.ArgumentParser(
        description='Loads prediction database based on imadsconf.yaml')
    parser.add_argument('command', choices=funcs.keys())
    args = parser.parse_args()
    funcs[args.command](parse_config(CONFIG_FILENAME))
Exemplo n.º 4
0
import psycopg2.extras
from flask import Flask, request, render_template, jsonify, g, make_response, Response

from pred.config import parse_config, CONFIG_FILENAME
from pred.webserver.dbdatasource import DataSources
from pred.webserver.predictionsearch import get_predictions_with_guess, get_all_values
from pred.webserver.customlist import save_custom_file
from pred.webserver.dnasequence import lookup_dna_sequence
from pred.webserver.sequencelist import SequenceList
from pred.webserver.customjob import CustomJob, JobStatus
from pred.webserver.customresult import CustomResultData
from pred.webserver.errors import ClientException, ServerException, ErrorType

logging.basicConfig(stream=sys.stderr)
app = Flask(__name__)
g_config = parse_config(CONFIG_FILENAME)
g_dbconfig = g_config.dbconfig


def log_info(message):
    print(message)


def get_db():
    db = getattr(g, '_database', None)
    if db is None:
        log_info("Creating database connection.")
        db = g._database = create_db_connection(g_dbconfig)
    return db

Exemplo n.º 5
0
import psycopg2
import psycopg2.extras
from flask import Flask, request, render_template, jsonify, g, make_response, Response

from pred.config import parse_config, CONFIG_FILENAME
from pred.webserver.dbdatasource import DataSources
from pred.webserver.predictionsearch import get_predictions_with_guess, get_all_values
from pred.webserver.customlist import save_custom_file
from pred.webserver.dnasequence import lookup_dna_sequence
from pred.webserver.sequencelist import SequenceList
from pred.webserver.customjob import CustomJob, JobStatus
from pred.webserver.customresult import CustomResultData
from pred.webserver.errors import ClientException, ServerException, ErrorType

app = Flask(__name__)
g_config = parse_config(CONFIG_FILENAME)
g_dbconfig = g_config.dbconfig


def log_info(message):
    print(message)


def get_db():
    db = getattr(g, '_database', None)
    if db is None:
        log_info("Creating database connection.")
        db = g._database = create_db_connection(g_dbconfig)
    return db