Skip to content

Commit 66efce2

Browse files
committed
added entry commands
1 parent d3988ce commit 66efce2

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

src/service/jobs/job_utils.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,55 @@ import (
1111
"path/filepath"
1212
)
1313

14+
// AutodriverLimits limits to construct the autodriver cli args
15+
// more info - https://github.com/UB-CSE-IT/Autolab-Public-Documentation/blob/d6c2fb902d8cc0534794f20d6ef0bab871fe2602/The%20autograding%20process.md#running-the-job
16+
// todo verify assumptions
17+
type AutodriverLimits struct {
18+
// limits the number of processes that can be started
19+
ULimit int
20+
// sets the maximum file size that can be created in bytes I assume
21+
MaxFileSize int
22+
// limits the size of the output in bytes I assume
23+
MaxOutputSize int
24+
// sets the job timeout in seconds I assume
25+
Timeout int
26+
}
27+
28+
const (
29+
// DefaultLeviathanEntryCommand command for normal graders made for leviathan
30+
DefaultLeviathanEntryCommand = "cd autolab;"
31+
// DefaultTangoEntryCommand command for tango compatibility
32+
// sets up autograde cli
33+
DefaultTangoEntryCommand = "" +
34+
"chown autolab:autolab autolab; chmod 755 autolab;" + // mode perm since CopyToContainer switches to root and messes up perms
35+
"su autolab -c \"autodriver -u 100 -f 104857600 -t 20 -o 1024000 autolab > output/feedback 2>&1\"; " +
36+
"cat output/feedback;" // print stdout so that leviathan can parse
37+
)
38+
39+
var (
40+
// DefaultAutoDriverLimits limits taken from https://github.com/UB-CSE-IT/Autolab-Public-Documentation/blob/d6c2fb902d8cc0534794f20d6ef0bab871fe2602/The%20autograding%20process.md#running-the-job
41+
DefaultAutoDriverLimits = AutodriverLimits{
42+
ULimit: 100,
43+
MaxFileSize: 104857600,
44+
Timeout: 20,
45+
MaxOutputSize: 1024000,
46+
}
47+
)
48+
49+
// builds the autodriver command for tango compatibility
50+
// defaults to DefaultAutoDriverLimits, if limits is nil
51+
func createTangoEntryCommand(limits *AutodriverLimits) string {
52+
if limits == nil {
53+
limits = &DefaultAutoDriverLimits
54+
}
55+
return fmt.Sprintf(""+
56+
"chown autolab:autolab autolab; chmod 755 autolab;"+ // mode perm since CopyToContainer switches to root and messes up perms
57+
"su autolab -c \"autodriver -u %d -f %d -t %d -o %d autolab > output/feedback 2>&1\";"+
58+
"cat output/feedback;", // print stdout so that leviathan can parse
59+
limits.ULimit, limits.MaxFileSize, limits.Timeout, limits.MaxOutputSize,
60+
)
61+
}
62+
1463
// HardLinkFolder creates hard links of all files from source folder to target folder
1564
// and maintains the original UID/GID
1665
func HardLinkFolder(sourceDir, targetDir string) error {

0 commit comments

Comments
 (0)