Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compute_worker/compute_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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',
Expand Down
13 changes: 12 additions & 1 deletion src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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'])
Expand All @@ -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']:

Expand Down
26 changes: 24 additions & 2 deletions src/static/riot/competitions/detail/_tabs.tag
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,15 @@
<loader></loader>
</div>
<!-- Tab Content !-->
<div show="{!loading}">
<div class="row" if="{!CODALAB.state.user.logged_in}">
<div class="column">
<div class="ui yellow message">
<a href="{URLS.LOGIN}?next={location.pathname}">Log In</a> or
<a href="{URLS.SIGNUP}" target="_blank">Sign Up</a> to view this competition results.
</div>
</div>
</div>
<div if="{CODALAB.state.user.logged_in}" show="{!loading}">
<div class="ui button-container inline">
<div class="ui button {active: selected_phase_index == phase.id}"
each="{ phase in competition.phases }"
Expand All @@ -244,6 +252,7 @@
<div show="{!loading && _.isEmpty(competition.leaderboards)}">
<div class="center aligned"><h2>No Visible Leaderboards for this competition</h2></div>
</div>

</div>
</div>

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
8 changes: 6 additions & 2 deletions src/static/riot/competitions/detail/leaderboards.tag
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
</tr>
<tr class="task-row">
<th>Task:</th>
<th></th>
<th colspan=3></th>
<th each="{ task in filtered_tasks }" class="center aligned" colspan="{ task.colWidth }">{ task.name }</th>
<th if="{enable_detailed_results}"></th>
</tr>
<tr>
<th class="center aligned">#</th>
<th>Participant</th>
<th class="center aligned" each="{ column in filtered_columns }" colspan="1">{column.title}</th>
<th>Entries</th>
<th>Date of last entry</th>
<th each="{ column in filtered_columns }" colspan="1">{column.title}</th>
<th if="{enable_detailed_results}">Detailed Results</th>
</tr>
</thead>
Expand All @@ -55,6 +57,8 @@
<virtual if="{index + 1 > 5}">{index + 1}</virtual>
</td>
<td if="{submission.organization === null}"><a href="{submission.slug_url}">{ submission.owner }</a></td>
<td>{submission.num_entries}</td>
<td>{submission.last_entry_date}</td>
<td if="{submission.organization !== null}"><a href="{submission.organization.url}">{ submission.organization.name }</a></td>
<td each="{ column in filtered_columns }">{ get_score(column, submission) } </td>
<td if="{enable_detailed_results}"><a href="detailed_results/{submission.id}" target="_blank">Show detailed results</a></td>
Expand Down
13 changes: 12 additions & 1 deletion src/static/riot/competitions/detail/submission_manager.tag
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<th if="{ opts.admin }">Owner</th>
<th if="{ opts.admin }">Phase</th>
<th>Date</th>
<th class="right aligned">Status</th>
<th>Status</th>
<th>Score</th>
<th class="center aligned {admin-action-column: opts.admin, action-column: !opts.admin}">Actions</th>
</tr>
</thead>
Expand Down Expand Up @@ -94,6 +95,7 @@
<i if="{submission.status === 'Failed'}" class="failed question circle icon"></i>
</sup>
</td>
<td>{get_score(submission)}</td>
<td class="center aligned">
<virtual if="{ opts.admin }">
<span data-tooltip="Rerun Submission"
Expand Down Expand Up @@ -382,6 +384,15 @@
}
}

self.get_score = function (submission) {
try{
return parseFloat(submission.scores[0].score).toFixed(2)

} catch {
return ""
}
}

self.toggle_submission_is_public = function (submission) {
event.stopPropagation()
let message = submission.is_public
Expand Down
4 changes: 2 additions & 2 deletions src/tests/functional/test_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ 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
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)
Expand Down