Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require metadata on all topology #26

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/slurm.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Then run the topograph service as normal.

You must then start the toposim service as such, setting the path to the test model that you want to use in simulation:
```bash
/usr/local/bin/topograph -m /usr/local/bin/tests/models/<cluster-model>.yaml
/usr/local/bin/toposim -m /usr/local/bin/tests/models/<cluster-model>.yaml
```

You can then verify the topology results via simulation by querying topograph, and specifying the test model path as a parameter to the provider.
Expand Down
2 changes: 2 additions & 0 deletions pkg/engines/k8s/labeler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/NVIDIA/topograph/pkg/topology"
"github.com/NVIDIA/topograph/pkg/translate"
)

Expand All @@ -40,6 +41,7 @@ func (l *testLabeler) AddNodeLabels(_ context.Context, nodeName string, labels m

func TestApplyNodeLabels(t *testing.T) {
root, _ := translate.GetTreeTestSet(true)
require.Equal(t, root.Metadata[topology.KeyPlugin], topology.TopologyTree)
labeler := &testLabeler{data: make(map[string]map[string]string)}
data := map[string]map[string]string{
"Node201": {"topology.kubernetes.io/network-level-1": "S2", "topology.kubernetes.io/network-level-2": "S1"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/engines/slurm/slurm.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func GenerateOutputParams(ctx context.Context, tree *topology.Vertex, params *Pa
plugin = tree.Metadata[topology.KeyPlugin]
}
if len(plugin) == 0 {
plugin = topology.ValTopologyTree
plugin = topology.TopologyTree
}
if _, err := buf.WriteString(fmt.Sprintf(TopologyHeader, plugin)); err != nil {
return nil, err
Expand Down
11 changes: 8 additions & 3 deletions pkg/engines/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package test
import (
"context"
"errors"
"fmt"

"github.com/NVIDIA/topograph/internal/config"
"github.com/NVIDIA/topograph/pkg/engines"
Expand Down Expand Up @@ -59,10 +60,14 @@ func (eng *TestEngine) GenerateOutput(ctx context.Context, tree *topology.Vertex
}

if len(tree.Metadata) == 0 {
tree.Metadata = make(map[string]string)
return nil, fmt.Errorf("metadata for test engine not set")
}

tree.Metadata[topology.KeyPlugin] = p.Plugin
tree.Metadata[topology.KeyBlockSizes] = p.BlockSizes
if len(p.Plugin) != 0 {
tree.Metadata[topology.KeyPlugin] = p.Plugin
}
if len(p.BlockSizes) != 0 {
tree.Metadata[topology.KeyBlockSizes] = p.BlockSizes
}
return slurm.GenerateOutputParams(ctx, tree, &p)
}
9 changes: 8 additions & 1 deletion pkg/ib/ib.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ func GenerateTopologyConfig(data []byte) (*topology.Vertex, error) {
}
seen = make(map[int]map[string]*Switch)
root.simplify(root.getHeight())
return root.toGraph()
rootNode, err := root.toGraph()
if err != nil {
henryh2 marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}
rootNode.Metadata = map[string]string{
topology.KeyPlugin: topology.TopologyTree,
}
return rootNode, nil
}

func (sw *Switch) toGraph() (*topology.Vertex, error) {
Expand Down
20 changes: 13 additions & 7 deletions pkg/models/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ func getNetworkLayers(name string, swmap map[string]string) ([]string, error) {
}
}

func (model *Model) ToTree() (*topology.Vertex, map[string]string) {
func (model *Model) ToGraph() (*topology.Vertex, map[string]string) {
instance2node := make(map[string]string)
nodeVertexMap := make(map[string]*topology.Vertex)
swVertexMap := make(map[string]*topology.Vertex)
swRootMap := make(map[string]bool)
blockVertexMap := make(map[string]*topology.Vertex)
var block_topology bool = false

// Create all the vertices for each node
for k, v := range model.Nodes {
Expand All @@ -165,6 +166,9 @@ func (model *Model) ToTree() (*topology.Vertex, map[string]string) {
for _, node := range cb.Nodes {
blockVertexMap[cb.Name].Vertices[node] = nodeVertexMap[node]
}
if len(cb.NVLink) != 0 {
block_topology = true
}
}

// Connect all the switches to their sub-switches and sub-nodes
Expand Down Expand Up @@ -196,11 +200,13 @@ func (model *Model) ToTree() (*topology.Vertex, map[string]string) {
for k, v := range blockVertexMap {
blockRoot.Vertices[k] = v
}
root := &topology.Vertex{
Vertices: map[string]*topology.Vertex{
topology.ValTopologyBlock: blockRoot,
topology.ValTopologyTree: treeRoot,
},
if block_topology {
root := &topology.Vertex{
Vertices: map[string]*topology.Vertex{topology.TopologyBlock: blockRoot, topology.TopologyTree: treeRoot},
Metadata: map[string]string{topology.KeyPlugin: topology.TopologyBlock},
}
return root, instance2node
}
return root, instance2node
treeRoot.Metadata = map[string]string{topology.KeyPlugin: topology.TopologyTree}
return treeRoot, instance2node
}
Loading
Loading