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 7c3734b
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 10 deletions.
9 changes: 9 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 @@ -115,10 +122,12 @@

"""
Variables d'environnement influant le comportement des outils Khiops
Ces variables sont decrites dans la methode help_env_vars de kht_env
"""
# Variables documentees pour l'utilisateur
KHIOPS_PREPARATION_TRACE_MODE = "KhiopsPreparationTraceMode"
KHIOPS_PARALLEL_TRACE = "KhiopsParallelTrace"
KHIOPS_FILE_SERVER_ACTIVATED = "KhiopsFileServerActivated"
KHIOPS_MEM_STATS_LOG_FILE_NAME = "KhiopsMemStatsLogFileName"
KHIOPS_MEM_STATS_LOG_FREQUENCY = "KhiopsMemStatsLogFrequency"
KHIOPS_MEM_STATS_LOG_TO_COLLECT = "KhiopsMemStatsLogToCollect"
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
3 changes: 3 additions & 0 deletions test/LearningTestTool/py/kht_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def help_env_vars():
"trace for dimensionnining of preparation tasks (default: false)",
)
print_env_var_help(kht.KHIOPS_PARALLEL_TRACE, "trace for parallel tasks (0 to 3)")
print_env_var_help(
kht.KHIOPS_FILE_SERVER_ACTIVATED, "activate MPI file server (false,true)"
)

# Aide particulier sur le pilotage des traces memoire
print(
Expand Down
72 changes: 62 additions & 10 deletions test/LearningTestTool/py/kht_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,63 @@ 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 = []
tested_binaries_name = []
# 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"
tested_binaries_name.append(tool_exe_name)
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
tool_full_name = ""
for name in tested_binaries_name:
tool_full_name += name + " "
tool_full_name += kht.TOOL_EXE_NAMES[tool_name]
error_message = (
"no binaries found for "
+ tool_name
+ " ("
+ tool_full_name.rstrip()
+ ") in "
+ actual_tool_binaries_dir
+ alias_info
)
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 +264,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 +336,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 7c3734b

Please sign in to comment.