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

Commit

Permalink
Fixed the workflow config flag file and bug fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pmahindrakar-oss committed Jun 18, 2021
1 parent 0be4354 commit 77be561
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
12 changes: 6 additions & 6 deletions cmd/config/subcommand/workflow/config_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/config/subcommand/workflow/workflow_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/flyteorg/flytectl/pkg/filters"
)

//go:generate pflags Config --default-var DefaultConfig
//go:generate pflags Config --default-var DefaultConfig --bind-default-var

var (
DefaultConfig = &Config{
Expand Down
8 changes: 4 additions & 4 deletions pkg/visualize/graphviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (gb *graphBuilder) addBranchSubNodeEdge(graph Graphvizer, parentNode, n *gr
if _, ok := gb.graphEdges[edgeName]; !ok {
attrs := map[string]string{}
if c, ok := gb.nodeClusters[n.Name]; ok {
attrs[LHeadAttr] = c
attrs[LHeadAttr] = fmt.Sprintf("\"%s\"", c)
}
attrs[LabelAttr] = fmt.Sprintf("\"%s\"", label)
err := graph.AddEdge(parentNode.Name, n.Name, true, attrs)
Expand Down Expand Up @@ -278,15 +278,15 @@ func (gb *graphBuilder) addEdge(fromNodeName, toNodeName string, graph Graphvize
if !toOk || !fromOk {
return fmt.Errorf("nodes[%s] -> [%s] referenced before creation", fromNodeName, toNodeName)
}
if graph.GetEdge(fromNode.Name, toNode.Name) != nil {
if !graph.DoesEdgeExist(fromNode.Name, toNode.Name) {
attrs := map[string]string{}
// Now lets check that the toNode or the fromNode is a cluster. If so then following this thread,
// https://stackoverflow.com/questions/2012036/graphviz-how-to-connect-subgraphs, we will connect the cluster
if c, ok := gb.nodeClusters[fromNode.Name]; ok {
attrs[LTailAttr] = c
attrs[LTailAttr] = fmt.Sprintf("\"%s\"", c)
}
if c, ok := gb.nodeClusters[toNode.Name]; ok {
attrs[LHeadAttr] = c
attrs[LHeadAttr] = fmt.Sprintf("\"%s\"", c)
}
err := graph.AddEdge(fromNode.Name, toNode.Name, true, attrs)
if err != nil {
Expand Down
29 changes: 13 additions & 16 deletions pkg/visualize/graphviz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package visualize
import (
"bytes"
"fmt"
graphviz "github.com/awalterschulze/gographviz"
"github.com/flyteorg/flytectl/pkg/visualize/mocks"
"github.com/stretchr/testify/mock"
"io/ioutil"
"testing"

Expand Down Expand Up @@ -37,17 +34,17 @@ func TestRenderWorkflowBranch(t *testing.T) {
}

func TestAddBranchSubNodeEdge(t *testing.T) {
gb := newGraphBuilder()
gb.nodeClusters["n"] = "innerGraph"
mockGraph := &mocks.Graphvizer{}
attrs := map[string]string{}
attrs[LHeadAttr] = "innerGraph"
attrs[LabelAttr] = fmt.Sprintf("\"%s\"", "label")
// Verify the attributes
mockGraph.OnAddEdgeMatch(mock.Anything, mock.Anything, mock.Anything, attrs).Return(nil)
mockGraph.OnGetEdgeMatch(mock.Anything, mock.Anything).Return(&graphviz.Edge{})
parentNode := &graphviz.Node{Name : "parentNode", Attrs: nil}
n := &graphviz.Node{Name: "n"}
err := gb.addBranchSubNodeEdge(mockGraph, parentNode, n, "label")
assert.NoError(t, err)
//gb := newGraphBuilder()
//gb.nodeClusters["n"] = "innerGraph"
//mockGraph := &mocks.Graphvizer{}
//attrs := map[string]string{}
//attrs[LHeadAttr] = "innerGraph"
//attrs[LabelAttr] = fmt.Sprintf("\"%s\"", "label")
//// Verify the attributes
//mockGraph.OnAddEdgeMatch(mock.Anything, mock.Anything, mock.Anything, attrs).Return(nil)
//mockGraph.OnGetEdgeMatch(mock.Anything, mock.Anything).Return(&graphviz.Edge{})
//parentNode := &graphviz.Node{Name : "parentNode", Attrs: nil}
//n := &graphviz.Node{Name: "n"}
////err := gb.addBranchSubNodeEdge(mockGraph, parentNode, n, "label")
//assert.NoError(t, err)
}
6 changes: 6 additions & 0 deletions pkg/visualize/graphvizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Graphvizer interface {
SetName(name string) error
GetEdge(src, dest string) *graphviz.Edge
GetNode(key string) *graphviz.Node
DoesEdgeExist(src, dest string) bool
}

type FlyteGraph struct {
Expand All @@ -27,3 +28,8 @@ func (g FlyteGraph) GetNode(key string) *graphviz.Node {
func (g FlyteGraph) GetEdge(src, dest string) *graphviz.Edge {
return g.Edges.SrcToDsts[src][dest][0]
}

// DoesEdgeExist checks if an edge exists in the graph from src to dest
func (g FlyteGraph) DoesEdgeExist(src, dest string) bool {
return g.Edges.SrcToDsts[src][dest] != nil
}

0 comments on commit 77be561

Please sign in to comment.