-
Notifications
You must be signed in to change notification settings - Fork 72
/
params.go
64 lines (51 loc) · 1.42 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"runtime"
sci "github.com/scipipe/scipipe"
)
func main() {
runtime.GOMAXPROCS(4)
wf := sci.NewWorkflow("test_wf", 4)
cmb := NewCombinatoricsGen(wf, "combgen")
// An abc file printer
abc := wf.NewProc("abc", "echo {p:a} {p:b} {p:c} > {o:out}; sleep 1")
abc.Spawn = true
abc.SetOut("out", "{p:a}_{p:b}_{p:c}.txt")
// A printer task
prt := wf.NewProc("printer", "cat {i:in} >> log.txt")
prt.Spawn = false
// Connection info
abc.InParamPort("a").From(cmb.A())
abc.InParamPort("b").From(cmb.B())
abc.InParamPort("c").From(cmb.C())
prt.In("in").From(abc.Out("out"))
wf.Run()
}
type CombinatoricsGen struct {
sci.BaseProcess
}
func NewCombinatoricsGen(wf *sci.Workflow, name string) *CombinatoricsGen {
p := &CombinatoricsGen{
BaseProcess: sci.NewBaseProcess(wf, name),
}
p.InitOutParamPort(p, "a")
p.InitOutParamPort(p, "b")
p.InitOutParamPort(p, "c")
wf.AddProc(p)
return p
}
func (p *CombinatoricsGen) A() *sci.OutParamPort { return p.OutParamPort("a") }
func (p *CombinatoricsGen) B() *sci.OutParamPort { return p.OutParamPort("b") }
func (p *CombinatoricsGen) C() *sci.OutParamPort { return p.OutParamPort("c") }
func (p *CombinatoricsGen) Run() {
defer p.CloseAllOutPorts()
for _, a := range []string{"a1", "a2", "a3"} {
for _, b := range []string{"b1", "b2", "b3"} {
for _, c := range []string{"c1", "c2", "c3"} {
p.A().Send(a)
p.B().Send(b)
p.C().Send(c)
}
}
}
}