Skip to content

Commit

Permalink
Merge pull request #264 from dres-dev/dev
Browse files Browse the repository at this point in the history
v0.8.1 bugfixes
  • Loading branch information
sauterl authored Jun 11, 2021
2 parents 378ed65 + a5c2f95 commit d78d715
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,12 @@ class ListSubmissionsPerTaskRunAdminHandler : AbstractCompetitionRunAdminRestHan
override fun doGet(ctx: Context): List<SubmissionInfo> {
val runId = runId(ctx)
val run = getRun(runId) ?: throw ErrorStatusException(404, "No such run was found: $runId", ctx)
val rac = runActionContext(ctx, run)


val taskId = ctx.pathParamMap().getOrElse("taskId") {
throw ErrorStatusException(404, "Parameter 'taskId' is missing!'", ctx)
}.UID()
return run.submissions(rac).filter { it.task?.description?.id?.equals(taskId) ?: false }.map { SubmissionInfo.withId(it) }
return run.allSubmissions.filter { it.task?.description?.id?.equals(taskId) ?: false }.map { SubmissionInfo.withId(it) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,47 @@ import dev.dres.data.model.submissions.aspects.TemporalSubmissionAspect
* @author Luca Rossetto
* @version 1.0.0
*/
data class SubmissionInfo(val id: String? = null, val team: String, val member: String, val status: SubmissionStatus, val timestamp: Long, val item: RestMediaItem? = null, val start: Long? = null, val end: Long? = null) {
constructor(submission: Submission) : this(submission.uid.string, submission.teamId.string, submission.memberId.string, submission.status, submission.timestamp, RestMediaItem.fromMediaItem(submission.item), null, null)
constructor(submission: TemporalSubmissionAspect) : this(submission.uid.string, submission.teamId.string, submission.memberId.string, submission.status, submission.timestamp, RestMediaItem.fromMediaItem(submission.item), submission.start, submission.end)
data class SubmissionInfo(
val id: String? = null,
val team: String,
val member: String,
val status: SubmissionStatus,
val timestamp: Long,
val item: RestMediaItem? = null,
val start: Long? = null,
val end: Long? = null
) {
constructor(submission: Submission) : this(
submission.uid.string,
submission.teamId.string,
submission.memberId.string,
submission.status,
submission.timestamp,
RestMediaItem.fromMediaItem(submission.item),
if (submission is TemporalSubmissionAspect) submission.start else null,
if (submission is TemporalSubmissionAspect) submission.end else null
)


companion object {
fun blind(submission: Submission): SubmissionInfo = SubmissionInfo(null, submission.teamId.string, submission.memberId.string, submission.status, submission.timestamp)
fun withId(submission: Submission): SubmissionInfo = SubmissionInfo(submission.uid.string, submission.teamId.string, submission.memberId.string, submission.status, submission.timestamp, RestMediaItem.fromMediaItem(submission.item))
fun blind(submission: Submission): SubmissionInfo = SubmissionInfo(
null,
submission.teamId.string,
submission.memberId.string,
submission.status,
submission.timestamp
)

fun withId(submission: Submission): SubmissionInfo = SubmissionInfo(
submission.uid.string,
submission.teamId.string,
submission.memberId.string,
submission.status,
submission.timestamp,
RestMediaItem.fromMediaItem(submission.item),
if (submission is TemporalSubmissionAspect) submission.start else null,
if (submission is TemporalSubmissionAspect) submission.end else null
)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class CompetitionRunSerializer(private val competitionSerializer: CompetitionSer
for (j in 0 until input.readInt()) {
taskRun.submissions.add(SubmissionSerializer.deserialize(input,available))
}
(run.tasks as MutableList<InteractiveSynchronousCompetition.Task>).add(taskRun)
}
run
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ class InteractiveSynchronousRunManager(val run: InteractiveSynchronousCompetitio
* @return True on success, false otherwise.
*/
override fun updateSubmission(context: RunActionContext, submissionId: UID, submissionStatus: SubmissionStatus): Boolean = this.stateLock.read {
/* Sanity check. TODO: Do we indeed only want to be able to update submissions for the current task? */
val found = this.submissions(context).find { it.uid == submissionId} ?: return false
/* Sanity check. */
val found = this.allSubmissions.find { it.uid == submissionId} ?: return false

/* Actual update - currently, only status update is allowed */
if (found.status != submissionStatus) {
Expand All @@ -479,6 +479,14 @@ class InteractiveSynchronousRunManager(val run: InteractiveSynchronousCompetitio
/* Enqueue submission for post-processing. */
this.scoresUpdatable.enqueue(Pair(found.task!!, found))

if (submissionStatus == SubmissionStatus.INDETERMINATE) {
found.task?.validator?.let{
if (it is JudgementValidator){
it.validate(found)
}
}
}

/* Enqueue WS message for sending */
this.messageQueueUpdatable.enqueue(ServerMessage(this.id.string, ServerMessageType.TASK_UPDATED))

Expand Down
13 changes: 9 additions & 4 deletions backend/src/main/kotlin/dev/dres/run/RunExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import java.util.concurrent.Executors
import java.util.concurrent.Future
import java.util.concurrent.locks.StampedLock
import java.util.function.Consumer
import kotlin.collections.HashMap
import kotlin.collections.HashSet

/**
* The execution environment for [RunManager]s
Expand Down Expand Up @@ -74,8 +72,15 @@ object RunExecutor : Consumer<WsHandler> {
this.runs = runs
this.runs.filter { !it.hasEnded }.forEach { //TODO needs more distinction
val run = when(it) {
is InteractiveSynchronousCompetition -> InteractiveSynchronousRunManager(it)
is NonInteractiveCompetition -> NonInteractiveRunManager(it)
is InteractiveSynchronousCompetition -> {
it.tasks.forEach { t ->
t.submissions.forEach { s -> s.task = t }
}
InteractiveSynchronousRunManager(it)
}
is NonInteractiveCompetition -> {
NonInteractiveRunManager(it)
}
else -> throw NotImplementedError("No matching run manager found for $it")
}
this.schedule(run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.collections.HashMap
import kotlin.concurrent.read
import kotlin.concurrent.write

Expand Down Expand Up @@ -85,6 +84,12 @@ open class BasicJudgementValidator(knownCorrectRanges: Collection<ItemRange> = e
* @return [SubmissionStatus] of the [Submission]
*/
override fun validate(submission: Submission) = updateLock.read {

//only validate submissions which are not already validated
if (submission.status != SubmissionStatus.INDETERMINATE){
return@read
}

//check cache first
val cachedStatus = this.cache[ItemRange(submission)]
if (cachedStatus != null) {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/kotlin/dev/dres/utilities/FFmpegUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ object FFmpegUtil {

val input = File(File(collectionBasePath), description.item.location).toPath()
val output = File(cacheLocation, description.cacheItemName()).toPath()
val range = TimeUtil.toMilliseconds(description.temporalRange)
val range = TimeUtil.toMilliseconds(description.temporalRange, description.item.fps)

extractSegment(input, "${range.first / 1000}", "${range.second / 1000}", output)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</td>
</ng-container>
<!-- TEAM COL -->
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef>Type</th>
<ng-container matColumnDef="team">
<th mat-header-cell *matHeaderCellDef>Team</th>
<td mat-cell *matCellDef="let row">{{row.team}}</td>
</ng-container>
<!-- STATUS COL -->
Expand All @@ -46,6 +46,16 @@
<th mat-header-cell *matHeaderCellDef>Media Item</th>
<td mat-cell *matCellDef="let row">{{row.item != null ? row?.item?.name +" ("+row?.item?.type+")": "N/A"}}</td>
</ng-container>
<!-- START COL -->
<ng-container matColumnDef="start">
<th mat-header-cell *matHeaderCellDef>Start</th>
<td mat-cell *matCellDef="let row">{{row.start != null ? ((row.start / 1000) | formatTime) : "N/A"}}</td>
</ng-container>
<!-- END COL -->
<ng-container matColumnDef="end">
<th mat-header-cell *matHeaderCellDef>End</th>
<td mat-cell *matCellDef="let row">{{row.end != null ? ((row.end / 1000) | formatTime) : "N/A"}}</td>
</ng-container>
<!-- ACTION COL -->
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>Actions</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class RunAdminSubmissionsListComponent implements AfterViewInit, OnDestro
/**
* The displayed columns
*/
displayColumns = ['id', 'timestamp', 'status', 'item', 'actions'];
displayColumns = ['id', 'timestamp', 'team', 'item', 'start', 'end', 'status', 'actions'];

submissions: SubmissionInfo[] = [];

Expand Down

0 comments on commit d78d715

Please sign in to comment.