From 8939a67d9ea80e942cb098cef4d0c8c45e4e6031 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 12 May 2023 13:19:41 +0500 Subject: [PATCH 01/13] Leaderboard show total entries and date of last entry --- src/apps/api/views/competitions.py | 12 ++++++++++++ src/static/riot/competitions/detail/leaderboards.tag | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 4f6288da9..77eadf990 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -501,6 +501,16 @@ def get_leaderboard(self, request, pk): columns = [col for col in query['columns']] submissions_keys = {} for submission in query['submissions']: + + # count number of entried/ number of submissions for user of the submission + num_entries = Submission.objects.filter(owner__username=submission['owner']).count() + + # get date of last submission + last_entry_date = Submission.objects.filter(owner__username=submission['owner'])\ + .values('created_when')\ + .order_by('-created_when')[0]['created_when']\ + .strftime('%Y-%m-%d %H:%M:%S') + submission_key = f"{submission['owner']}{submission['parent'] or submission['id']}" if submission_key not in submissions_keys: submissions_keys[submission_key] = len(response['submissions']) @@ -511,6 +521,8 @@ def get_leaderboard(self, request, pk): 'fact_sheet_answers': submission['fact_sheet_answers'], 'slug_url': submission['slug_url'], 'organization': submission['organization'], + 'num_entries': num_entries, + 'last_entry_date': last_entry_date }) for score in submission['scores']: diff --git a/src/static/riot/competitions/detail/leaderboards.tag b/src/static/riot/competitions/detail/leaderboards.tag index 6e476108f..1befeafdf 100644 --- a/src/static/riot/competitions/detail/leaderboards.tag +++ b/src/static/riot/competitions/detail/leaderboards.tag @@ -35,7 +35,9 @@ # Participant - {column.title} + Entries + Date of last entry + {column.title} Detailed Results @@ -55,6 +57,8 @@ {index + 1} { submission.owner } + {submission.num_entries} + {submission.last_entry_date} { submission.organization.name } { get_score(column, submission) } Show detailed results @@ -120,6 +124,7 @@ self.update_leaderboard = () => { CODALAB.api.get_leaderboard_for_render(self.phase_id) .done(responseData => { + console.log(responseData) self.selected_leaderboard = responseData self.columns = [] // Make fake task and columns for Metadata so it can be filtered like columns From 044e48b235a52d0d97e307415b95cf7796621a27 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 12 May 2023 15:36:46 +0500 Subject: [PATCH 02/13] test updated to test the right td for prediction score --- src/tests/functional/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/test_submissions.py b/src/tests/functional/test_submissions.py index 5bc11af8a..8f13064b4 100644 --- a/src/tests/functional/test_submissions.py +++ b/src/tests/functional/test_submissions.py @@ -73,7 +73,7 @@ def _run_submission_and_add_to_leaderboard(self, competition_zip_path, submissio # The leaderboard table lists our submission prediction_score = Submission.objects.get(pk=submission_id).scores.first().score - assert Decimal(self.find('leaderboards table tbody tr:nth-of-type(1) td:nth-of-type(3)').text) == round(Decimal(prediction_score), precision) + assert Decimal(self.find('leaderboards table tbody tr:nth-of-type(1) td:nth-of-type(5)').text) == round(Decimal(prediction_score), precision) def test_v15_iris_result_submission_end_to_end(self): self._run_submission_and_add_to_leaderboard('competition_15_iris.zip', 'submission_15_iris_result.zip', '======= Set 1 (Iris_test)', has_solutions=False, precision=4) From 3f070c2e0dbf5a04754248a91dd8755b6fff9bbd Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 12 May 2023 16:40:22 +0500 Subject: [PATCH 03/13] console log removed --- src/static/riot/competitions/detail/leaderboards.tag | 1 - 1 file changed, 1 deletion(-) diff --git a/src/static/riot/competitions/detail/leaderboards.tag b/src/static/riot/competitions/detail/leaderboards.tag index 1befeafdf..16aa8e60f 100644 --- a/src/static/riot/competitions/detail/leaderboards.tag +++ b/src/static/riot/competitions/detail/leaderboards.tag @@ -124,7 +124,6 @@ self.update_leaderboard = () => { CODALAB.api.get_leaderboard_for_render(self.phase_id) .done(responseData => { - console.log(responseData) self.selected_leaderboard = responseData self.columns = [] // Make fake task and columns for Metadata so it can be filtered like columns From 748805009d17e8252ea9cbab0b9f38633a098b25 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 12 May 2023 16:42:04 +0500 Subject: [PATCH 04/13] date format change to just date YYY-MM-DD --- src/apps/api/views/competitions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 77eadf990..2a9e676d7 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -509,7 +509,7 @@ def get_leaderboard(self, request, pk): last_entry_date = Submission.objects.filter(owner__username=submission['owner'])\ .values('created_when')\ .order_by('-created_when')[0]['created_when']\ - .strftime('%Y-%m-%d %H:%M:%S') + .strftime('%Y-%m-%d') submission_key = f"{submission['owner']}{submission['parent'] or submission['id']}" if submission_key not in submissions_keys: From d10b2588697f7202bc72b723dd827296e667ad41 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 12 May 2023 18:31:24 +0500 Subject: [PATCH 05/13] num_entries fixed, ui changed to adjust factsheet answers --- src/apps/api/views/competitions.py | 8 ++++---- src/static/riot/competitions/detail/leaderboards.tag | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 2a9e676d7..666a2f5ab 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -502,11 +502,11 @@ def get_leaderboard(self, request, pk): submissions_keys = {} for submission in query['submissions']: - # count number of entried/ number of submissions for user of the submission - num_entries = Submission.objects.filter(owner__username=submission['owner']).count() + # count number of entries/number of submissions for the owner of this submission for this phase + num_entries = Submission.objects.filter(owner__username=submission['owner'], phase=phase).count() - # get date of last submission - last_entry_date = Submission.objects.filter(owner__username=submission['owner'])\ + # get date of last submission by the owner of this submission for this phase + last_entry_date = Submission.objects.filter(owner__username=submission['owner'], phase=phase)\ .values('created_when')\ .order_by('-created_when')[0]['created_when']\ .strftime('%Y-%m-%d') diff --git a/src/static/riot/competitions/detail/leaderboards.tag b/src/static/riot/competitions/detail/leaderboards.tag index 16aa8e60f..d289060ef 100644 --- a/src/static/riot/competitions/detail/leaderboards.tag +++ b/src/static/riot/competitions/detail/leaderboards.tag @@ -28,7 +28,7 @@ Task: - + { task.name } From 8ce8a6a5a627df9f78f5eb466f3b5ca4cca396a0 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Tue, 16 May 2023 20:55:29 +0500 Subject: [PATCH 06/13] Score shown in submission panel for user and admin --- .../riot/competitions/detail/submission_manager.tag | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/static/riot/competitions/detail/submission_manager.tag b/src/static/riot/competitions/detail/submission_manager.tag index 0dd92d7d2..057cd089b 100644 --- a/src/static/riot/competitions/detail/submission_manager.tag +++ b/src/static/riot/competitions/detail/submission_manager.tag @@ -62,7 +62,8 @@ Owner Phase Date - Status + Status + Score Actions @@ -94,6 +95,7 @@ + {get_score(submission)} Date: Wed, 17 May 2023 11:49:42 +0500 Subject: [PATCH 07/13] selenium test updated for click to the right table td --- src/tests/functional/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/test_submissions.py b/src/tests/functional/test_submissions.py index 8f13064b4..2beba29f1 100644 --- a/src/tests/functional/test_submissions.py +++ b/src/tests/functional/test_submissions.py @@ -68,7 +68,7 @@ def _run_submission_and_add_to_leaderboard(self, competition_zip_path, submissio submission_id = int(self.find('submission-manager#user-submission-table table tbody tr:nth-of-type(1) td:nth-of-type(1)').text) # Add the submission to the leaderboard and go to results tab - self.find('submission-manager#user-submission-table table tbody tr:nth-of-type(1) td:nth-of-type(5) span[data-tooltip="Add to Leaderboard"]').click() + self.find('submission-manager#user-submission-table table tbody tr:nth-of-type(1) td:nth-of-type(6) span[data-tooltip="Add to Leaderboard"]').click() self.find('.item[data-tab="results-tab"]').click() # The leaderboard table lists our submission From 96fda39d7fef4b8c6dafa9ad990d05758f55fb8c Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Wed, 17 May 2023 15:46:14 +0500 Subject: [PATCH 08/13] debug log removed --- src/apps/api/views/competitions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 666a2f5ab..b104c69a6 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -97,7 +97,6 @@ def get_queryset(self): # On GETs lets optimize the query to reduce DB calls if self.request.method == 'GET': - logger.warning("\n\nGET\n\n") qs = qs.select_related('created_by') if self.action != 'list': qs = qs.select_related('created_by') From bcd8fb3b97fbbeb4fb4207b9f3116a60d783edfd Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Wed, 17 May 2023 17:20:42 +0500 Subject: [PATCH 09/13] html is now interpreted in compettion pages --- src/static/riot/competitions/detail/_tabs.tag | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/static/riot/competitions/detail/_tabs.tag b/src/static/riot/competitions/detail/_tabs.tag index 719308664..a56325567 100644 --- a/src/static/riot/competitions/detail/_tabs.tag +++ b/src/static/riot/competitions/detail/_tabs.tag @@ -328,7 +328,14 @@ // Need to run update() to build tags to render html in self.update() _.forEach(self.competition.pages, (page, index) => { - $(`#page_${index}`)[0].innerHTML = render_markdown(page.content) + + if (self.isHTML(page.content)){ + $(`#page_${index}`)[0].innerHTML = sanitize_HTML(page.content) + }else{ + $(`#page_${index}`)[0].innerHTML = render_markdown(page.content) + } + + }) _.forEach(self.competition.phases, (phase, index) => { $(`#phase_${index}`)[0].innerHTML = render_markdown(phase.description) @@ -359,6 +366,12 @@ CODALAB.events.trigger('phase_selected', data) } } + // To check if page content has HTML + // Return true if content is html + // Return false if content is not html i.e. MarkDown + self.isHTML = function (page_content) { + return /<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i.test(page_content); + } self.update() From 2f8dbf8ab98e9a1c7f9cf09ab67d8d103c506f5c Mon Sep 17 00:00:00 2001 From: didayolo Date: Wed, 17 May 2023 16:44:13 +0200 Subject: [PATCH 10/13] Mount /codabench/data to /app/data --- compute_worker/compute_worker.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compute_worker/compute_worker.py b/compute_worker/compute_worker.py index c8bef06d1..93e709ece 100644 --- a/compute_worker/compute_worker.py +++ b/compute_worker/compute_worker.py @@ -39,9 +39,9 @@ # Setup base directories used by all submissions -HOST_DIRECTORY = os.environ.get("HOST_DIRECTORY", "/tmp/codabench/") # note: we need to pass this directory to - # docker compose so it knows where to store things! -BASE_DIR = "/codabench/" +# note: we need to pass this directory to docker-compose so it knows where to store things! +HOST_DIRECTORY = os.environ.get("HOST_DIRECTORY", "/tmp/codabench/") +BASE_DIR = "/codabench/" # base directory inside the container CACHE_DIR = os.path.join(BASE_DIR, "cache") MAX_CACHE_DIR_SIZE_GB = float(os.environ.get('MAX_CACHE_DIR_SIZE_GB', 10)) @@ -182,6 +182,7 @@ def __init__(self, run_args): self.bundle_dir = os.path.join(self.root_dir, "bundles") self.input_dir = os.path.join(self.root_dir, "input") self.output_dir = os.path.join(self.root_dir, "output") + self.data_dir = os.path.join(HOST_DIRECTORY, "data") # absolute path to data in the host self.logs = {} # Details for submission @@ -522,6 +523,7 @@ async def _run_program_directory(self, program_dir, kind, can_be_output=False): # Set the volumes '-v', f'{self._get_host_path(program_dir)}:/app/program', '-v', f'{self._get_host_path(self.output_dir)}:/app/output', + '-v', f'{self.data_dir}:/app/data', # Start in the right directory '-w', '/app/program', From 9ea0571cccae6a9e3c17446507eec6f50bf85ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Pav=C3=A3o?= Date: Wed, 17 May 2023 17:09:52 +0200 Subject: [PATCH 11/13] Add ":ro" for read-only access --- compute_worker/compute_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute_worker/compute_worker.py b/compute_worker/compute_worker.py index 93e709ece..ef83d1580 100644 --- a/compute_worker/compute_worker.py +++ b/compute_worker/compute_worker.py @@ -523,7 +523,7 @@ async def _run_program_directory(self, program_dir, kind, can_be_output=False): # Set the volumes '-v', f'{self._get_host_path(program_dir)}:/app/program', '-v', f'{self._get_host_path(self.output_dir)}:/app/output', - '-v', f'{self.data_dir}:/app/data', + '-v', f'{self.data_dir}:/app/data:ro', # Start in the right directory '-w', '/app/program', From 820395c453d25405e7628ea1cb0067f8dca929d6 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Wed, 17 May 2023 22:07:33 +0500 Subject: [PATCH 12/13] do not show empty leaderboard table when user is not loggedin --- src/static/riot/competitions/detail/_tabs.tag | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/static/riot/competitions/detail/_tabs.tag b/src/static/riot/competitions/detail/_tabs.tag index a56325567..3ef4279b3 100644 --- a/src/static/riot/competitions/detail/_tabs.tag +++ b/src/static/riot/competitions/detail/_tabs.tag @@ -218,7 +218,15 @@ -
+
+
+
+ Log In or + Sign Up to view this competition results. +
+
+
+

No Visible Leaderboards for this competition

+
From 10a102e462b66ce7dadedd6ecd13b5e0c092f5b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Pav=C3=A3o?= Date: Tue, 23 May 2023 17:52:21 +0200 Subject: [PATCH 13/13] Remove expiration error --- compute_worker/compute_worker.py | 1 - 1 file changed, 1 deletion(-) diff --git a/compute_worker/compute_worker.py b/compute_worker/compute_worker.py index ef83d1580..152ab2d0e 100644 --- a/compute_worker/compute_worker.py +++ b/compute_worker/compute_worker.py @@ -250,7 +250,6 @@ async def watch_detailed_results(self): if time.time() - start > expiration_seconds: timeout_error_message = f"Detailed results not written to after {expiration_seconds} seconds, exiting!" logger.warning(timeout_error_message) - raise SubmissionException(timeout_error_message) await asyncio.sleep(5) file_path = self.get_detailed_results_file_path() else: