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 @@
"""
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

Check warning on line 566 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L565-L566

Added lines #L565 - L566 were not covered by tests

# 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 "

Check warning on line 571 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L570-L571

Added lines #L570 - L571 were not covered by tests
"%d (this ProxyService considers contest %d "
"only).", task_id, task.contest_id,
self.contest_id)
return

Check warning on line 575 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L575

Added line #L575 was not covered by tests

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

Check warning on line 577 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L577

Added line #L577 was not covered by tests
task.id, dataset.id)

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

Check warning on line 581 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L581

Added line #L581 was not covered by tests

for submission in task.submissions:

Check warning on line 583 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L583

Added line #L583 was not covered by tests
# Update RWS.
if not submission.participation.hidden and \

Check warning on line 585 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L585

Added line #L585 was not covered by tests
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)

Check warning on line 590 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L589-L590

Added lines #L589 - L590 were not covered by tests
else:
logger.warning("Dataset update for unexistent task %d.", task_id)

Check warning on line 592 in cms/service/ProxyService.py

View check run for this annotation

Codecov / codecov/patch

cms/service/ProxyService.py#L592

Added line #L592 was not covered by tests
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