From 9ebdb411d872ecfcbee2e26c40095a64e7f2609e Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Tue, 5 May 2026 02:22:19 +0000 Subject: [PATCH 1/3] fix: remove logging to std out during import Related-To: NEO-18404 Signed-off-by: shubham kumar --- bindings/sysman/python/source/pyzes.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/bindings/sysman/python/source/pyzes.py b/bindings/sysman/python/source/pyzes.py index d6329fde..c9035421 100644 --- a/bindings/sysman/python/source/pyzes.py +++ b/bindings/sysman/python/source/pyzes.py @@ -67,10 +67,8 @@ def _LoadZeLibrary(): # load the library libName = "ze_loader" if sys.platform.startswith("linux"): - print("Loading Linux library") libName = "/usr/lib/x86_64-linux-gnu/lib" + libName + ".so.1" else: - print("Loading Windows library") # Try multiple common locations for Windows Intel GPU drivers import os @@ -94,29 +92,21 @@ def _LoadZeLibrary(): matching_paths = glob.glob(path) for match_path in matching_paths: try: - print(f"Trying: {match_path}") gpuLib = CDLL(match_path) library_loaded = True - print(f"Successfully loaded: {match_path}") break except Exception as e: - print(f"Failed to load {match_path}: {e}") continue else: if os.path.exists(path): - print(f"Trying: {path}") gpuLib = CDLL(path) library_loaded = True - print(f"Successfully loaded: {path}") break else: - print(f"Trying: {path}") gpuLib = CDLL(path) library_loaded = True - print(f"Successfully loaded: {path}") break except Exception as e: - print(f"Failed to load {path}: {e}") continue if library_loaded: From 23819d9e24517ba1146e7eb664cdbdbd3b24b622 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Tue, 5 May 2026 02:45:39 +0000 Subject: [PATCH 2/3] fix: remove logging to std out during import Related-To: NEO-18404 Signed-off-by: shubham kumar --- bindings/sysman/python/source/pyzes.py | 4 ++-- .../sysman/python/test/unit_tests/test_init.py | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/bindings/sysman/python/source/pyzes.py b/bindings/sysman/python/source/pyzes.py index c9035421..98f4b3dc 100644 --- a/bindings/sysman/python/source/pyzes.py +++ b/bindings/sysman/python/source/pyzes.py @@ -95,7 +95,7 @@ def _LoadZeLibrary(): gpuLib = CDLL(match_path) library_loaded = True break - except Exception as e: + except Exception: continue else: if os.path.exists(path): @@ -106,7 +106,7 @@ def _LoadZeLibrary(): gpuLib = CDLL(path) library_loaded = True break - except Exception as e: + except Exception: continue if library_loaded: diff --git a/bindings/sysman/python/test/unit_tests/test_init.py b/bindings/sysman/python/test/unit_tests/test_init.py index 13fa42a9..c2585dee 100644 --- a/bindings/sysman/python/test/unit_tests/test_init.py +++ b/bindings/sysman/python/test/unit_tests/test_init.py @@ -118,13 +118,9 @@ def test_GivenLibraryAlreadyLoadedWhenCallingLoadZeLibraryThenReturnsEarly(self) try: # This should return early without any library loading - with patch("builtins.print") as mock_print: - self.pyzes._LoadZeLibrary() - # Should not print "Loading Linux library" because it returns early - print_calls = [ - call.args[0] for call in mock_print.call_args_list if call.args - ] - self.assertNotIn("Loading Linux library", print_calls) + self.pyzes._LoadZeLibrary() + # Verify gpuLib remains unchanged (early return) + self.assertEqual(self.pyzes.gpuLib, mock_lib) finally: # Restore original state self.pyzes.gpuLib = original_gpuLib @@ -201,11 +197,10 @@ def test_GivenValidLibraryWhenGettingNewFunctionPointerThenCachesAndReturnsFunct @patch("sys.platform", "win32") @patch("pyzes.gpuLib", None) - @patch("builtins.print") @patch("os.path.exists") @patch("pyzes.CDLL") def test_GivenWindowsPlatformWhenLoadingLibraryThenLibraryIsLoaded( - self, mock_cdll, mock_exists, mock_print + self, mock_cdll, mock_exists ): # Test Windows library loading path with deterministic mocking mock_exists.return_value = True @@ -214,10 +209,9 @@ def test_GivenWindowsPlatformWhenLoadingLibraryThenLibraryIsLoaded( self.pyzes._LoadZeLibrary() - # Verify Windows-specific print was called - mock_print.assert_any_call("Loading Windows library") # Verify successful library loading mock_cdll.assert_called() + self.assertIsNotNone(self.pyzes.gpuLib) if __name__ == "__main__": From 92d7c977f9df0554e4ba30f9632c87d2d017a1e4 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Tue, 5 May 2026 02:59:24 +0000 Subject: [PATCH 3/3] fix: remove logging to std out during import Related-To: NEO-18404 Signed-off-by: shubham kumar --- bindings/sysman/python/source/pyzes.py | 47 +++++++++++--------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/bindings/sysman/python/source/pyzes.py b/bindings/sysman/python/source/pyzes.py index 98f4b3dc..f7841f50 100644 --- a/bindings/sysman/python/source/pyzes.py +++ b/bindings/sysman/python/source/pyzes.py @@ -70,8 +70,6 @@ def _LoadZeLibrary(): libName = "/usr/lib/x86_64-linux-gnu/lib" + libName + ".so.1" else: # Try multiple common locations for Windows Intel GPU drivers - import os - possible_paths = [ # Try system PATH first libName + "64.dll", @@ -84,34 +82,29 @@ def _LoadZeLibrary(): library_loaded = False for path in possible_paths: - try: - if "*" in path: - # Handle wildcard paths for driver store - import glob - - matching_paths = glob.glob(path) - for match_path in matching_paths: - try: - gpuLib = CDLL(match_path) - library_loaded = True - break - except Exception: - continue - else: - if os.path.exists(path): - gpuLib = CDLL(path) - library_loaded = True - break - else: - gpuLib = CDLL(path) - library_loaded = True - break - except Exception: - continue - if library_loaded: break + if "*" in path: + # Handle wildcard paths for driver store + import glob + + matching_paths = glob.glob(path) + for match_path in matching_paths: + try: + gpuLib = CDLL(match_path) + library_loaded = True + break + except OSError: + pass # Try next path + else: + # Try loading the library directly + try: + gpuLib = CDLL(path) + library_loaded = True + except OSError: + pass # Try next path + if not library_loaded: raise Exception( f"Failed to load Intel GPU library. Tried paths: {possible_paths}"