From fddc2e45bb7c4a1933e75523db4529baa9c587ca Mon Sep 17 00:00:00 2001 From: tommoral Date: Mon, 4 Mar 2024 12:22:50 +0100 Subject: [PATCH] ENH make event approval more robust to concurrent approval --- ramp-database/ramp_database/tools/team.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ramp-database/ramp_database/tools/team.py b/ramp-database/ramp_database/tools/team.py index e8c402ae..ba484786 100644 --- a/ramp-database/ramp_database/tools/team.py +++ b/ramp-database/ramp_database/tools/team.py @@ -4,6 +4,7 @@ from ..model import EventTeam from .submission import add_submission +from .submission import DuplicateSubmissionError from ._query import select_event_by_name from ._query import select_event_team_by_name @@ -65,13 +66,19 @@ def sign_up_team(session, event_name, team_name): event.problem.path_ramp_kit, "submissions", event.ramp_sandbox_name ) submission_name = event.ramp_sandbox_name - submission = add_submission( - session, - event_name, - team_name, - submission_name, - path_sandbox_submission, - ) + try: + submission = add_submission( + session, + event_name, + team_name, + submission_name, + path_sandbox_submission, + ) + except DuplicateSubmissionError: + logger.info( + "Sanbox submission already exists. " + "This probably due to concurrent approval, skipping." + ) logger.info("Copying the submission files into the deployment folder") logger.info("Adding {}".format(submission)) event_team.approved = True