Skip to content

Commit

Permalink
Merge branch '111-update-learningtest-python-scripts' of https://gith…
Browse files Browse the repository at this point in the history
…ub.com/KhiopsML/khiops into 111-update-learningtest-python-scripts
  • Loading branch information
marcboulle committed Jan 9, 2024
2 parents b4666e0 + 85e135e commit 0c99405
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/run-standard-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ name: Run Standard Tests
on:
workflow_dispatch:
pull_request:
paths: [src/**]
paths:
- '**CMakeLists.txt'
- src/**.h
- src/**.cpp
- src/**.java
- src/**.dd
- src/**.inc
- src/**.lex
- src/**.yac
- test/LearningTest/**
env:
KhiopsBatchMode: true
jobs:
Expand Down
70 changes: 32 additions & 38 deletions test/LearningTest/cmd/python/test_khiops.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ def test(modl_path, samples_path, sample_test):
# verifie l'existence du repertoire et du fichier de sample_test
# et lance la comparaison pour le sample 'sample_test'

def filter_lines(lines, filtered_pattern):
"""retourne les lignes sans celles contenant le pattern en parametre"""
output_lines = []
for line in lines:
if filtered_pattern not in line:
output_lines.append(line)
return output_lines

def filter_empty_lines(lines):
"""retourne les lignes sans les lignes vides"""
output_lines = []
for line in lines:
line = line.strip()
if line != "":
output_lines.append(line)
return output_lines

# check MODL path
if modl_path != "nul":
if not os.path.isfile(modl_path):
Expand Down Expand Up @@ -290,57 +307,34 @@ def test(modl_path, samples_path, sample_test):

# En cas d'anomalie, memorisation du contenu de des sorties standard
if stdout != "":
# Pour les test KNI, le stdout contient une ligne avec le nombre de records
ok = False
is_kni = "KNI" in modl_path
is_coclustering = "Coclustering" in modl_path
lines = stdout.split("\n")
lines = filter_empty_lines(lines)
# Pour les test KNI, le stdout contient une ligne avec le nombre de records
if is_kni:
lines = stdout.split("\n")
ok = len(lines) == 2 and lines[1] == ""
# Cas special pour LearningTest\TestKNITransfer\SmallInstability\VeryLarge
if not ok:
ok = True
for line in lines:
line = line.strip()
if line == "":
continue
if (
line.find("Recoded record number:") == -1
and line.find(" stream ") == -1
):
ok = False
break
lines = filter_lines(lines, "Recoded record number:")
# Cas particulier du coclustering en mode debug
if is_coclustering:
lines = filter_lines(
lines, "BEWARE: Optimization level set to 0 in debug mode only!!!"
)
# Exception egalement pour cas des lancement en mode parallele simule
lines = filter_lines(lines, "Warning : simulated parallel mode")
# Exception en mode debug, pour les stats memoire
if "Memory stats (number of pointers, and memory space)" in stdout:
lines = stdout.split("\n")
ok = True
# Parcours des lignes pour voir si ce sont bien des messages de stats, y compris en parallel
# En parallele, on a l'id du process entre crochets en tete de chaque ligne
for line in lines:
ok = (
line == ""
or (line[0] == "[" and line[-1] == "]")
(line[0] == "[" and line[-1] == "]")
or "Memory stats (number of pointers, and memory space)" in line
or "Alloc: " in line
or "Requested: " in line
)
if not ok:
break
# Cas special pour LearningTest\TestKNITransfer\SmallInstability\VeryLarge
if not ok:
ok = True
for line in lines:
line = line.strip()
if line == "":
continue
if (
line.find("Recoded record number:") == -1
and line.find(" stream ") == -1
):
ok = False
break
# Exception egalement pour cas des lancement en mode parallele simule
if "Warning : simulated parallel mode" in stdout:
ok = True
else:
ok = len(lines) == 0
if not ok:
with open(
os.path.join(os.getcwd(), test_dir, "results", "stdout_error.log"),
Expand Down

0 comments on commit 0c99405

Please sign in to comment.