Skip to content

Commit

Permalink
LearningTestTool takes into account the binary renaming
Browse files Browse the repository at this point in the history
The kht_test script handles the new naming of th eparallel binaries:
MODL_openmpi or MODL_mpich or MODL (the last one has priority)
  • Loading branch information
bruno-at-orange committed Apr 12, 2024
1 parent 70ff89d commit 4a1664e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
8 changes: 8 additions & 0 deletions test/LearningTestTool/py/_kht_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
}
assert set(TOOL_EXE_NAMES) == set(TOOL_NAMES), "Exe names must be defined for each tool"

"""
Liste des suffixes MPI pour les outils pouvant tourner en parallele
Le binaire parallelisable est pris en priorité sans suffixe, si il n'existe pas on prend
le binaire avec un suffixe mpi
"""
TOOL_MPI_SUFFIXES = {"_openmpi", "_mpich"}

""" Dictionnaire des noms des sous-repertoires de LearningTest avec le nom d'outil en cle """
TOOL_DIR_NAMES = {
KHIOPS: "TestKhiops",
Expand Down Expand Up @@ -123,6 +130,7 @@
KHIOPS_MEM_STATS_LOG_FREQUENCY = "KhiopsMemStatsLogFrequency"
KHIOPS_MEM_STATS_LOG_TO_COLLECT = "KhiopsMemStatsLogToCollect"
KHIOPS_IO_TRACE_MODE = "KhiopsIOTraceMode"
KHIOPS_FILE_SERVER_ACTIVATED = "KhiopsFileServerActivated"

# Variables non documentee documentees, utilisee systematiquyement pour les tests
KHIOPS_EXPERT_MODE = "KhiopsExpertMode"
Expand Down
26 changes: 26 additions & 0 deletions test/LearningTestTool/py/_kht_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,32 @@ def parent_dir_name(dir_path, depth):
return result_name


"""
Gestion des noms des binaires
"""


def is_valid_tool_full_exe_name(tool_exe_name):
"""Indique si le nom du binaire fait partie des noms valides, avec prise
en compte des suffixes mpi pour les exe paralellisable"""

if tool_exe_name in kht.TOOL_EXE_NAMES.values():
return True
if extract_tool_exe_name(tool_exe_name) in kht.PARALLEL_TOOL_NAMES:
return True
return False


def extract_tool_exe_name(tool_full_exe_name):
"""Extrait le nom du binaire a partir d'un nom ayant potentiellement un suffixe mpi"""

if tool_full_exe_name in kht.TOOL_EXE_NAMES.values():
return tool_full_exe_name
for suffix in kht.TOOL_MPI_SUFFIXES:
if tool_full_exe_name.endswith(suffix):
return tool_full_exe_name.removesuffix(suffix)


"""
Gestion des messages utilisateurs
"""
Expand Down
57 changes: 47 additions & 10 deletions test/LearningTestTool/py/kht_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,48 @@ def build_tool_exe_path(tool_binaries_dir, tool_name):
tool_exe_path = os.path.join(actual_tool_binaries_dir, tool_exe_name)
if not os.path.isfile(tool_exe_path):
tool_exe_path = None
error_message = (
tool_name
+ " binary ("
+ tool_exe_name
+ ") not found in tool binaries dir "
+ actual_tool_binaries_dir
+ alias_info
)
# si le binaire n'existe pas, c'est peut-etre un binaire parallele qui a un suffixe
if tool_name in kht.PARALLEL_TOOL_NAMES:
tool_with_suffixes = []
# construction de la liste des binaires avec suffixe qui sont presents dans le repertoire bin
for suffix in kht.TOOL_MPI_SUFFIXES:
tool_exe_name = kht.TOOL_EXE_NAMES[tool_name] + suffix
if platform == "Windows":
tool_exe_name += ".exe"
tool_exe_path = os.path.join(
actual_tool_binaries_dir, tool_exe_name
)
if os.path.isfile(tool_exe_path):
tool_with_suffixes.append(tool_exe_path)
# Si il y en a plusieurs ou aucun, il y a une erreur
if len(tool_with_suffixes) == 0:
tool_exe_path = None
elif len(tool_with_suffixes) > 1:
tool_exe_path = None
conflict_names = ""
for name in tool_with_suffixes:
conflict_names += os.path.basename(name) + " "
error_message = (
"multiple binaries found for "
+ tool_name
+ " ("
+ conflict_names.rstrip()
+ ") in "
+ actual_tool_binaries_dir
+ alias_info
)
else:
tool_exe_path = tool_with_suffixes[0]
# Message d'erreur par defaut
if tool_exe_path == None and error_message == "":
error_message = (
tool_name
+ " binary ("
+ tool_exe_name
+ ") not found in tool binaries dir "
+ actual_tool_binaries_dir
+ alias_info
)
return tool_exe_path, error_message


Expand Down Expand Up @@ -215,7 +249,10 @@ def evaluate_tool_on_test_dir(
# Lancement des tests
if tool_exe_path != kht.ALIAS_CHECK:
# Recherche du nom du l'executable Khiops (sans l'extension)
tool_exe_name, _ = os.path.splitext(os.path.basename(tool_exe_path))
tool_exe_full_name, _ = os.path.splitext(os.path.basename(tool_exe_path))

# ... et sans le suffixe mpi
tool_exe_name = utils.extract_tool_exe_name(tool_exe_full_name)

# Recherche du nom de l'outil correspondant
if tool_exe_name not in kht.TOOL_EXE_NAMES.values():
Expand Down Expand Up @@ -284,7 +321,7 @@ def evaluate_tool_on_test_dir(
# permet de lancer plus de processus qu'il n'y a de coeurs
khiops_params.append("--oversubscribe")
# permet de lancer en tant que root
khiops_params.append("--allow-run-as-root ")
khiops_params.append("--allow-run-as-root")
# Ajoute le rang du processus dans les traces
khiops_params.append("--tag-output")
khiops_params.append("-n")
Expand Down

0 comments on commit 4a1664e

Please sign in to comment.