Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Douglas Wightman <[email protected]>
  • Loading branch information
glowkey committed Dec 19, 2023
1 parent 427b4c1 commit 493d2fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
32 changes: 16 additions & 16 deletions pkg/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
)

const (
FlexKey = "f" // Monitor all GPUs if MIG is disabled or all GPU instances if MIG is enabled
MajorKey = "g" // Monitor top-level entities: GPUs or NvSwitches or CPUs
MinorKey = "i" // Monitor sub-level entities: GPU instances/NvLinks/CPUCores - GPUI cannot be specified if MIG is disabled
FlexKey = "f" // Monitor all GPUs if MIG is disabled or all GPU instances if MIG is enabled
MajorKey = "g" // Monitor top-level entities: GPUs or NvSwitches or CPUs
MinorKey = "i" // Monitor sub-level entities: GPU instances/NvLinks/CPUCores - GPUI cannot be specified if MIG is disabled
undefinedConfigMapData = "none"
deviceUsageTemplate = `Specify which devices dcgm-exporter monitors.
Possible values: {{.FlexKey}} or
Expand Down Expand Up @@ -55,7 +55,7 @@ var (
CLIRemoteHEInfo = "remote-hostengine-info"
CLIGPUDevices = "devices"
CLISwitchDevices = "switch-devices"
CLICpuDevices = "cpu-devices"
CLICpuDevices = "cpu-devices"
CLINoHostname = "no-hostname"
CLIUseFakeGpus = "fake-gpus"
CLIConfigMapData = "configmap-data"
Expand Down Expand Up @@ -113,13 +113,13 @@ func NewApp(buildVersion ...string) *cli.App {
Usage: "Use old 1.x namespace",
EnvVars: []string{"DCGM_EXPORTER_USE_OLD_NAMESPACE"},
},
&cli.StringFlag{
Name: CLICpuDevices,
Aliases: []string{"p"},
Value: FlexKey,
Usage: DeviceUsageStr,
EnvVars: []string{"DCGM_EXPORTER_CPU_DEVICES_STR"},
},
&cli.StringFlag{
Name: CLICpuDevices,
Aliases: []string{"p"},
Value: FlexKey,
Usage: DeviceUsageStr,
EnvVars: []string{"DCGM_EXPORTER_CPU_DEVICES_STR"},
},
&cli.StringFlag{
Name: CLIConfigMapData,
Aliases: []string{"m"},
Expand Down Expand Up @@ -352,10 +352,10 @@ func contextToConfig(c *cli.Context) (*dcgmexporter.Config, error) {
return nil, err
}

cOpt, err := parseDeviceOptions(c.String(CLICpuDevices))
if err != nil {
return nil, err
}
cOpt, err := parseDeviceOptions(c.String(CLICpuDevices))
if err != nil {
return nil, err
}

return &dcgmexporter.Config{
CollectorsFile: c.String(CLIFieldsFile),
Expand All @@ -369,7 +369,7 @@ func contextToConfig(c *cli.Context) (*dcgmexporter.Config, error) {
RemoteHEInfo: c.String(CLIRemoteHEInfo),
GPUDevices: gOpt,
SwitchDevices: sOpt,
CpuDevices: cOpt,
CpuDevices: cOpt,
NoHostname: c.Bool(CLINoHostname),
UseFakeGpus: c.Bool(CLIUseFakeGpus),
ConfigMapData: c.String(CLIConfigMapData),
Expand Down
18 changes: 8 additions & 10 deletions pkg/dcgmexporter/gpu_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ func testDCGMGPUCollector(t *testing.T, counters []Counter) (*DCGMCollector, fun
return nil
}

dcgmGetCpuHierarchy = func () (dcgm.CpuHierarchy_v1, error) {

dcgmGetCpuHierarchy = func() (dcgm.CpuHierarchy_v1, error) {
Cpu := dcgm.CpuHierarchyCpu_v1{
CpuId: 0,
CpuId: 0,
OwnedCores: []uint64{0},
}
hierarchy := dcgm.CpuHierarchy_v1{
Version: 0,
NumCpus: 1,
Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu},
Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu},
}

return hierarchy, nil
Expand Down Expand Up @@ -162,9 +161,9 @@ func testDCGMCpuCollector(t *testing.T, counters []Counter) (*DCGMCollector, fun

dcgmGetDeviceInfo = func(gpuId uint) (dcgm.Device, error) {
dev := dcgm.Device{
GPU: 0,
GPU: 0,
DCGMSupported: "No",
UUID: fmt.Sprintf("fake%d", gpuId),
UUID: fmt.Sprintf("fake%d", gpuId),
}

return dev, nil
Expand All @@ -181,16 +180,15 @@ func testDCGMCpuCollector(t *testing.T, counters []Counter) (*DCGMCollector, fun
return nil
}

dcgmGetCpuHierarchy = func () (dcgm.CpuHierarchy_v1, error) {

dcgmGetCpuHierarchy = func() (dcgm.CpuHierarchy_v1, error) {
Cpu := dcgm.CpuHierarchyCpu_v1{
CpuId: 0,
CpuId: 0,
OwnedCores: []uint64{0, 1},
}
hierarchy := dcgm.CpuHierarchy_v1{
Version: 0,
NumCpus: 1,
Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu},
Cpus: [dcgm.MAX_NUM_CPUS]dcgm.CpuHierarchyCpu_v1{Cpu},
}

return hierarchy, nil
Expand Down

0 comments on commit 493d2fa

Please sign in to comment.