Skip to content

Commit

Permalink
First files to refactor config of keopscore
Browse files Browse the repository at this point in the history
  • Loading branch information
bcharlier committed Oct 14, 2024
1 parent 1f919f8 commit 660d41d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
68 changes: 68 additions & 0 deletions keopscore/keopscore/config/Config_new.py
Original file line number Diff line number Diff line change
@@ -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()





7 changes: 7 additions & 0 deletions keopscore/keopscore/config/Platform.py
Original file line number Diff line number Diff line change
@@ -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
"""
1 change: 1 addition & 0 deletions keopscore/keopscore/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 660d41d

Please sign in to comment.