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

Implement disabling a judge #2005

Merged
merged 3 commits into from
Jan 3, 2023
Merged

Implement disabling a judge #2005

merged 3 commits into from
Jan 3, 2023

Conversation

WallE256
Copy link
Member

@WallE256 WallE256 commented Oct 6, 2022

This feature removes a disabled judge from the queue handling, such that normal or rejudged submissions will not be allocated to it for grading. However, it will still receive submissions intended for it specifically.

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2022

Codecov Report

Base: 46.69% // Head: 46.61% // Decreases project coverage by -0.07% ⚠️

Coverage data is based on head (39d0d98) compared to base (6c5dd7b).
Patch coverage: 32.35% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2005      +/-   ##
==========================================
- Coverage   46.69%   46.61%   -0.08%     
==========================================
  Files         238      239       +1     
  Lines       13236    13322      +86     
==========================================
+ Hits         6180     6210      +30     
- Misses       7056     7112      +56     
Impacted Files Coverage Δ
judge/bridge/django_handler.py 0.00% <0.00%> (ø)
judge/bridge/judge_handler.py 0.00% <0.00%> (ø)
judge/bridge/judge_list.py 0.00% <0.00%> (ø)
judge/admin/runtime.py 64.17% <40.00%> (-2.49%) ⬇️
judge/judgeapi.py 24.28% <50.00%> (+0.75%) ⬆️
judge/models/runtime.py 69.74% <57.14%> (-1.05%) ⬇️
judge/migrations/0135_disable_judge.py 100.00% <100.00%> (ø)
judge/utils/unicode.py 52.17% <0.00%> (-3.83%) ⬇️
judge/views/problem.py 25.57% <0.00%> (+1.42%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

judge/bridge/judge_list.py Outdated Show resolved Hide resolved
def toggle_disabled(self):
self.is_disabled = not self.is_disabled
self.save(update_fields=['is_disabled'])
disconnect_judge(self, force=True)
Copy link
Member

Choose a reason for hiding this comment

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

Should this send a forced disconnect if you're re-enabling the judge?

In particular, it looks like this function is used less like toggle disable, and more like disable.

Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose of forcing a disconnect is to update the is_disabled cached property in the bridge, which helps to not access the Judge DB object for every submission and queue removal.

Copy link
Member

Choose a reason for hiding this comment

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

I think there should be a bridge RPC added rather than hacking around it this way. The judge we run on dmoj.ca will auto-reconnect, but it's not guaranteed that all judges will.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a bridge RPC instead of the disconnect method.

Copy link
Member

@kiritofeng kiritofeng left a comment

Choose a reason for hiding this comment

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

Tentative LGTM, would like @quantum5 or @Xyene to look over it before merging though.

Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

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

LGTM, but it looks like there are merge conflicts.

judge/bridge/judge_list.py Outdated Show resolved Hide resolved
<a style="display: none" title="{% trans "Disable" %}" href="{% url 'admin:judge_judge_disable' original.pk %}"
class="button disable-link">
<i class="fa fa-lg fa-ban"></i>
<span class="text">{% trans "Disable" %}</span>
Copy link
Member

Choose a reason for hiding this comment

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

Don't know how I feel about this being a toggle but always showing Disable.

Copy link
Member Author

Choose a reason for hiding this comment

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

This has been addressed.

@WallE256 WallE256 force-pushed the disable-judge branch 2 times, most recently from 02e5ff9 to 39d0d98 Compare January 3, 2023 00:35
@@ -18,6 +18,7 @@ def __init__(self, request, client_address, server, judges):
'submission-request': self.on_submission,
'terminate-submission': self.on_termination,
'disconnect-judge': self.on_disconnect_request,
'disable-judge': self.update_disable_judge,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'disable-judge': self.update_disable_judge,
'disable-judge': self.on_disable_judge,

for consistency

@@ -147,6 +149,13 @@ def disconnect(self, force=False):

disconnect.alters_data = True

def toggle_disabled(self):
self.is_disabled = not self.is_disabled
self.save(update_fields=['is_disabled'])
Copy link
Member

Choose a reason for hiding this comment

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

I think this save should come after the RPC, so we don't end up (in case of an error) with a bridge that does not agree in state with the site.

@@ -22,5 +23,18 @@
<i class="fa fa-lg fa-plug"></i>
<span class="text">{% trans "Terminate" %}</span>
</a>
{% if not original.is_disabled %}
<a style="display: none" title="{% trans "Disable" %}" href="{% url 'admin:judge_judge_disable' original.pk %}"
Copy link
Member

Choose a reason for hiding this comment

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

Missing indentation within the if/else.

Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Xyene Xyene merged commit dac260f into master Jan 3, 2023
@Xyene Xyene deleted the disable-judge branch January 3, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants