Skip to content

Commit

Permalink
Use printMetadata also for judging metadata
Browse files Browse the repository at this point in the history
Also fix some small inconsistencies and typo's:
- rename title text 'runtime' to 'exit-status'
- replace non-existing icon fa-exitcode
- tiny tweaks to add missing spaces in output
  • Loading branch information
eldering committed Nov 26, 2023
1 parent f5e00ba commit 206674f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
9 changes: 1 addition & 8 deletions webapp/src/Controller/Jury/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,8 @@ public function viewAction(
}
$runs[] = $runResult[0];
unset($runResult[0]);
if (empty($runResult['metadata'])) {
$runResult['cpu_time'] = $firstJudgingRun === null ? 'n/a' : $firstJudgingRun->getRuntime();
} else {
if (!empty($runResult['metadata'])) {
$metadata = $this->dj->parseMetadata($runResult['metadata']);
$runResult['cpu_time'] = $metadata['cpu-time'];
$runResult['wall_time'] = $metadata['wall-time'];
$runResult['memory'] = Utils::printsize((int)$metadata['memory-bytes'], 2);
$runResult['exitcode'] = $metadata['exitcode'];
$runResult['signal'] = $metadata['signal'] ?? -1;
$runResult['output_limit'] = $metadata['output-truncated'];
}
$runResult['terminated'] = preg_match('/timelimit exceeded.*hard (wall|cpu) time/',
Expand Down
18 changes: 8 additions & 10 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1066,16 +1066,14 @@ public function printMetadata(?string $metadata): string
}
$metadata = $this->dj->parseMetadata($metadata);
return '<span style="display:inline; margin-left: 5px;">'
. '<i class="fas fa-stopwatch" title="runtime"></i>'
. $metadata['cpu-time'] . 's'
. ' CPU, '
. $metadata['wall-time'] . 's'
. ' wall time, '
. '<i class="fas fa-memory" title="RAM"></i>'
. Utils::printsize((int)($metadata['memory-bytes']))
. ', '
. '<i class="fas fa-exitcode" title="runtime"></i>'
. 'exit-code: ' . $metadata['exitcode'];
. '<i class="fas fa-stopwatch" title="runtime"></i> '
. $metadata['cpu-time'] . 's CPU, '
. $metadata['wall-time'] . 's wall, '
. '<i class="fas fa-memory" title="RAM"></i> '
. Utils::printsize((int)($metadata['memory-bytes'])) . ', '
. '<i class="far fa-question-circle" title="exit-status"></i> '
. 'exit-code: ' . $metadata['exitcode']
. (($metadata['signal'] ?? -1) > 0 ? ' signal: ' . $metadata['signal'] : '');
}

public function printWarningContent(ExternalSourceWarning $warning): string
Expand Down
26 changes: 8 additions & 18 deletions webapp/templates/jury/submission.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -712,24 +712,14 @@
</span>
</div>
<div class="card-body">
{% if run.firstJudgingRun is not null and runsOutput[runIdx].cpu_time %}
<span style="display:inline; margin-left: 5px;">
<i class="fas fa-stopwatch" title="runtime"></i>
{{ runsOutput[runIdx].cpu_time }}s
CPU{% if runsOutput[runIdx].metadata is not null %},
{{ runsOutput[runIdx].wall_time }}s wall,
<i class="fas fa-memory" title="RAM"></i>
{{ runsOutput[runIdx].memory }},
<i class="far fa-question-circle" title="exit-code"></i>
exit code:
{{ runsOutput[runIdx].exitcode }}{% if runsOutput[runIdx].signal > 0 %},
signal: {{ runsOutput[runIdx].signal }}
{% endif %}
<button class="btn btn-sm btn-outline-secondary" data-bs-toggle="collapse"
data-bs-target="#collapseExample-{{ runIdx }}"
aria-expanded="false">
show complete metadata
</button>
{% if run.firstJudgingRun is not null %}
{{ runsOutput[runIdx].metadata | printMetadata }}
<button class="btn btn-sm btn-outline-secondary" data-bs-toggle="collapse"
data-bs-target="#collapseExample-{{ runIdx }}"
aria-expanded="false">
show complete metadata
</button>
{% if runsOutput[runIdx].metadata is not null %}
{% if runsOutput[runIdx].output_limit %}
<div class="alert alert-warning">
The submission output (<code>{{ runsOutput[runIdx].output_limit }}</code>) was
Expand Down

0 comments on commit 206674f

Please sign in to comment.