Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProxyService bugfix #1244

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions cms/service/ProxyService.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,28 +562,31 @@ def dataset_updated(self, task_id):
"""
with SessionGen() as session:
task = Task.get_from_id(task_id, session)
dataset = task.active_dataset

# This ProxyService may focus on a different contest, and it should
# ignore this update.
if task.contest_id != self.contest_id:
logger.debug("Ignoring dataset change for task %d of contest "
"%d (this ProxyService considers contest %d "
"only).", task_id, task.contest.id,
self.contest_id)
return

logger.info("Dataset update for task %d (dataset now is %d).",
task.id, dataset.id)

# max_score and/or extra_headers might have changed.
self.reinitialize()

for submission in task.submissions:
# Update RWS.
if not submission.participation.hidden and \
submission.official and \
submission.get_result() is not None and \
submission.get_result().scored():
for operation in self.operations_for_score(submission):
self.enqueue(operation)
if task is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more readable to invert the check here (if task is None), returning early in that case. It would avoid having to indent the rest of the code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right it would make it more readable. I think I fixed it and pushed, I am not sure it's the first time I open a pull request, sorry for any github-wise misbehaviour :D

dataset = task.active_dataset

# This ProxyService may focus on a different contest, and it should
# ignore this update.
if task.contest_id != self.contest_id:
logger.debug("Ignoring dataset change for task %d of contest "
"%d (this ProxyService considers contest %d "
"only).", task_id, task.contest_id,
self.contest_id)
return

logger.info("Dataset update for task %d (dataset now is %d).",
task.id, dataset.id)

# max_score and/or extra_headers might have changed.
self.reinitialize()

for submission in task.submissions:
# Update RWS.
if not submission.participation.hidden and \
submission.official and \
submission.get_result() is not None and \
submission.get_result().scored():
for operation in self.operations_for_score(submission):
self.enqueue(operation)
else:
logger.warning("Dataset update for unexistent task %d.", task_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unexistent -> non-existent

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just corrected each occurrence of it in the file