From dcd7638095033bf03c01d22916ab0f41c6cac6b8 Mon Sep 17 00:00:00 2001 From: Nizar Ben Bouchta Date: Mon, 18 Nov 2024 08:59:25 +0000 Subject: [PATCH] fixing pykeops imports --- keopscore/keopscore/__init__.py | 4 +++- keopscore/keopscore/config/Platform.py | 4 ---- keopscore/keopscore/config/cuda.py | 5 +---- keopscore/keopscore/config/openmp.py | 4 ---- pykeops/pykeops/__init__.py | 16 ++++++++-------- pykeops/pykeops/common/keops_io/__init__.py | 4 ++-- pykeops/pykeops/config.py | 7 +++---- 7 files changed, 17 insertions(+), 27 deletions(-) diff --git a/keopscore/keopscore/__init__.py b/keopscore/keopscore/__init__.py index 543688c9a..054156735 100644 --- a/keopscore/keopscore/__init__.py +++ b/keopscore/keopscore/__init__.py @@ -40,4 +40,6 @@ # Retrieve the current build folder build_folder = config.get_build_folder() -# from keopscore.config.config import show_gpu_config, show_cuda_status +from keopscore.config import cuda_config +show_gpu_config = cuda_config.print_all() +show_cuda_status = cuda_config.get_use_cuda() diff --git a/keopscore/keopscore/config/Platform.py b/keopscore/keopscore/config/Platform.py index 665e15a83..40b287908 100644 --- a/keopscore/keopscore/config/Platform.py +++ b/keopscore/keopscore/config/Platform.py @@ -91,7 +91,3 @@ def print_all(self): print(f"{var} is not set") -if __name__ == "__main__": - # Create an instance of DetectPlatform and print all platform related information - platform_detector = DetectPlatform() - platform_detector.print_all() diff --git a/keopscore/keopscore/config/cuda.py b/keopscore/keopscore/config/cuda.py index 9c3c40676..1409bf749 100644 --- a/keopscore/keopscore/config/cuda.py +++ b/keopscore/keopscore/config/cuda.py @@ -320,7 +320,4 @@ def print_all(self): print(f"{var} is not set") -if __name__ == "__main__": - # Create an instance of CUDAConfig and print all CUDA-related information - cuda_config = CUDAConfig() - cuda_config.print_all() + diff --git a/keopscore/keopscore/config/openmp.py b/keopscore/keopscore/config/openmp.py index 34b6c8150..d994707fa 100644 --- a/keopscore/keopscore/config/openmp.py +++ b/keopscore/keopscore/config/openmp.py @@ -144,7 +144,3 @@ def print_all(self): print(f"{var} is not set") -if __name__ == "__main__": - # Create an instance of OpenMPConfig and print all OpenMP-related information - openmp_config = OpenMPConfig() - openmp_config.print_all() diff --git a/pykeops/pykeops/__init__.py b/pykeops/pykeops/__init__.py index 1257be103..f86c5594a 100644 --- a/pykeops/pykeops/__init__.py +++ b/pykeops/pykeops/__init__.py @@ -9,14 +9,14 @@ import keopscore import keopscore.config -import keopscore.config.config -from keopscore.config.base_config import ConfigNew +from keopscore.config import config, cuda_config from . import config as pykeopsconfig - from keopscore import show_cuda_status -keops_get_build_folder = ConfigNew.get_default_build_folder_name() +keops_get_build_folder = pykeopsconfig.get_build_folder +from .config import pykeops_nvrtc_name +from .config import numpy_found, torch_found def set_verbose(val): @@ -39,8 +39,8 @@ def set_verbose(val): default_device_id = 0 # default Gpu device number -if keopscore.config.config.use_cuda: - if not os.path.exists(pykeopsconfig.pykeops_nvrtc_name(type="target")): +if cuda_config.get_use_cuda(): + if not os.path.exists(pykeops_nvrtc_name(type="target")): from .common.keops_io.LoadKeOps_nvrtc import compile_jit_binary compile_jit_binary() @@ -74,10 +74,10 @@ def get_build_folder(): return keops_get_build_folder() -if pykeopsconfig.numpy_found: +if numpy_found: from .numpy.test_install import test_numpy_bindings -if pykeopsconfig.torch_found: +if torch_found: from .torch.test_install import test_torch_bindings # next line is to ensure that cache file for formulas is loaded at import diff --git a/pykeops/pykeops/common/keops_io/__init__.py b/pykeops/pykeops/common/keops_io/__init__.py index 82b1b7143..4cc57c89b 100644 --- a/pykeops/pykeops/common/keops_io/__init__.py +++ b/pykeops/pykeops/common/keops_io/__init__.py @@ -1,6 +1,6 @@ -import keopscore.config +from keopscore.config import config, cuda_config -if keopscore.config.config.use_cuda: +if cuda_config._use_cuda: from . import LoadKeOps_nvrtc, LoadKeOps_cpp keops_binder = { diff --git a/pykeops/pykeops/config.py b/pykeops/pykeops/config.py index 43fa102e1..0b7375375 100644 --- a/pykeops/pykeops/config.py +++ b/pykeops/pykeops/config.py @@ -9,11 +9,10 @@ numpy_found = importlib.util.find_spec("numpy") is not None torch_found = importlib.util.find_spec("torch") is not None -from keopscore.config.cuda import CUDAconfig -from keopscore.config.base_config import ConfigNew +from keopscore.config import cuda_config, config -gpu_available = CUDAconfig.get_use_cuda() -get_build_folder = ConfigNew.get_build_folder() +gpu_available = cuda_config.get_use_cuda() +get_build_folder = config.get_build_folder def pykeops_nvrtc_name(type="src"):