How to use the ramp-database.rampdb.tools.query.select_submission_by_id function in ramp-database

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 / rampdb / tools / api.py View on Github external
Parameters
    ----------
    config : dict
        Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.
    path_predictions : str
        The path where the results files are located.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        for fold_id, cv_fold in enumerate(submission.on_cv_folds):
            path_results = os.path.join(path_predictions,
                                        'fold_{}'.format(fold_id))
            results = {}
            for step in ('train', 'valid', 'test'):
                results[step + '_time'] = np.asscalar(
                    np.loadtxt(os.path.join(path_results, step + '_time'))
                )
            for key, value in results.items():
                setattr(cv_fold, key, value)
        session.commit()
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
Parameters
    ----------
    config : dict
        Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.
    path_predictions : str
        The path where the results files are located.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        for fold_id, cv_fold in enumerate(submission.on_cv_folds):
            path_results = os.path.join(path_predictions,
                                        'fold_{}'.format(fold_id))
            cv_fold.full_train_y_pred = np.load(
                os.path.join(path_results, 'y_pred_train.npz'))['y_pred']
            cv_fold.test_y_pred = np.load(
                os.path.join(path_results, 'y_pred_test.npz'))['y_pred']
        session.commit()
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
----------
    config : dict
        Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.
    error_msg : str
        The error message.
    """

    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        submission.error_msg = error_msg
        session.commit()
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
* 'training_error': training finished abnormally;
        * 'validated': validation finished normally;
        * 'validating_error': validation finished abnormally;
        * 'tested': testing finished normally;
        * 'testing_error': testing finished abnormally;
        * 'training': training is running normally;
        * 'scored': submission scored.
    """
    if state not in STATES:
        raise UnknownStateError("Unrecognized state : '{}'".format(state))

    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        submission.set_state(state)

        session.commit()
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
Parameters
    ----------
    config : dict
        Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.
    path_predictions : str
        The path where the results files are located.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        for fold_id, cv_fold in enumerate(submission.on_cv_folds):
            path_results = os.path.join(path_predictions,
                                        'fold_{}'.format(fold_id))
            scores_update = pd.read_csv(
                os.path.join(path_results, 'scores.csv'), index_col=0
            )
            for score in cv_fold.scores:
                for step in scores_update.index:
                    value = scores_update.loc[step, score.name]
                    setattr(score, step + '_score', value)
        session.commit()
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
Parameters
    ----------
    config : dict
        Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.
    max_ram_mb : float
        The max amount of RAM in MB.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        submission.max_ram = max_ram_mb
        session.commit()
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.

    Returns
    -------
    max_ram_mb : float
        The max amount of RAM in MB.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        return submission.max_ram
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.

    Returns
    -------
    scores : pd.DataFrame
        A pandas dataframe containing the scores of each fold.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        results = defaultdict(list)
        index = []
        for fold_id, cv_fold in enumerate(submission.on_cv_folds):
            for step in ('train', 'valid', 'test'):
                index.append((fold_id, step))
                for score in cv_fold.scores:
                    results[score.name].append(getattr(score, step + '_score'))
        multi_index = pd.MultiIndex.from_tuples(index, names=['fold', 'step'])
        scores = pd.DataFrame(results, index=multi_index)
        return scores
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.

    Returns
    -------
    error_msg : str
        The error message.
    """

    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        return submission.error_msg
github paris-saclay-cds / ramp-board / ramp-database / rampdb / tools / api.py View on Github external
Configuration file containing the information to connect to the
        dataset. If you are using the configuration provided by ramp, it
        corresponds to the the `sqlalchemy` key.
    submission_id : int
        The id of the submission.

    Returns
    -------
    computation_time : pd.DataFrame
        A pandas dataframe containing the computation time of each fold.
    """
    db, Session = _setup_db(config)
    with db.connect() as conn:
        session = Session(bind=conn)

        submission = select_submission_by_id(session, submission_id)
        results = defaultdict(list)
        for fold_id, cv_fold in enumerate(submission.on_cv_folds):
            results['fold'].append(fold_id)
            for step in ('train', 'valid', 'test'):
                results[step].append(getattr(cv_fold, '{}_time'.format(step)))
        return pd.DataFrame(results).set_index('fold')