How to use the ramp-database.ramp_database.model.Event 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 / ramp_database / tools / event.py View on Github external
Whether to overwrite an existing event. If ``false=False``, an error
        will be raised.

    Returns
    -------
    event : Event
        The event which has been registered in the database.
    """
    event = select_event_by_name(session, event_name)
    if event is not None:
        if not force:
            raise ValueError("Attempting to overwrite existing event. "
                             "Use force=True to overwrite.")
        delete_event(session, event_name)

    event = Event(name=event_name, problem_name=problem_name,
                  event_title=event_title,
                  ramp_sandbox_name=ramp_sandbox_name,
                  path_ramp_submissions=ramp_submissions_path,
                  session=session)
    event.is_public = is_public
    event.is_send_submitted_mails = False
    event.is_send_trained_mails = False
    logger.info('Adding {}'.format(event))
    session.add(event)
    session.commit()

    X_train, y_train = event.problem.get_train_data()
    cv = event.problem.module.get_cv(X_train, y_train)
    for train_indices, test_indices in cv:
        cv_fold = CVFold(event=event,
                         train_is=train_indices,
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / _query.py View on Github external
Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to query the database.
    event_name : str
        The name of the RAMP event.
    state : str
        The state of the submissions to query.

    Returns
    -------
    submissions : list of :class:`ramp_database.model.Submission`
        The queried list of submissions.
    """
    q = (session.query(Submission)
                .filter(Event.name == event_name)
                .filter(Event.id == EventTeam.event_id)
                .filter(EventTeam.id == Submission.event_team_id)
                .order_by(Submission.submission_timestamp))
    if state is None:
        return q.all()
    return q.filter(Submission.state == state).all()
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / _query.py View on Github external
Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to query the database.
    event_name : str
        The name of the RAMP event.

    Returns
    -------
    event : :class:`ramp_database.model.Event`
        The queried event.
    """
    if event_name is None:
        return session.query(Event).all()
    return session.query(Event).filter(Event.name == event_name).one_or_none()