Skip to content

Commit 7cf1ba3

Browse files
Revert "Backend: Add field to store github branch for challenge creation(Cloud-CV#4737)" (Cloud-CV#4742)
This reverts commit 6549fcb.
1 parent 8ff4236 commit 7cf1ba3

10 files changed

Lines changed: 3 additions & 134 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ notifications:
8181
email:
8282
on_success: change
8383
on_failure: always
84-
slack: cloudcv:gy3CGQGNXLwXOqVyzXGZfdea
84+
slack: cloudcv:gy3CGQGNXLwXOqVyzXGZfdea

apps/challenges/admin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class ChallengeAdmin(ImportExportTimeStampedAdmin):
5858
"workers",
5959
"task_def_arn",
6060
"github_repository",
61-
"github_branch",
6261
)
6362
list_filter = (
6463
ChallengeFilter,
@@ -76,7 +75,6 @@ class ChallengeAdmin(ImportExportTimeStampedAdmin):
7675
"creator__team_name",
7776
"slug",
7877
"github_repository",
79-
"github_branch",
8078
)
8179
actions = [
8280
"start_selected_workers",

apps/challenges/challenge_config_utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,6 @@ def validate_serializer(self):
586586
"github_repository": self.request.data[
587587
"GITHUB_REPOSITORY"
588588
],
589-
"github_branch": self.request.data.get(
590-
"GITHUB_BRANCH_NAME", ""
591-
),
592589
},
593590
)
594591
if not serializer.is_valid():

apps/challenges/migrations/0113_add_github_branch_field_and_unique_constraint.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

apps/challenges/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ def __init__(self, *args, **kwargs):
186186
github_repository = models.CharField(
187187
max_length=1000, null=True, blank=True, default=""
188188
)
189-
# The github branch name used to create/update the challenge
190-
github_branch = models.CharField(
191-
max_length=200, null=True, blank=True, default=""
192-
)
193189
# The number of vCPU for a Fargate worker for the challenge. Default value
194190
# is 0.25 vCPU.
195191
worker_cpu_cores = models.IntegerField(null=True, blank=True, default=512)

apps/challenges/serializers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class Meta:
9595
"worker_instance_type",
9696
"sqs_retention_period",
9797
"github_repository",
98-
"github_branch",
9998
)
10099

101100

@@ -257,9 +256,6 @@ def __init__(self, *args, **kwargs):
257256
github_repository = context.get("github_repository")
258257
if github_repository:
259258
kwargs["data"]["github_repository"] = github_repository
260-
github_branch = context.get("github_branch")
261-
if github_branch:
262-
kwargs["data"]["github_branch"] = github_branch
263259

264260
class Meta:
265261
model = Challenge
@@ -298,7 +294,6 @@ class Meta:
298294
"max_docker_image_size",
299295
"cli_version",
300296
"github_repository",
301-
"github_branch",
302297
"vpc_cidr",
303298
"subnet_1_cidr",
304299
"subnet_2_cidr",

apps/challenges/views.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,12 +3897,8 @@ def create_or_update_github_challenge(request, challenge_host_team_pk):
38973897
response_data = {"error": "ChallengeHostTeam does not exist"}
38983898
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
38993899

3900-
# Get branch name with default fallback
3901-
github_branch = request.data.get("GITHUB_BRANCH_NAME", "")
3902-
39033900
challenge_queryset = Challenge.objects.filter(
3904-
github_repository=request.data["GITHUB_REPOSITORY"],
3905-
github_branch=github_branch,
3901+
github_repository=request.data["GITHUB_REPOSITORY"]
39063902
)
39073903

39083904
if challenge_queryset:
@@ -3983,7 +3979,6 @@ def create_or_update_github_challenge(request, challenge_host_team_pk):
39833979
"github_repository": request.data[
39843980
"GITHUB_REPOSITORY"
39853981
],
3986-
"github_branch": github_branch,
39873982
"worker_image_url": worker_image_url,
39883983
},
39893984
)

scripts/seed.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ def create_challenge(
255255
queue=queue,
256256
featured=is_featured,
257257
image=image_file,
258-
github_repository=f"evalai-examples/{slug}",
259-
github_branch="main",
260258
)
261259
challenge.save()
262260

