Skip to content

Commit

Permalink
Add more docstrings in FileCombinator
Browse files Browse the repository at this point in the history
  • Loading branch information
samuell committed May 21, 2019
1 parent 3fd900e commit 93f7f92
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions components/file_combinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import (
"github.com/scipipe/scipipe"
)

// FileCombinator takes a set of input streams of FileIPs, and returns the same
// number of output streams, where the FileIPs are multiplied so as to
// guarantee that all combinations of the ips in the input streams are created.
// Input ports and corresponding out-ports (with the same port names) are
// created on demand, by accessing them with the p.In(PORTNAME) method.
// The corresponding out-porta can then be accessed with the same port name
// with p.Out(PORTNAME)
type FileCombinator struct {
scipipe.BaseProcess
globPatterns []string
Expand All @@ -18,10 +25,8 @@ func NewFileCombinator(wf *scipipe.Workflow, name string) *FileCombinator {
return p
}

// Out returns the outport
func (p *FileCombinator) Out(pName string) *scipipe.OutPort { return p.OutPort(pName) }

// In returns the in-port
// In returns the in-port with name pName. If it does not exist, it will create
// that in-port, and a corresponding out-port with the same port name.
func (p *FileCombinator) In(pName string) *scipipe.InPort {
if _, ok := p.InPorts()[pName]; !ok {
p.InitInPort(p, pName)
Expand All @@ -33,6 +38,9 @@ func (p *FileCombinator) In(pName string) *scipipe.InPort {
return p.InPort(pName)
}

// Out returns the outport
func (p *FileCombinator) Out(pName string) *scipipe.OutPort { return p.OutPort(pName) }

// Run runs the FileCombinator process
func (p *FileCombinator) Run() {
defer p.CloseAllOutPorts()
Expand Down Expand Up @@ -62,6 +70,13 @@ func (p *FileCombinator) Run() {
}
}

// combine is a recursive method that creates combinations of all the IPs in the input IP arrays, such that:
// [a.txt b.txt]
// [1,txt 2.txt 3.txt]
// ... will be turned into:
// [a.txt a.txt a.txt b.txt b.txt b.txt]
// [1.txt 2.txt 3.txt 1.txt 2.txt 3.txt]
// as an example.
func (p *FileCombinator) combine(inIPs map[string][]*scipipe.FileIP, keys []string) map[string][]*scipipe.FileIP {
if len(inIPs) <= 1 {
return inIPs
Expand Down

0 comments on commit 93f7f92

Please sign in to comment.