From b6be911eaa1a18f92b395ea0e4c31ab1a928c143 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 18 Apr 2024 15:01:20 +0200 Subject: [PATCH] Replace go-nvlib/pkg/nvml with go-nvml/pkg/nvml Signed-off-by: Evan Lezar --- internal/info/additional_info.go | 2 +- internal/info/additional_info_test.go | 37 ++++++++++++++------------- internal/info/auto.go | 2 +- pkg/nvcdi/driver-nvml.go | 2 +- pkg/nvcdi/full-gpu-nvml.go | 2 +- pkg/nvcdi/lib-nvml.go | 2 +- pkg/nvcdi/lib.go | 2 +- pkg/nvcdi/mig-device-nvml.go | 2 +- pkg/nvcdi/namer.go | 2 +- pkg/nvcdi/namer_nvml_mock.go | 2 +- pkg/nvcdi/namer_test.go | 2 +- pkg/nvcdi/options.go | 2 +- 12 files changed, 30 insertions(+), 29 deletions(-) diff --git a/internal/info/additional_info.go b/internal/info/additional_info.go index 3d37fd2a..760d510d 100644 --- a/internal/info/additional_info.go +++ b/internal/info/additional_info.go @@ -22,7 +22,7 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) // additionalInfo allows for the info.Interface to be extened to implement the infoInterface. diff --git a/internal/info/additional_info_test.go b/internal/info/additional_info_test.go index a7c9518f..0a071188 100644 --- a/internal/info/additional_info_test.go +++ b/internal/info/additional_info_test.go @@ -20,7 +20,8 @@ import ( "testing" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml/mock" "github.com/stretchr/testify/require" ) @@ -32,7 +33,7 @@ func TestUsesNVGPUModule(t *testing.T) { }{ { description: "init failure returns false", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.ERROR_LIBRARY_NOT_FOUND }, @@ -41,7 +42,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "no devices returns false", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -56,7 +57,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "DeviceGetCount error returns false", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -71,7 +72,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "Failure to get device name returns false", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -82,7 +83,7 @@ func TestUsesNVGPUModule(t *testing.T) { return 1, nvml.SUCCESS }, DeviceGetHandleByIndexFunc: func(index int) (nvml.Device, nvml.Return) { - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { return "", nvml.ERROR_UNKNOWN }, @@ -94,7 +95,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "nested panic returns false", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -105,7 +106,7 @@ func TestUsesNVGPUModule(t *testing.T) { return 1, nvml.SUCCESS }, DeviceGetHandleByIndexFunc: func(index int) (nvml.Device, nvml.Return) { - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { panic("deep panic") }, @@ -117,7 +118,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "Single device name with no nvgpu", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -128,7 +129,7 @@ func TestUsesNVGPUModule(t *testing.T) { return 1, nvml.SUCCESS }, DeviceGetHandleByIndexFunc: func(index int) (nvml.Device, nvml.Return) { - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { return "NVIDIA A100-SXM4-40GB", nvml.SUCCESS }, @@ -140,7 +141,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "Single device name with nvgpu", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -151,7 +152,7 @@ func TestUsesNVGPUModule(t *testing.T) { return 1, nvml.SUCCESS }, DeviceGetHandleByIndexFunc: func(index int) (nvml.Device, nvml.Return) { - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { return "Orin (nvgpu)", nvml.SUCCESS }, @@ -163,7 +164,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "Multiple device names with no nvgpu", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -174,7 +175,7 @@ func TestUsesNVGPUModule(t *testing.T) { return 2, nvml.SUCCESS }, DeviceGetHandleByIndexFunc: func(index int) (nvml.Device, nvml.Return) { - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { return "NVIDIA A100-SXM4-40GB", nvml.SUCCESS }, @@ -186,7 +187,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "Multiple device names with nvgpu", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -197,7 +198,7 @@ func TestUsesNVGPUModule(t *testing.T) { return 2, nvml.SUCCESS }, DeviceGetHandleByIndexFunc: func(index int) (nvml.Device, nvml.Return) { - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { return "Orin (nvgpu)", nvml.SUCCESS }, @@ -209,7 +210,7 @@ func TestUsesNVGPUModule(t *testing.T) { }, { description: "Mixed device names", - nvmllib: &nvml.InterfaceMock{ + nvmllib: &mock.Interface{ InitFunc: func() nvml.Return { return nvml.SUCCESS }, @@ -226,7 +227,7 @@ func TestUsesNVGPUModule(t *testing.T) { } else { deviceName = "Orin (nvgpu)" } - device := &nvml.DeviceMock{ + device := &mock.Device{ GetNameFunc: func() (string, nvml.Return) { return deviceName, nvml.SUCCESS }, diff --git a/internal/info/auto.go b/internal/info/auto.go index 3ca7f15e..5d1426d9 100644 --- a/internal/info/auto.go +++ b/internal/info/auto.go @@ -19,7 +19,7 @@ package info import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/NVIDIA/nvidia-container-toolkit/internal/config/image" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" diff --git a/pkg/nvcdi/driver-nvml.go b/pkg/nvcdi/driver-nvml.go index 10d154d6..99374003 100644 --- a/pkg/nvcdi/driver-nvml.go +++ b/pkg/nvcdi/driver-nvml.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strings" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "golang.org/x/sys/unix" "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" diff --git a/pkg/nvcdi/full-gpu-nvml.go b/pkg/nvcdi/full-gpu-nvml.go index 9e4013ef..c7327757 100644 --- a/pkg/nvcdi/full-gpu-nvml.go +++ b/pkg/nvcdi/full-gpu-nvml.go @@ -23,7 +23,7 @@ import ( "strings" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" diff --git a/pkg/nvcdi/lib-nvml.go b/pkg/nvcdi/lib-nvml.go index 0403901a..95236651 100644 --- a/pkg/nvcdi/lib-nvml.go +++ b/pkg/nvcdi/lib-nvml.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" diff --git a/pkg/nvcdi/lib.go b/pkg/nvcdi/lib.go index ad75a239..7f07fd7e 100644 --- a/pkg/nvcdi/lib.go +++ b/pkg/nvcdi/lib.go @@ -21,7 +21,7 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" diff --git a/pkg/nvcdi/mig-device-nvml.go b/pkg/nvcdi/mig-device-nvml.go index 86ce04d2..d67d7d46 100644 --- a/pkg/nvcdi/mig-device-nvml.go +++ b/pkg/nvcdi/mig-device-nvml.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" diff --git a/pkg/nvcdi/namer.go b/pkg/nvcdi/namer.go index e6a27f45..8edd8f07 100644 --- a/pkg/nvcdi/namer.go +++ b/pkg/nvcdi/namer.go @@ -20,7 +20,7 @@ import ( "errors" "fmt" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) // UUIDer is an interface for getting UUIDs. diff --git a/pkg/nvcdi/namer_nvml_mock.go b/pkg/nvcdi/namer_nvml_mock.go index 68bc1782..6a704b45 100644 --- a/pkg/nvcdi/namer_nvml_mock.go +++ b/pkg/nvcdi/namer_nvml_mock.go @@ -6,7 +6,7 @@ package nvcdi import ( "sync" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) // Ensure, that nvmlUUIDerMock does implement nvmlUUIDer. diff --git a/pkg/nvcdi/namer_test.go b/pkg/nvcdi/namer_test.go index 1a106f68..f959609d 100644 --- a/pkg/nvcdi/namer_test.go +++ b/pkg/nvcdi/namer_test.go @@ -19,7 +19,7 @@ package nvcdi import ( "testing" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/stretchr/testify/require" ) diff --git a/pkg/nvcdi/options.go b/pkg/nvcdi/options.go index a4e49b60..89992a54 100644 --- a/pkg/nvcdi/options.go +++ b/pkg/nvcdi/options.go @@ -18,7 +18,7 @@ package nvcdi import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" "github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/transform"