tests/unit/challenges/test_views.py

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,11 @@ def test_get_challenge(self):
205205
"worker_instance_type": self.challenge.worker_instance_type,
206206
"sqs_retention_period": self.challenge.sqs_retention_period,
207207
"github_repository": self.challenge.github_repository,
208-
"github_branch": self.challenge.github_branch,
209208
}
210209
]
211210

212211
response = self.client.get(self.url, {})
213-
self.assertEqual(
214-
response.data["results"], json.loads(json.dumps(expected))
215-
)
212+
self.assertEqual(response.data["results"], expected)
216213
self.assertEqual(response.status_code, status.HTTP_200_OK)
217214

218215
def test_particular_challenge_host_team_for_challenge_does_not_exist(self):
@@ -580,7 +577,6 @@ def test_get_particular_challenge(self):
580577
"worker_instance_type": self.challenge.worker_instance_type,
581578
"sqs_retention_period": self.challenge.sqs_retention_period,
582579
"github_repository": self.challenge.github_repository,
583-
"github_branch": self.challenge.github_branch,
584580
}
585581
response = self.client.get(self.url, {})
586582
self.assertEqual(response.data, expected)
@@ -684,7 +680,6 @@ def test_update_challenge_when_user_is_its_creator(self):
684680
"worker_instance_type": self.challenge.worker_instance_type,
685681
"sqs_retention_period": self.challenge.sqs_retention_period,
686682
"github_repository": self.challenge.github_repository,
687-
"github_branch": self.challenge.github_branch,
688683
}
689684
response = self.client.put(
690685
self.url, {"title": new_title, "description": new_description}
@@ -814,7 +809,6 @@ def test_particular_challenge_partial_update(self):
814809
"worker_instance_type": self.challenge.worker_instance_type,
815810
"sqs_retention_period": self.challenge.sqs_retention_period,
816811
"github_repository": self.challenge.github_repository,
817-
"github_branch": self.challenge.github_branch,
818812
}
819813
response = self.client.patch(self.url, self.partial_update_data)
820814
self.assertEqual(response.data, expected)
@@ -893,7 +887,6 @@ def test_particular_challenge_update(self):
893887
"worker_instance_type": self.challenge.worker_instance_type,
894888
"sqs_retention_period": self.challenge.sqs_retention_period,
895889
"github_repository": self.challenge.github_repository,
896-
"github_branch": self.challenge.github_branch,
897890
}
898891
response = self.client.put(self.url, self.data)
899892
self.assertEqual(response.data, expected)
@@ -1491,7 +1484,6 @@ def test_get_past_challenges(self):
14911484
"worker_instance_type": self.challenge3.worker_instance_type,
14921485
"sqs_retention_period": self.challenge3.sqs_retention_period,
14931486
"github_repository": self.challenge3.github_repository,
1494-
"github_branch": self.challenge3.github_branch,
14951487
}
14961488
]
14971489
response = self.client.get(self.url, {}, format="json")
@@ -1576,7 +1568,6 @@ def test_get_present_challenges(self):
15761568
"worker_instance_type": self.challenge2.worker_instance_type,
15771569
"sqs_retention_period": self.challenge2.sqs_retention_period,
15781570
"github_repository": self.challenge2.github_repository,
1579-
"github_branch": self.challenge2.github_branch,
15801571
}
15811572
]
15821573
response = self.client.get(self.url, {}, format="json")
@@ -1661,7 +1652,6 @@ def test_get_future_challenges(self):
16611652
"worker_instance_type": self.challenge4.worker_instance_type,
16621653
"sqs_retention_period": self.challenge4.sqs_retention_period,
16631654
"github_repository": self.challenge4.github_repository,
1664-
"github_branch": self.challenge4.github_branch,
16651655
}
16661656
]
16671657
response = self.client.get(self.url, {}, format="json")
@@ -1746,7 +1736,6 @@ def test_get_all_challenges(self):
17461736
"worker_instance_type": self.challenge4.worker_instance_type,
17471737
"sqs_retention_period": self.challenge4.sqs_retention_period,
17481738
"github_repository": self.challenge4.github_repository,
1749-
"github_branch": self.challenge4.github_branch,
17501739
},
17511740
{
17521741
"id": self.challenge3.pk,
@@ -1815,7 +1804,6 @@ def test_get_all_challenges(self):
18151804
"worker_instance_type": self.challenge3.worker_instance_type,
18161805
"sqs_retention_period": self.challenge3.sqs_retention_period,
18171806
"github_repository": self.challenge3.github_repository,
1818-
"github_branch": self.challenge3.github_branch,
18191807
},
18201808
{
18211809
"id": self.challenge2.pk,
@@ -1884,7 +1872,6 @@ def test_get_all_challenges(self):
18841872
"worker_instance_type": self.challenge2.worker_instance_type,
18851873
"sqs_retention_period": self.challenge2.sqs_retention_period,
18861874
"github_repository": self.challenge2.github_repository,
1887-
"github_branch": self.challenge2.github_branch,
18881875
},
18891876
]
18901877
response = self.client.get(self.url, {}, format="json")
@@ -2025,7 +2012,6 @@ def test_get_featured_challenges(self):
20252012
"worker_instance_type": self.challenge3.worker_instance_type,
20262013
"sqs_retention_period": self.challenge3.sqs_retention_period,
20272014
"github_repository": self.challenge3.github_repository,
2028-
"github_branch": self.challenge3.github_branch,
20292015
}
20302016
]
20312017
response = self.client.get(self.url, {}, format="json")
@@ -2191,7 +2177,6 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self):
21912177
"worker_instance_type": self.challenge3.worker_instance_type,
21922178
"sqs_retention_period": self.challenge3.sqs_retention_period,
21932179
"github_repository": self.challenge3.github_repository,
2194-
"github_branch": self.challenge3.github_branch,
21952180
}
21962181

