Documentation
¶
Index ¶
Constants ¶
View Source
const ( MagicReplace = "<REPLACE>" MemoryReplace = "<MEMORY>" )
Variables ¶
View Source
var Langs = map[string]Language{ "c": { Extensions: []string{".c"}, Compiled: true, PrintableName: "C", InternalName: "c", MOSSName: "cc", CompileCommand: []string{"gcc", "-fuse-ld=mold", "-std=c11", "-O2", "-lm", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MagicReplace, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.c", CompiledName: "/box/output", SimilarLangs: []string{"c", "cpp", "cpp11", "cpp14", "cpp17", "cpp20"}, Mounts: []Directory{{In: "/etc"}}, }, "cpp11": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp11"}, Compiled: true, PrintableName: "C++11", InternalName: "cpp11", MOSSName: "cc", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++11", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MagicReplace, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", SimilarLangs: []string{"c", "cpp", "cpp11", "cpp14", "cpp17", "cpp20"}, Mounts: []Directory{{In: "/etc"}}, }, "cpp14": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp14"}, Compiled: true, PrintableName: "C++14", InternalName: "cpp14", MOSSName: "cc", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++14", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MagicReplace, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", SimilarLangs: []string{"c", "cpp", "cpp11", "cpp14", "cpp17", "cpp20"}, Mounts: []Directory{{In: "/etc"}}, }, "cpp17": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp17"}, Compiled: true, PrintableName: "C++17", InternalName: "cpp17", MOSSName: "cc", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++17", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MagicReplace, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", SimilarLangs: []string{"c", "cpp", "cpp11", "cpp14", "cpp17", "cpp20"}, Mounts: []Directory{{In: "/etc"}}, }, "cpp20": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp20"}, Compiled: true, PrintableName: "C++20", InternalName: "cpp20", MOSSName: "cc", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++20", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MagicReplace, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", SimilarLangs: []string{"c", "cpp", "cpp11", "cpp14", "cpp17", "cpp20"}, Mounts: []Directory{{In: "/etc"}}, }, "pascal": { Extensions: []string{".pas"}, Compiled: true, PrintableName: "Pascal", InternalName: "pascal", MOSSName: "pascal", CompileCommand: []string{"fpc", "-O2", "-XSst", "-Mobjfpc", "-vw", "-dKNOVA", "-dONLINE_JUDGE", MagicReplace, "-o/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.pas", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "golang": { Extensions: []string{".go"}, Compiled: true, PrintableName: "Go", InternalName: "golang", MOSSName: "ascii", CompileCommand: []string{"/usr/bin/go", "build", MagicReplace}, RunCommand: []string{"/box/main"}, SourceName: "/box/main.go", CompiledName: "/box/main", BuildEnv: map[string]string{"GOMAXPROCS": "1", "CGO_ENABLED": "0", "GOCACHE": "/go/cache", "GOPATH": "/box", "GO111MODULE": "off"}, RunEnv: map[string]string{"GOMAXPROCS": "1"}, Mounts: []Directory{{In: "/go", Opts: "tmp", Verbatim: true}}, }, "haskell": { Disabled: true, Extensions: []string{".hs", ".lhs"}, Compiled: true, PrintableName: "Haskell", InternalName: "haskell", MOSSName: "haskell", CompileCommand: []string{"ghc", "-o", "/box/output", MagicReplace}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.hs", CompiledName: "/box/output", }, "java": { Disabled: true, Extensions: []string{".java"}, Compiled: true, PrintableName: "Java", InternalName: "java", MOSSName: "java", CompileCommand: []string{"javac", MagicReplace}, RunCommand: []string{"java", "Main"}, SourceName: "/Main.java", CompiledName: "/Main.class", Mounts: []Directory{{In: "/etc"}}, }, "kotlin": { Extensions: []string{".kt"}, Compiled: true, PrintableName: "Kotlin", InternalName: "kotlin", MOSSName: "ascii", CompileCommand: []string{"kotlinc", MagicReplace, "-include-runtime", "-d", "output.jar"}, RunCommand: []string{"java", "-Xmx" + MemoryReplace + "K", "-DKNOVA", "-DONLINE_JUDGE", "-jar", "/box/output.jar"}, SourceName: "/box/main.kt", CompiledName: "/box/output.jar", Mounts: []Directory{{In: "/etc"}}, }, "python3": { Extensions: []string{".py", ".py3"}, Compiled: false, PrintableName: "Python 3", InternalName: "python3", MOSSName: "python", RunCommand: []string{"python3", "/box/main.py"}, SourceName: "/box/main.py", CompiledName: "/box/main.py", }, "outputOnly": { Extensions: []string{".output_only"}, Compiled: false, PrintableName: "Output Only", InternalName: "outputOnly", MOSSName: "ascii", RunCommand: []string{"cat", "/box/output"}, SourceName: "/box/output_src", CompiledName: "/box/output", }, }
NOTE: Last extension MUST be unique (for proper detection of submissions in problem archives)
Functions ¶
func GetLangByFilename ¶
func Initialize ¶
func Initialize() error
Initialize should be called after reading the flags, but before manager.New
Types ¶
type Box2Request ¶ added in v0.25.0
type Box2Request struct { // key - path, value - reference to bucket file InputBucketFiles map[string]*BucketFile // key - path, value - contents InputByteFiles map[string]*ByteFile // Command to run Command []string // Box run config RunConfig *RunConfig // File paths to return OutputByteFiles []string // key - path, value - file to save into (will have mode set to whatever is in the struct) OutputBucketFiles map[string]*BucketFile }
type Box2Response ¶ added in v0.25.0
type Box2Response struct { Stats *RunStats // Files specified in the Request and not present in the response were not found (did not exist) // key - path, value - contents ByteFiles map[string][]byte // key - path, value - reference to bucket file BucketFiles map[string]*BucketFile }
type BoxScheduler ¶
type BoxScheduler interface { SubRunner(ctx context.Context, numConc int64) (BoxScheduler, error) NumConcurrent() int64 RunBox2(ctx context.Context, req *Box2Request, memQuota int64) (*Box2Response, error) Close(context.Context) error }
type BucketFile ¶ added in v0.25.0
type Directory ¶
type Directory struct { In string `toml:"in"` Out string `toml:"out"` Opts string `toml:"opts"` Removes bool `toml:"removes"` // Verbatim doesn't set Out to In implicitly if it isn't set Verbatim bool `toml:"verbatim"` }
Directory represents a directory rule
type Language ¶
type Language struct { Disabled bool // Useful to categorize by file upload Extensions []string Compiled bool // SimilarLangs is used on resolution of grader files during evaluation // to decide which of the grader files to include for interactive problems SimilarLangs []string `toml:"compatible_langs"` PrintableName string InternalName string // Reference: http://moss.stanford.edu/general/scripts/mossnet MOSSName string CompileCommand []string `toml:"compile_command"` RunCommand []string `toml:"run_command"` BuildEnv map[string]string `toml:"build_env"` RunEnv map[string]string `toml:"run_env"` // Mounts represents all directories to be mounted Mounts []Directory `toml:"mounts"` SourceName string `toml:"source_name"` CompiledName string `toml:"compiled_name"` }
Language is the data available for a language
type RunConfig ¶
type RunConfig struct { StderrToStdout bool InputPath string // If OutputPath or StderrPath are empty strings, they should default // to "/dev/null" for security reasons. OutputPath string StderrPath string MemoryLimit int TimeLimit float64 WallTimeLimit float64 InheritEnv bool EnvToInherit []string EnvToSet map[string]string Directories []Directory }
type Sandbox ¶
type Sandbox interface { // ReadFile reads contents of path from sandbox and pipes them to the given writer ReadFile(path string, w io.Writer) error // SaveFile reads contents of path from sandbox and saves them in the given bucket by calling WriteFile SaveFile(path string, bucket Bucket, filename string, mode fs.FileMode) error WriteFile(path string, r io.Reader, mode fs.FileMode) error // RemoveFile(path string) error FileExists(path string) bool GetID() int MemoryQuota() int64 // if stdout == stderr, then it will act like exec.CombinedOutput() RunCommand(ctx context.Context, cmd []string, conf *RunConfig) (*RunStats, error) io.Closer }
Click to show internal directories.
Click to hide internal directories.