How to use the ramp-database.ramp_database.model.Submission 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 / submission.py View on Github external
submission_name : str
        The name to give to the current submission.
    submission_path : str
        The path of the files associated to the current submission. It will
        corresponds to the key `ramp_kit_subissions_dir` of the dictionary
        created with :func:`ramp_utils.generate_ramp_config`.

    Returns
    -------
    submission : :class:`ramp_database.model.Submission`
        The newly created submission.
    """
    event = select_event_by_name(session, event_name)
    team = select_team_by_name(session, team_name)
    event_team = select_event_team_by_name(session, event_name, team_name)
    submission = (session.query(Submission)
                         .filter(Submission.name == submission_name)
                         .filter(Submission.event_team == event_team)
                         .one_or_none())

    # create a new submission
    if submission is None:
        all_submissions = (session.query(Submission)
                                  .filter(Submission.event_team == event_team)
                                  .order_by(Submission.submission_timestamp)
                                  .all())
        last_submission = None if not all_submissions else all_submissions[-1]
        # check for non-admin user if they wait enough to make a new submission
        if (team.admin.access_level != 'admin' and last_submission is not None
                and last_submission.is_not_sandbox):
            time_to_last_submission = (datetime.datetime.utcnow() -
                                       last_submission.submission_timestamp)
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / submission.py View on Github external
last_submission = None if not all_submissions else all_submissions[-1]
        # check for non-admin user if they wait enough to make a new submission
        if (team.admin.access_level != 'admin' and last_submission is not None
                and last_submission.is_not_sandbox):
            time_to_last_submission = (datetime.datetime.utcnow() -
                                       last_submission.submission_timestamp)
            min_resubmit_time = datetime.timedelta(
                seconds=event.min_duration_between_submissions)
            awaiting_time = int((min_resubmit_time - time_to_last_submission)
                                .total_seconds())
            if awaiting_time > 0:
                raise TooEarlySubmissionError(
                    'You need to wait {} more seconds until next submission'
                    .format(awaiting_time))

        submission = Submission(
            name=submission_name, event_team=event_team, session=session
        )
        for cv_fold in event.cv_folds:
            submission_on_cv_fold = SubmissionOnCVFold(submission=submission,
                                                       cv_fold=cv_fold)
            session.add(submission_on_cv_fold)
        session.add(submission)

    # the submission already exist
    else:
        # We allow resubmit for new or failing submissions
        if (submission.is_not_sandbox and
                (submission.state == 'new' or submission.is_error)):
            submission.set_state('new', session)
            submission.submission_timestamp = datetime.datetime.utcnow()
            all_cv_folds = (session.query(SubmissionOnCVFold)
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / _query.py View on Github external
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 / submission.py View on Github external
The name to give to the current submission.
    submission_path : str
        The path of the files associated to the current submission. It will
        corresponds to the key `ramp_kit_subissions_dir` of the dictionary
        created with :func:`ramp_utils.generate_ramp_config`.

    Returns
    -------
    submission : :class:`ramp_database.model.Submission`
        The newly created submission.
    """
    event = select_event_by_name(session, event_name)
    team = select_team_by_name(session, team_name)
    event_team = select_event_team_by_name(session, event_name, team_name)
    submission = (session.query(Submission)
                         .filter(Submission.name == submission_name)
                         .filter(Submission.event_team == event_team)
                         .one_or_none())

    # create a new submission
    if submission is None:
        all_submissions = (session.query(Submission)
                                  .filter(Submission.event_team == event_team)
                                  .order_by(Submission.submission_timestamp)
                                  .all())
        last_submission = None if not all_submissions else all_submissions[-1]
        # check for non-admin user if they wait enough to make a new submission
        if (team.admin.access_level != 'admin' and last_submission is not None
                and last_submission.is_not_sandbox):
            time_to_last_submission = (datetime.datetime.utcnow() -
                                       last_submission.submission_timestamp)
            min_resubmit_time = datetime.timedelta(
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()