From 660d41d72f1e88493d72c01fe90b8f4ddc713f0b Mon Sep 17 00:00:00 2001 From: Charlier Benjamin Date: Mon, 14 Oct 2024 10:35:02 +0200 Subject: [PATCH] First files to refactor config of keopscore --- keopscore/keopscore/config/Config_new.py | 68 ++++++++++++++++++++++++ keopscore/keopscore/config/Platform.py | 7 +++ keopscore/keopscore/config/config.py | 1 + 3 files changed, 76 insertions(+) create mode 100644 keopscore/keopscore/config/Config_new.py create mode 100644 keopscore/keopscore/config/Platform.py diff --git a/keopscore/keopscore/config/Config_new.py b/keopscore/keopscore/config/Config_new.py new file mode 100644 index 000000000..06836416a --- /dev/null +++ b/keopscore/keopscore/config/Config_new.py @@ -0,0 +1,68 @@ +import keopscore.config + +# TODO + +class Config_new: + """ + Set the configuration of the library. The print_all function + allows to print all the attributes of the class. They should + be formatted with _print at the end of the name. + """ + use_cuda = True # bool + use_OpenMP = None # bool + base_dir_path = "" # str + template_path = "" # str + bindings_source_dir = "" # str + keops_cache_folder = "" # str + default_build_folder_name = "" # str + specific_gpus = "" + default_build_path = "" + jit_binary = "" + cxx_compiler = "" + cpp_env_flags = "" + compile_options = "" + cpp_flags = "" + disable_pragma_unrolls + check_openmp_loaded + load_dll + show_cuda_status + init_cudalibs_flag + init_cudalibs + show_gpu_config + + + def __init__(self, config): + + # detect platform + self.os = platform.system() + + # detect python version + self.python_version = platform.python_version() + + self.config = config + + @property + def use_cuda(self): + + return + + def print_all(self): + """ + Print all the attributes of the class + + :return: + """ + # test if all the attributes contain the string "print" and launch the function + for attr in dir(self): + if "print" in attr: + getattr(self, attr)() + + +if __name__ == "__main__": + conf = Config_new(keopscore.config) + config.print_all() + + + + + diff --git a/keopscore/keopscore/config/Platform.py b/keopscore/keopscore/config/Platform.py new file mode 100644 index 000000000..93f376113 --- /dev/null +++ b/keopscore/keopscore/config/Platform.py @@ -0,0 +1,7 @@ +""" +Detect the platform and set the correct path for the keops library + +Detect if venv is active and set the correct path for the keops library + +Detect if conda is active and set the correct path for the keops library +""" \ No newline at end of file diff --git a/keopscore/keopscore/config/config.py b/keopscore/keopscore/config/config.py index 07424a8c7..01e0edd11 100644 --- a/keopscore/keopscore/config/config.py +++ b/keopscore/keopscore/config/config.py @@ -16,6 +16,7 @@ template_path = join(base_dir_path, "templates") bindings_source_dir = join(base_dir_path) +# First, check environment variables. If not set, use default values keops_cache_folder = os.getenv("KEOPS_CACHE_FOLDER") if keops_cache_folder is None: keops_cache_folder = join(