Step 4: Pre-Flight¶
Purpose¶
The Pre-Flight step runs initial validation checks on the submission and prepares the code for grading. It acts as the final "gatekeeper" that ensures both the file structure is correct and the code is in an executable state (e.g., compiled).
This step performs three main functions:
1. Asset injection: Injecting grader-owned static files (datasets, test fixtures) from S3 into the sandbox.
2. Required files check: Ensuring all mandatory files defined in the assignment configuration exist.
3. Setup commands execution: Running compilation or initialization scripts (e.g., javac, npm install, gcc) inside the sandbox.
How It Works¶
The step execution follows these logic gates:
-
Asset Injection: If the
setup_configcontains anassetslist, thePreFlightServiceresolves each asset via theAssetSourceResolver. Assets are fetched from S3 and injected into the container's/tmpdirectory using a secure Base64-encodedexec_runmethod (fully compatible with gVisor). -
Required Files Check: It compares the files in the submission against the list provided in the
required_filessection of thesetup_configfor the submission's language. -
Setup Commands Execution: If the
setup_configcontainssetup_commands, they are executed sequentially within the sandbox created in Step 3.- Stop on Failure: If any command fails (non-zero or invalid response), the step stops immediately and fails the entire pre-flight check. Subsequent commands are not executed.
- Setup commands are orchestrated via the
SandboxService.
If both checks pass, the step succeeds and the pipeline continues to Step 5: Grade.
Dependencies¶
| Step | What It Needs |
|---|---|
| Sandbox | Requires the SandboxContainer to execute setup commands |
Input¶
| Source | Data |
|---|---|
| Constructor | setup_config: dict — language-keyed setup configuration |
| Pipeline | StepName.SANDBOX → SandboxContainer |
| Pipeline | pipeline_exec.submission → submission files and language |
Output¶
| Field | Type | Description |
|---|---|---|
data |
None |
This step does not produce data for downstream steps |
status |
StepStatus.SUCCESS |
Required files exist and all setup commands passed |
Language-Specific Configuration¶
The setup_config defines mandatory files and commands for each language:
{
"python": {
"required_files": ["main.py"],
"setup_commands": []
},
"java": {
"required_files": ["Calculator.java"],
"setup_commands": ["javac Calculator.java"]
}
}
Failure Scenarios¶
- Missing required file →
StepStatus.FAILlisting missing files. - Setup Command Failed →
StepStatus.FAILwith the command's exit code, stdout, and stderr. - No Sandbox →
StepStatus.FAILif setup commands exist but no sandbox was provided.
Next Step¶
After verification and compilation, the pipeline proceeds to Step 5: Grade to execute the actual test functions.
Source¶
autograder/steps/pre_flight_step.py → PreFlightStep
autograder/services/pre_flight_service.py → PreFlightService
autograder/services/sandbox_service.py → SandboxService