Runner

abstract class Runner(val stages: Pipeline, val context: Runner.Context) : Reporter, AutoCloseable, CoroutineScope, StateTraceable<Runner.ExecStateData, Unit>

A runner which can be used to execute a pipeline.

Parameters

context

Context stores the required paths for Runner to reach files from both the host and remote

Constructors

Link copied to clipboard
constructor(stages: Pipeline, context: Runner.Context)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
open class Context(val submissionId: String, val assignmentConfigId: Long, stageWaitDuration: Duration = Duration.ofMinutes(1), earlyReturnOnThrow: Boolean = false, val envContext: EnvContext) : PartialContext

Context captures paths and naming conventions of the various machines involved in the Runner Such that this could be dynamically crafted and injected to the Runner, independent of the pipeline

Link copied to clipboard
abstract class ExecStateData

The data associated with the execution state used by StateTraceable.

Link copied to clipboard
data class PipelineError(val stage: PipelineStage, val tr: Throwable)

Properties

Link copied to clipboard
Link copied to clipboard
private var _envLogPath: Path?
Link copied to clipboard
private var _graderLogPath: Path?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The current CloseableState of this runner.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The temporary directory relative to the virtualization environment created for file exchange between the grader and the virtualization environment.

Link copied to clipboard

The time taken to run execWithInput, or null if the method has not started or has not terminated.

Link copied to clipboard

The temporary directory relative to the grader environment created for file exchange between the grader and the virtualization environment.

Link copied to clipboard
Link copied to clipboard
protected val logger: Logger
Link copied to clipboard
private val memoReport: ReportT

Generates and memoizes ReportT from collected _reportUnits This should be a pure operation in that successive generations of the report yields the same result

Link copied to clipboard
private val outPaths: MountedPaths
Link copied to clipboard

List of all PipelineError, in order of appearance.

Link copied to clipboard

_reportUnits is to be updated across stages of a runner for appending reporting information

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun appendToFile(relativePath: String, content: String)

Appends content to a file relative to context.outPaths.hostRoot for exporting.

Link copied to clipboard
override fun close()
Link copied to clipboard
@MustBeInvokedByOverriders
protected open fun closeImpl()

Implementation for AutoCloseable.close.

Link copied to clipboard
fun compressFile(relativePath: String, compressorName: String, keepOriginal: Boolean = false): Path

Compresses a file relative to context.outPaths.hostRoot.

Link copied to clipboard
protected fun createLogDirectories()

Creates directories for exchanging files between the grader environment and the virtualization environment.

Link copied to clipboard
fun decompressFile(relativePath: String, keepOriginal: Boolean = false): Path

Decompresses a file relative to context.outPaths.hostRoot.

Link copied to clipboard
suspend fun execWithInput(input: Any): StageResult

Executes the pipeline using the given input as the input to the entire pipeline.

Link copied to clipboard
protected abstract suspend fun execWithInputImpl(input: Any): StageResult

Implementation for execWithInput.

Link copied to clipboard
Link copied to clipboard

Returns the generated ReportT

Link copied to clipboard

Generates ErrorUnit.PipelineErrorUnit.NonFatalError's based on a _pipelineErrs Intended to be used with pipelineErrs after successful pipeline execution

Link copied to clipboard
fun printErrors(logMethod: (String) -> Unit)
Link copied to clipboard
Link copied to clipboard
fun putError(pipelineError: Runner.PipelineError)

Records an error emitted by a pipeline stage.

Link copied to clipboard
Link copied to clipboard
fun readFromFile(relativePath: String): String
Link copied to clipboard
fun readLinesFromFile(relativePath: String): List<String>

readLinesFromFile reads files on reachable from context.outPaths.hostRoot and return the file content as lines for reporting readFromFile does the same as readLinesFromFile but returns a long string

Link copied to clipboard
protected fun removeLogDirectories()

Removes the directories created from createLogDirectories.

Link copied to clipboard
fun toDigestString(concreteClassName: Boolean = true): String

Returns a string representation of this Runner, simplified to only contain the assignment configuration and submission IDs.

Link copied to clipboard
fun writeToFile(relativePath: String, content: String)

writeToFile writes content to a file reachable from context.outPaths.hostRoot for exporting