How to use ramp-database - 10 common examples

To help you get started, we’ve selected a few ramp-database examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
# we can automatically setup the database from the config file used for the
    # tests.
    ramp_config = generate_ramp_config(read_config(ramp_config))

    # FIXME: we are recreating the deployment directory but it should be
    # replaced by an temporary creation of folder.
    deployment_dir = os.path.commonpath(
        [ramp_config['ramp_kit_dir'], ramp_config['ramp_data_dir']]
    )

    shutil.rmtree(deployment_dir, ignore_errors=True)
    os.makedirs(ramp_config['ramp_submissions_dir'])
    db, _ = setup_db(database_config)
    Model.metadata.drop_all(db)
    Model.metadata.create_all(db)
    with session_scope(database_config) as session:
        setup_files_extension_type(session)
    return deployment_dir
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
"""Create a toy dataset with couple of users, problems, events.

    Parameters
    ----------
    database_config : dict
        The configuration file containing the database information.
    ramp_config : str
        The configuration file containing the information about a RAMP event.

    Returns
    -------
    deployment_dir : str
        The deployment directory for the RAMP components (kits, data, etc.).
    """
    deployment_dir = create_test_db(database_config, ramp_config)
    with session_scope(database_config['sqlalchemy']) as session:
        setup_toy_db(session)
    return deployment_dir
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
def sign_up_teams_to_events(session):
    """Sign up user to the events in the database.

    Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.

    Notes
    -----
    Be aware that :func:`add_users`, :func:`add_problems`,
    and :func:`add_events` need to be called before.
    """
    for event_name in ['iris_test', 'boston_housing_test']:
        sign_up_team(session, event_name, 'test_user')
        sign_up_team(session, event_name, 'test_user_2')
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
def sign_up_teams_to_events(session):
    """Sign up user to the events in the database.

    Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.

    Notes
    -----
    Be aware that :func:`add_users`, :func:`add_problems`,
    and :func:`add_events` need to be called before.
    """
    for event_name in ['iris_test', 'boston_housing_test']:
        sign_up_team(session, event_name, 'test_user')
        sign_up_team(session, event_name, 'test_user_2')
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.
    """
    add_user(
        session, name='test_user', password='test',
        lastname='Test', firstname='User',
        email='test.user@gmail.com', access_level='asked')
    approve_user(session, 'test_user')
    add_user(
        session, name='test_user_2', password='test',
        lastname='Test_2', firstname='User_2',
        email='test.user.2@gmail.com', access_level='user')
    approve_user(session, 'test_user_2')
    add_user(
        session, name='test_iris_admin', password='test',
        lastname='Admin', firstname='Iris',
        email='iris.admin@gmail.com', access_level='admin')
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
def add_users(session):
    """Add dummy users in the database.

    Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.
    """
    add_user(
        session, name='test_user', password='test',
        lastname='Test', firstname='User',
        email='test.user@gmail.com', access_level='asked')
    approve_user(session, 'test_user')
    add_user(
        session, name='test_user_2', password='test',
        lastname='Test_2', firstname='User_2',
        email='test.user.2@gmail.com', access_level='user')
    approve_user(session, 'test_user_2')
    add_user(
        session, name='test_iris_admin', password='test',
        lastname='Admin', firstname='Iris',
        email='iris.admin@gmail.com', access_level='admin')
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.
    """
    ramp_configs = {
        'iris': read_config(ramp_config_iris()),
        'boston_housing': read_config(ramp_config_boston_housing())
    }
    for problem_name, ramp_config in ramp_configs.items():
        internal_ramp_config = generate_ramp_config(ramp_config)
        setup_ramp_kit_ramp_data(internal_ramp_config, problem_name, depth=1)
        add_problem(session, problem_name,
                    internal_ramp_config['ramp_kit_dir'],
                    internal_ramp_config['ramp_data_dir'])
        add_keyword(session, problem_name, 'data_domain',
                    category='scientific data')
        add_problem_keyword(session, problem_name=problem_name,
                            keyword_name=problem_name)
        add_keyword(session, problem_name + '_theme', 'data_science_theme',
                    category='classification')
        add_problem_keyword(session, problem_name=problem_name,
                            keyword_name=problem_name + '_theme')
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
"""
    ramp_configs = {
        'iris': read_config(ramp_config_iris()),
        'boston_housing': read_config(ramp_config_boston_housing())
    }
    for problem_name, ramp_config in ramp_configs.items():
        internal_ramp_config = generate_ramp_config(ramp_config)
        setup_ramp_kit_ramp_data(internal_ramp_config, problem_name, depth=1)
        add_problem(session, problem_name,
                    internal_ramp_config['ramp_kit_dir'],
                    internal_ramp_config['ramp_data_dir'])
        add_keyword(session, problem_name, 'data_domain',
                    category='scientific data')
        add_problem_keyword(session, problem_name=problem_name,
                            keyword_name=problem_name)
        add_keyword(session, problem_name + '_theme', 'data_science_theme',
                    category='classification')
        add_problem_keyword(session, problem_name=problem_name,
                            keyword_name=problem_name + '_theme')
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
The session to directly perform the operation on the database.
    """
    ramp_configs = {
        'iris': read_config(ramp_config_iris()),
        'boston_housing': read_config(ramp_config_boston_housing())
    }
    for problem_name, ramp_config in ramp_configs.items():
        ramp_config_problem = generate_ramp_config(ramp_config)
        path_submissions = os.path.join(
            ramp_config_problem['ramp_kit_dir'], 'submissions'
        )
        submit_starting_kits(
            session, ramp_config_problem['event_name'], 'test_user',
            path_submissions
        )
        submit_starting_kits(
            session, ramp_config_problem['event_name'], 'test_user_2',
            path_submissions
        )
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / testing.py View on Github external
Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.
    """
    ramp_configs = {
        'iris': read_config(ramp_config_iris()),
        'boston_housing': read_config(ramp_config_boston_housing())
    }
    for problem_name, ramp_config in ramp_configs.items():
        ramp_config_problem = generate_ramp_config(ramp_config)
        path_submissions = os.path.join(
            ramp_config_problem['ramp_kit_dir'], 'submissions'
        )
        submit_starting_kits(
            session, ramp_config_problem['event_name'], 'test_user',
            path_submissions
        )
        submit_starting_kits(
            session, ramp_config_problem['event_name'], 'test_user_2',
            path_submissions
        )