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

Add backend for GitHub challenges #2965

Merged
merged 16 commits into from
Sep 10, 2020

Conversation

KhalidRmb
Copy link
Member

@KhalidRmb KhalidRmb commented Aug 20, 2020

This PR includes the backend changes to enable GitHub based challenges.

Changes:

  • Refactor Abstract out and make relevant changes to Challenge config validation API
  • Add new API for GitHub challenges MVP
  • The above API handled both updates and creation for a Github based challenge, and is called from the build step in the host's private repository through Github Actions
  • Add a field in Challenge model for storing the github_repository identifier which uniquely identifies a private github repository (of the format: <github_account>/<github_repo_name>)
  • Changes in tests and serialisers to incorporate the changes in the Challenge model

Screenshot 2020-08-20 at 9 36 43 PM

@codecov-commenter
Copy link

Codecov Report

Merging #2965 into master will increase coverage by 1.09%.
The diff coverage is 25.99%.

@@            Coverage Diff             @@
##           master    #2965      +/-   ##
==========================================
+ Coverage   72.93%   74.03%   +1.09%     
==========================================
  Files          83       20      -63     
  Lines        5368     3019    -2349     
==========================================
- Hits         3915     2235    -1680     
+ Misses       1453      784     -669     
Impacted Files Coverage Δ
...ontend/src/js/controllers/featuredChallengeCtrl.js 68.99% <ø> (ø)
frontend/src/js/controllers/authCtrl.js 58.58% <3.70%> (-8.28%) ⬇️
frontend/src/js/controllers/permissionCtrl.js 36.36% <22.22%> (-63.64%) ⬇️
frontend/src/js/controllers/challengeCtrl.js 66.18% <22.48%> (-7.52%) ⬇️
frontend/src/js/controllers/challengeListCtrl.js 95.74% <50.00%> (+1.06%) ⬆️
...ntend/src/js/controllers/challengeHostTeamsCtrl.js 70.50% <66.66%> (-1.18%) ⬇️
frontend/src/js/controllers/teamsCtrl.js 71.17% <66.66%> (ø)
frontend/src/js/controllers/changePwdCtrl.js 100.00% <100.00%> (ø)
frontend/src/js/controllers/dashCtrl.js 99.00% <100.00%> (+0.08%) ⬆️
apps/web/urls.py
... and 36 more
Impacted Files Coverage Δ
...ontend/src/js/controllers/featuredChallengeCtrl.js 68.99% <ø> (ø)
frontend/src/js/controllers/authCtrl.js 58.58% <3.70%> (-8.28%) ⬇️
frontend/src/js/controllers/permissionCtrl.js 36.36% <22.22%> (-63.64%) ⬇️
frontend/src/js/controllers/challengeCtrl.js 66.18% <22.48%> (-7.52%) ⬇️
frontend/src/js/controllers/challengeListCtrl.js 95.74% <50.00%> (+1.06%) ⬆️
...ntend/src/js/controllers/challengeHostTeamsCtrl.js 70.50% <66.66%> (-1.18%) ⬇️
frontend/src/js/controllers/teamsCtrl.js 71.17% <66.66%> (ø)
frontend/src/js/controllers/changePwdCtrl.js 100.00% <100.00%> (ø)
frontend/src/js/controllers/dashCtrl.js 99.00% <100.00%> (+0.08%) ⬆️
apps/web/urls.py
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd7147a...9355a29. Read the comment docs.

apps/challenges/challenge_config_utils.py Outdated Show resolved Hide resolved
apps/challenges/challenge_config_utils.py Outdated Show resolved Hide resolved
apps/challenges/views.py Outdated Show resolved Hide resolved
apps/challenges/models.py Outdated Show resolved Hide resolved
apps/challenges/views.py Outdated Show resolved Hide resolved
apps/challenges/views.py Outdated Show resolved Hide resolved
apps/challenges/views.py Show resolved Hide resolved
apps/challenges/views.py Outdated Show resolved Hide resolved
else:
message = (" ERROR: There is no html file present for key"
" {} in phase {}.".format(key, yaml_file_data["name"]))
is_valid = True
Copy link
Member

Choose a reason for hiding this comment

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

@KhalidRmb why is this check removed?

Copy link
Member Author

@KhalidRmb KhalidRmb Sep 6, 2020

Choose a reason for hiding this comment

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

Because the validation inside the challenge create API is such that it allows an invalid value for the file. It just replaces it with null before moving on. Validation fails if the entire key is missing. @Ram81 (I'd discussed this with you when working on this, and we decided to keep it this way)

Copy link
Member

Choose a reason for hiding this comment

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

I didn't get the reason for the removal of this check. Can we please discuss about this on slack channel.



def get_value_from_field(data, base_location, field_name):
file_path = join(base_location, data.get(field_name))
Copy link
Member

Choose a reason for hiding this comment

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

what about exception handling for missing values for a field name?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the value is missing, this function will return None. In accordance with the validation. (This is also what happens in the create challenge API)

else:
message = (" ERROR: There is no html file present for key"
" {} in phase {}.".format(key, yaml_file_data["name"]))
is_valid = True
Copy link
Member

Choose a reason for hiding this comment

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

I didn't get the reason for the removal of this check. Can we please discuss about this on slack channel.

@@ -196,6 +200,7 @@ def create_eks_cluster_for_challenge(sender, instance, created, **kwargs):
class DatasetSplit(TimeStampedModel):
name = models.CharField(max_length=100)
codename = models.CharField(max_length=100)
config_id = models.IntegerField(default=None, blank=True, null=True)
Copy link
Member

Choose a reason for hiding this comment

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

Can we please add comments for these fields answering why are they needed.

@@ -263,6 +268,7 @@ def __init__(self, *args, **kwargs):
is_partial_submission_evaluation_enabled = models.BooleanField(
default=False
)
config_id = models.IntegerField(default=None, blank=True, null=True)
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

@@ -317,6 +323,7 @@ def save(self, *args, **kwargs):
class Leaderboard(TimeStampedModel):

schema = JSONField()
config_id = models.IntegerField(default=None, blank=True, null=True)
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
@authentication_classes((ExpiringTokenAuthentication,))
def create_or_update_github_challenge(request, challenge_host_team_pk):
challenge_queryset = Challenge.objects.filter(
Copy link
Member

Choose a reason for hiding this comment

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

Can we please add check to verify who can use this API?

Copy link
Member

Choose a reason for hiding this comment

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

It should be accessed by hosts only.

challenge_phases_data,
files["challenge_test_annotation_files"],
):
data["slug"] = "{}-{}-{}".format(
Copy link
Member

Choose a reason for hiding this comment

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

isn't there a util method to get slug?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's different. That just replaces empty spaces with '-', and is used only for challenge. I can use it here only to modify the codename.

@KhalidRmb
Copy link
Member Author

@RishabhJain2018
Done

@RishabhJain2018
Copy link
Member

@KhalidRmb Can you please resolve the conflicts here?

@KhalidRmb
Copy link
Member Author

@RishabhJain2018 Done

@RishabhJain2018 RishabhJain2018 merged commit 47af1db into Cloud-CV:master Sep 10, 2020
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.

4 participants