Skip to content

Commit

Permalink
Get job settings from challenge request in phase conversion form
Browse files Browse the repository at this point in the history
  • Loading branch information
koopmant committed Dec 6, 2024
1 parent 4a9868e commit db9db17
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
29 changes: 28 additions & 1 deletion app/grandchallenge/evaluation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,14 @@ class ConfigureAlgorithmPhasesForm(SaveFormInitMixin, Form):
widget=forms.HiddenInput(),
disabled=True,
)
algorithm_selectable_gpu_type_choices = forms.JSONField(
widget=forms.HiddenInput(),
disabled=True,
)
algorithm_maximum_settable_memory_gb = forms.IntegerField(
widget=forms.HiddenInput(),
disabled=True,
)

def __init__(self, *args, challenge, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -772,10 +780,29 @@ def __init__(self, *args, challenge, **kwargs):
challenge_request = ChallengeRequest.objects.get(
short_name=challenge.short_name
)
except ObjectDoesNotExist:
challenge_request = None
if challenge_request:
self.fields["algorithm_selectable_gpu_type_choices"].initial = (
challenge_request.algorithm_selectable_gpu_type_choices
)
self.fields["algorithm_maximum_settable_memory_gb"].initial = (
challenge_request.algorithm_maximum_settable_memory_gb
)
self.fields["algorithm_time_limit"].initial = (
challenge_request.inference_time_limit_in_minutes * 60
)
except ObjectDoesNotExist:
else:
self.fields["algorithm_selectable_gpu_type_choices"].initial = (
Phase._meta.get_field(
"algorithm_selectable_gpu_type_choices"
).get_default()
)
self.fields["algorithm_maximum_settable_memory_gb"].initial = (
Phase._meta.get_field(
"algorithm_maximum_settable_memory_gb"
).get_default()
)
self.fields["algorithm_time_limit"].initial = (
Phase._meta.get_field("algorithm_time_limit").get_default()
)
Expand Down
21 changes: 20 additions & 1 deletion app/grandchallenge/evaluation/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,12 @@ def form_valid(self, form):
inputs=form.cleaned_data["algorithm_inputs"],
outputs=form.cleaned_data["algorithm_outputs"],
algorithm_time_limit=form.cleaned_data["algorithm_time_limit"],
algorithm_selectable_gpu_type_choices=form.cleaned_data[
"algorithm_selectable_gpu_type_choices"
],
algorithm_maximum_settable_memory_gb=form.cleaned_data[
"algorithm_maximum_settable_memory_gb"
],
)
messages.success(self.request, "Phases were successfully updated")
return super().form_valid(form)
Expand All @@ -1055,7 +1061,14 @@ def get_success_url(self):
)

def turn_phase_into_algorithm_phase(
self, *, phase, inputs, outputs, algorithm_time_limit
self,
*,
phase,
inputs,
outputs,
algorithm_time_limit,
algorithm_selectable_gpu_type_choices,
algorithm_maximum_settable_memory_gb,
):
archive = Archive.objects.create(
title=format_html(
Expand All @@ -1079,6 +1092,12 @@ def turn_phase_into_algorithm_phase(
archive.add_editor(user)

phase.algorithm_time_limit = algorithm_time_limit
phase.algorithm_selectable_gpu_type_choices = (
algorithm_selectable_gpu_type_choices
)
phase.algorithm_maximum_settable_memory_gb = (
algorithm_maximum_settable_memory_gb
)
phase.archive = archive
phase.submission_kind = phase.SubmissionKindChoices.ALGORITHM
phase.creator_must_be_verified = True
Expand Down
8 changes: 8 additions & 0 deletions app/tests/evaluation_tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,14 @@ def test_configure_algorithm_phases_view(client):
phase.algorithm_time_limit
== challenge_request.inference_time_limit_in_minutes * 60
)
assert (
phase.algorithm_selectable_gpu_type_choices
== challenge_request.algorithm_selectable_gpu_type_choices
)
assert (
phase.algorithm_maximum_settable_memory_gb
== challenge_request.algorithm_maximum_settable_memory_gb
)


@pytest.mark.django_db
Expand Down
2 changes: 2 additions & 0 deletions app/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class Meta:
)
expected_number_of_teams = 10
inference_time_limit_in_minutes = 10
algorithm_selectable_gpu_type_choices = ["", "A10G", "T4"]
algorithm_maximum_settable_memory_gb = 40
average_size_of_test_image_in_mb = 10
phase_1_number_of_submissions_per_team = 10
phase_2_number_of_submissions_per_team = 0
Expand Down

0 comments on commit db9db17

Please sign in to comment.