Commit d59ff3b
fix: correct grader path handling in ContainerGrader and entrypoint
ContainerGrader had two bugs affecting how grader files were located
inside the container at runtime:
1. Docker backend bind-mounted the grader problem directory at /grader,
overwriting the grader_support package that the base image copies
there. Fixed by binding at /graders instead and passing the
resulting absolute in-container path (/graders/<file>) to the
entrypoint.
2. Kubernetes backend set working_dir to the grader problem directory
(e.g. /graders/ps07/Robot/), preventing Python from finding the
grader_support package which lives at /grader/grader_support/.
Fixed by keeping working_dir=/grader (the base image WORKDIR) and
passing the absolute grader path in args instead of just the
basename.
entrypoint.py previously passed the full absolute path verbatim to
__import__(), which fails for paths containing slashes. It now detects
absolute paths, inserts the parent directory into sys.path, and uses
only the basename as the importable module name.
Also updates grader_support/README.md to document the correct layout
(/graders/ for course grader scripts, /grader/ for grader_support) and
the gradelib compatibility note for course teams migrating from
Python 2 graders.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 39d1d7b commit d59ff3b
3 files changed
Lines changed: 75 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
26 | 47 | | |
27 | 48 | | |
28 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
29 | 56 | | |
30 | | - | |
31 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
32 | 60 | | |
33 | | - | |
34 | | - | |
| 61 | + | |
35 | 62 | | |
36 | 63 | | |
37 | | - | |
| 64 | + | |
38 | 65 | | |
39 | 66 | | |
40 | 67 | | |
| |||
46 | 73 | | |
47 | 74 | | |
48 | 75 | | |
49 | | - | |
| 76 | + | |
50 | 77 | | |
51 | 78 | | |
52 | 79 | | |
| |||
59 | 86 | | |
60 | 87 | | |
61 | 88 | | |
| 89 | + | |
| 90 | + | |
62 | 91 | | |
63 | 92 | | |
64 | 93 | | |
| |||
67 | 96 | | |
68 | 97 | | |
69 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
| |||
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
59 | | - | |
| 71 | + | |
60 | 72 | | |
61 | 73 | | |
62 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| |||
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
173 | | - | |
174 | | - | |
| 178 | + | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| |||
238 | 243 | | |
239 | 244 | | |
240 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
246 | | - | |
| 256 | + | |
247 | 257 | | |
248 | 258 | | |
249 | | - | |
| 259 | + | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
| |||
0 commit comments