diff --git a/compute_worker/compute_worker.py b/compute_worker/compute_worker.py index c8bef06d1..152ab2d0e 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 @@ -249,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: @@ -522,6 +522,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:ro', # Start in the right directory '-w', '/app/program', diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 4f6288da9..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') @@ -501,6 +500,16 @@ def get_leaderboard(self, request, pk): columns = [col for col in query['columns']] submissions_keys = {} for submission in query['submissions']: + + # 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 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') + 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 +520,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/_tabs.tag b/src/static/riot/competitions/detail/_tabs.tag index 719308664..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

+
@@ -328,7 +337,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 +375,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() diff --git a/src/static/riot/competitions/detail/leaderboards.tag b/src/static/riot/competitions/detail/leaderboards.tag index 6e476108f..d289060ef 100644 --- a/src/static/riot/competitions/detail/leaderboards.tag +++ b/src/static/riot/competitions/detail/leaderboards.tag @@ -28,14 +28,16 @@ Task: - + { task.name } # 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 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)}