21972182
response = self.client.get(self.url, {})
@@ -2284,7 +2269,6 @@ def test_get_challenge_by_pk_when_user_is_participant(self):
22842269
"worker_instance_type": self.challenge4.worker_instance_type,
22852270
"sqs_retention_period": self.challenge4.sqs_retention_period,
22862271
"github_repository": self.challenge4.github_repository,
2287-
"github_branch": self.challenge4.github_branch,
22882272
}
22892273

22902274
self.client.force_authenticate(user=self.user1)
@@ -2439,7 +2423,6 @@ def test_get_challenge_when_host_team_is_given(self):
24392423
"worker_instance_type": self.challenge2.worker_instance_type,
24402424
"sqs_retention_period": self.challenge2.sqs_retention_period,
24412425
"github_repository": self.challenge2.github_repository,
2442-
"github_branch": self.challenge2.github_branch,
24432426
}
24442427
]
24452428

@@ -2520,7 +2503,6 @@ def test_get_challenge_when_participant_team_is_given(self):
25202503
"worker_instance_type": self.challenge2.worker_instance_type,
25212504
"sqs_retention_period": self.challenge2.sqs_retention_period,
25222505
"github_repository": self.challenge2.github_repository,
2523-
"github_branch": self.challenge2.github_branch,
25242506
}
25252507
]
25262508

@@ -2601,7 +2583,6 @@ def test_get_challenge_when_mode_is_participant(self):
26012583
"worker_instance_type": self.challenge2.worker_instance_type,
26022584
"sqs_retention_period": self.challenge2.sqs_retention_period,
26032585
"github_repository": self.challenge2.github_repository,
2604-
"github_branch": self.challenge2.github_branch,
26052586
}
26062587
]
26072588

@@ -2680,7 +2661,6 @@ def test_get_challenge_when_mode_is_host(self):
26802661
"worker_instance_type": self.challenge.worker_instance_type,
26812662
"sqs_retention_period": self.challenge.sqs_retention_period,
26822663
"github_repository": self.challenge.github_repository,
2683-
"github_branch": self.challenge.github_branch,
26842664
},
26852665
{
26862666
"id": self.challenge2.pk,
@@ -2749,7 +2729,6 @@ def test_get_challenge_when_mode_is_host(self):
27492729
"worker_instance_type": self.challenge2.worker_instance_type,
27502730
"sqs_retention_period": self.challenge2.sqs_retention_period,
27512731
"github_repository": self.challenge2.github_repository,
2752-
"github_branch": self.challenge2.github_branch,
27532732
},
27542733
]
27552734

