Documentation ¶
Overview ¶
Package workflow is for problem workflow manipulation.
Workflow Graph ¶
Workflow Graph is a directed acyclic graph (DAG) which describes how to perform a single testcase's judgement.
Each node of the graph represents a processor, with its input files and output files naming inbound and outbound respectively.
A _key node_ is specially treated by analyzer which means the main process of submission's testing.
A directed edge goes either from one of the outbounds of the source (node) to one of the inbounds of the destination (node), or from a field of a datagroup to one of the inbounds of the destination (node).
Datagroups is where all data files are given from.
Analyzer ¶
An analyzer examines up all nodes' execution result and all generated files to evaluate the whole process, and then returns a structured result.
Builder ¶
Builder provides a convenient way to create a workflow graph.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer interface {
Analyze(w Workflow, nodes map[string]RuntimeNode, fullscore float64) Result
}
Analyzer generates result of a workflow.
func LoadAnalyzer ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Build a workflow
Example ¶
package main import ( "log" "github.com/sshwy/yaoj-core/pkg/workflow" ) func main() { var b workflow.Builder b.SetNode("compile", "compiler", false) b.SetNode("run", "runner:stdio", true) b.SetNode("check", "checker:hcmp", false) b.AddInbound(workflow.Gsubm, "source", "compile", "source") b.AddInbound(workflow.Gstatic, "compilescript", "compile", "script") b.AddInbound(workflow.Gstatic, "limitation", "run", "limit") b.AddInbound(workflow.Gtests, "input", "run", "stdin") b.AddInbound(workflow.Gtests, "answer", "check", "ans") b.AddEdge("compile", "result", "run", "executable") b.AddEdge("run", "stdout", "check", "out") graph, err := b.WorkflowGraph() if err != nil { log.Print(err) } log.Print(string(graph.Serialize())) }
Output:
func (*Builder) AddInbound ¶
func (*Builder) WorkflowGraph ¶
func (r *Builder) WorkflowGraph() (*WorkflowGraph, error)
type DefaultAnalyzer ¶
type DefaultAnalyzer struct { }
func (DefaultAnalyzer) Analyze ¶
func (r DefaultAnalyzer) Analyze(w Workflow, nodes map[string]RuntimeNode, fullscore float64) Result
type Result ¶
type Result struct { ResultMeta // a list of file content to display File []ResultFileDisplay }
Result of a workflow, typically generated by Analyzer.
type ResultFileDisplay ¶
func FileDisplay ¶
func FileDisplay(path string, title string, len int) ResultFileDisplay
Try to display content of a text file with max-length limitation. It is well-processed if an executable file is provided.
type ResultMeta ¶
type RuntimeNode ¶
type Workflow ¶
type Workflow struct { *WorkflowGraph Analyzer }
workflow describes how to perform a single testcase's judgement
type WorkflowGraph ¶
type WorkflowGraph struct { // a node itself is just a processor Node map[string]Node Edge []Edge // inbound consists a series of data group. // Inbound: map[datagroup_name]*map[field]Bound Inbound map[Groupname]*map[string][]Inbound }
func (*WorkflowGraph) EdgeFrom ¶
func (r *WorkflowGraph) EdgeFrom(name string) []Edge
All edges starting from Node[nodeid]
func (*WorkflowGraph) EdgeTo ¶
func (r *WorkflowGraph) EdgeTo(name string) []Edge
All edges ending at Node[nodeid]