Skip to content

Commit 03ecbf4

Browse files
Avoid errors for missing submission results when dealing with datasets
Creating a dataset without copying the results do not create empty ones, but leave the submission without a result for the new dataset. The code dealing with results needs to be made aware that this might happen. In particular, this was not true for ProxyService (when making the new dataset live) and for ES (when enabling background judging).
1 parent 9dcc837 commit 03ecbf4

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

cms/service/EvaluationService.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Contest Management System - http://cms-dev.github.io/
55
# Copyright © 2010-2014 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
6-
# Copyright © 2010-2014 Stefano Maggiolo <s.maggiolo@gmail.com>
6+
# Copyright © 2010-2015 Stefano Maggiolo <s.maggiolo@gmail.com>
77
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
88
# Copyright © 2013 Luca Wehrstedt <luca.wehrstedt@gmail.com>
99
# Copyright © 2013 Bernard Blackham <bernard@largestprime.net>
@@ -1196,10 +1196,22 @@ def action_finished(self, data, plus, error=None):
11961196
submission_result = SubmissionResult.get_from_id(
11971197
(object_id, dataset_id), session)
11981198
if submission_result is None:
1199-
logger.error("[action_finished] Couldn't find "
1200-
"submission %d(%d) in the database.",
1201-
object_id, dataset_id)
1202-
return
1199+
logger.info("[action_finished] Couldn't find "
1200+
"submission %d(%d) in the database. "
1201+
"Creating it.", object_id, dataset_id)
1202+
submission = Submission.get_from_id(object_id, session)
1203+
dataset = Dataset.get_from_id(dataset_id, session)
1204+
if submission is None:
1205+
logger.error("[action_finished] Could not find "
1206+
"submission %d in the database.",
1207+
object_id)
1208+
return
1209+
if dataset is None:
1210+
logger.error("[action_finished] Could not find "
1211+
"dataset %d in the database.", dataset_id)
1212+
return
1213+
submission_result = submission.get_result_or_create(
1214+
dataset)
12031215

12041216
submission_result.compilation_tries += 1
12051217

cms/service/ProxyService.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Contest Management System - http://cms-dev.github.io/
55
# Copyright © 2010-2013 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
6-
# Copyright © 2010-2014 Stefano Maggiolo <s.maggiolo@gmail.com>
6+
# Copyright © 2010-2015 Stefano Maggiolo <s.maggiolo@gmail.com>
77
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
88
# Copyright © 2013 Luca Wehrstedt <luca.wehrstedt@gmail.com>
99
# Copyright © 2013 Bernard Blackham <bernard@largestprime.net>
@@ -278,7 +278,13 @@ def _missing_operations(self):
278278
if submission.user.hidden:
279279
continue
280280

281-
if submission.get_result().scored() and \
281+
# The submission result can be None if the dataset has
282+
# been just made live.
283+
sr = submission.get_result()
284+
if sr is None:
285+
continue
286+
287+
if sr.scored() and \
282288
submission.id not in self.scores_sent_to_rankings:
283289
for operation in self.operations_for_score(submission):
284290
self.enqueue(operation)
@@ -509,6 +515,7 @@ def dataset_updated(self, task_id):
509515
for submission in task.submissions:
510516
# Update RWS.
511517
if not submission.user.hidden and \
518+
submission.get_result() is not None and \
512519
submission.get_result().scored():
513520
for operation in self.operations_for_score(submission):
514521
self.enqueue(operation)

0 commit comments

Comments
 (0)