@@ -5932,7 +5911,6 @@ def test_create_challenge_using_github_success(self):
59325911
self.url,
59335912
{
59345913
"GITHUB_REPOSITORY": "https://github.com/yourusername/repository",
5935-
"GITHUB_BRANCH_NAME": "refs/heads/challenge",
59365914
"zip_configuration": self.input_zip_file,
59375915
},
59385916
format="multipart",
@@ -5948,14 +5926,6 @@ def test_create_challenge_using_github_success(self):
59485926
self.assertEqual(Leaderboard.objects.count(), 1)
59495927
self.assertEqual(ChallengePhaseSplit.objects.count(), 1)
59505928

5951-
# Verify github_branch is properly stored
5952-
challenge = Challenge.objects.first()
5953-
self.assertEqual(
5954-
challenge.github_repository,
5955-
"https://github.com/yourusername/repository",
5956-
)
5957-
self.assertEqual(challenge.github_branch, "refs/heads/challenge")
5958-
59595929
def test_create_challenge_using_github_when_challenge_host_team_does_not_exist(
59605930
self,
59615931
):
@@ -5994,40 +5964,6 @@ def test_create_challenge_using_github_when_user_is_not_authenticated(
59945964
self.assertEqual(list(response.data.values())[0], expected["error"])
59955965
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
59965966

5997-
def test_create_challenge_using_github_without_branch_name(self):
5998-
self.url = reverse_lazy(
5999-
"challenges:create_or_update_github_challenge",
6000-
kwargs={"challenge_host_team_pk": self.challenge_host_team.pk},
6001-
)
6002-
6003-
with mock.patch("challenges.views.requests.get") as m:
6004-
resp = mock.Mock()
6005-
resp.content = self.test_zip_file.read()
6006-
resp.status_code = 200
6007-
m.return_value = resp
6008-
response = self.client.post(
6009-
self.url,
6010-
{
6011-
"GITHUB_REPOSITORY": "https://github.com/yourusername/repository",
6012-
"zip_configuration": self.input_zip_file,
6013-
},
6014-
format="multipart",
6015-
)
6016-
expected = {
6017-
"Success": "Challenge Challenge Title has been created successfully and sent for review to EvalAI Admin."
6018-
}
6019-
6020-
self.assertEqual(response.status_code, 201)
6021-
self.assertEqual(response.json(), expected)
6022-
6023-
# Verify github_branch defaults to empty string when not provided
6024-
challenge = Challenge.objects.first()
6025-
self.assertEqual(
6026-
challenge.github_repository,
6027-
"https://github.com/yourusername/repository",
6028-
)
6029-
self.assertEqual(challenge.github_branch, "")
6030-
60315967

60325968
class ValidateChallengeTest(APITestCase):
60335969
def setUp(self):
@@ -6094,7 +6030,6 @@ def test_validate_challenge_using_success(self):
60946030
self.url,
60956031
{
60966032
"GITHUB_REPOSITORY": "https://github.com/yourusername/repository",
6097-
"GITHUB_BRANCH_NAME": "refs/heads/challenge",
60986033
"zip_configuration": self.input_zip_file,
60996034
},
61006035
format="multipart",

tests/unit/participants/test_views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ def test_get_teams_and_corresponding_challenges_for_a_participant(self):
884884
"worker_instance_type": self.challenge1.worker_instance_type,
885885
"sqs_retention_period": self.challenge1.sqs_retention_period,
886886
"github_repository": self.challenge1.github_repository,
887-
"github_branch": self.challenge1.github_branch,
888887
},
889888
"participant_team": {
890889
"id": self.participant_team.id,
@@ -982,7 +981,6 @@ def test_get_participant_team_challenge_list(self):
982981
"worker_instance_type": self.challenge1.worker_instance_type,
983982
"sqs_retention_period": self.challenge1.sqs_retention_period,
984983
"github_repository": self.challenge1.github_repository,
985-
"github_branch": self.challenge1.github_branch,
986984
}
987985
]
988986

0 commit comments

Comments
 (0)