Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam DeHaan committed May 9, 2022
1 parent 22af432 commit 93c96ae
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pipeline/directed.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,18 @@ func (p *DirectedPipeline) Render() ([]byte, error) {
// Operators returns a slice of operators that make up the pipeline graph
func (p *DirectedPipeline) Operators() []operator.Operator {
operators := make([]operator.Operator, 0)
// If possible, return the list sorted. If for some strange reason
// an Unorderable error is returned, use the list without guaranteed order
if nodes, err := topo.Sort(p.Graph); err == nil {
for _, node := range nodes {
operators = append(operators, node.(OperatorNode).Operator())
}
} else {
nodes := p.Graph.Nodes()
for nodes.Next() {
operators = append(operators, nodes.Node().(OperatorNode).Operator())
}
return operators
}

// If for some unexpected reason an Unorderable error is returned,
// when using topo.Sort, return the list without ordering
nodes := p.Graph.Nodes()
for nodes.Next() {
operators = append(operators, nodes.Node().(OperatorNode).Operator())
}
return operators
}
Expand Down

0 comments on commit 93c96ae

Please sign in to comment.