FIX handle slight inconsistencies in github graphql api
from datetime import datetime, timedelta
+import sqlalchemy.exc
from sqlalchemy.sql import or_
from anubis.github.api import github_graphql
@@ -126,6 +127,7 @@ def fix_github_missing_submissions(org_name: str):
submission = Submission.query.filter(Submission.commit == commit).first()
if submission is None:
print(f"Found missing submission {user.netid=} {assignment=} {commit=}")
+ try:
submission = Submission(
commit=commit,
owner=user,
@@ -138,6 +140,9 @@ def fix_github_missing_submissions(org_name: str):
init_submission(submission)
if submission.assignment.autograde_enabled:
enqueue_autograde_pipeline(submission.id)
+ except sqlalchemy.exc.IntegrityError:
+ db.session.rollback()
+ logger.warning(f'Failed to create submission that already exists {user.netid=} {assignment=} {commit=}')
except TypeError as e:
logger.warning(f'Failed to parse commit objects for repo - {e} - {str(repo)}')
