Skip to content

Commit f001e74

Browse files
fix GUI error message in khiops and khiops coclustering
Fix these 2 problems: - The message saying to install "khiops" on conda environment is wrong. - when a non-existing option is passed, e.g. khiops --foo, the GUI message is displayed
1 parent 4f4759d commit f001e74

File tree

8 files changed

+82
-39
lines changed

8 files changed

+82
-39
lines changed

packaging/install.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if(UNIX)
7373
set(KHIOPS_COCLUSTERING_PATH "$(get_script_dir)")
7474
set(GET_PROC_NUMBER_PATH "$(get_script_dir)")
7575
set(KHIOPS_MPI_PATH "$(get_script_dir)") # We use mpiexec in conda's bin directory
76+
set(IS_CONDA_VAR "\n# Inside conda environment\nexport _IS_CONDA=true")
7677
else()
7778
if(IS_FEDORA_LIKE)
7879
set(KHIOPS_PATH "${MPI_BIN}/khiops/")
@@ -164,6 +165,7 @@ else(UNIX)
164165
if(IS_CONDA)
165166
set(GUI_STATUS "false")
166167
set(SET_MPI "SET_MPI_CONDA")
168+
set(IS_CONDA_VAR "REM Inside conda environment\r\nset \"_IS_CONDA=true\"")
167169
else()
168170
set(SET_MPI "SET_MPI_SYSTEM_WIDE")
169171
set(GUI_STATUS "true")

packaging/linux/common/khiops

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ error() {
1212
if [ -n "$DISPLAY" ]; then
1313
notify-send "Khiops" "$*" -i /usr/share/pixmaps/khiops.png -u normal
1414
fi
15+
unset _IS_CONDA
1516
exit 1
1617
}
1718

@@ -52,19 +53,6 @@ if [[ ! -e $KHIOPS_PATH ]]; then
5253
error "Binary not found ($KHIOPS_PATH)"
5354
fi
5455

55-
# Test multiple possible errors with the java GUI
56-
if [ "$KHIOPS_BATCH_MODE" = false ]; then
57-
if [ -z "$DISPLAY" ]; then
58-
error "GUI is not available, please use the '-b' flag"
59-
elif [ -z "$KHIOPS_JAVA_PATH" ]; then
60-
if [ -z "$KHIOPS_JAVA_ERROR" ]; then
61-
error "The khiops GUI is not configured properly. Please (re)install the 'khiops' package."
62-
else
63-
error "$KHIOPS_JAVA_ERROR"
64-
fi
65-
fi
66-
fi
67-
6856
# Display error with mpi configuration
6957
if [ -n "$KHIOPS_MPI_ERROR" ]; then
7058
warning "$KHIOPS_MPI_ERROR"
@@ -73,13 +61,35 @@ fi
7361
export CLASSPATH=$CLASSPATH:$KHIOPS_CLASSPATH
7462
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KHIOPS_JAVA_PATH
7563

76-
if [[ $# -eq 0 ]]; then
77-
# run without parameters
78-
# run and save scenario and log files in directory KHIOPS_LAST_RUN_DIR
79-
$KHIOPS_MPI_COMMAND $KHIOPS_PATH -o "${KHIOPS_LAST_RUN_DIR}"/scenario._kh -e "${KHIOPS_LAST_RUN_DIR}"/log.txt
64+
launch_khiops() {
65+
if [[ $# -eq 0 ]]; then
66+
# run without parameters
67+
# run and save scenario and log files in directory KHIOPS_LAST_RUN_DIR
68+
$KHIOPS_MPI_COMMAND "$KHIOPS_PATH -o ${KHIOPS_LAST_RUN_DIR}/scenario._kh -e ${KHIOPS_LAST_RUN_DIR}/log.txt"
69+
else
70+
# run with parameters
71+
$KHIOPS_MPI_COMMAND "$KHIOPS_PATH" "$@"
72+
fi
73+
}
74+
75+
# Launck Khiops
76+
if [ "$KHIOPS_BATCH_MODE" = true ]; then
77+
launch_khiops "$@"
8078
else
81-
# run with parameters
82-
$KHIOPS_MPI_COMMAND $KHIOPS_PATH "$@"
79+
if [ "$_IS_CONDA" = true ] || [ -z "$DISPLAY" ]; then
80+
error "GUI is not available, please use the '-b' flag"
81+
else
82+
if [ -z "$KHIOPS_JAVA_PATH" ]; then
83+
if [ -z "$KHIOPS_JAVA_ERROR" ]; then
84+
error "GUI is not available, please either use the '-b' flag, or install the 'khiops' native package for your host operating system."
85+
else
86+
error "$KHIOPS_JAVA_ERROR"
87+
fi
88+
else
89+
launch_khiops "$@"
90+
fi
91+
fi
8392
fi
8493

94+
unset _IS_CONDA
8595
exit $?

packaging/linux/common/khiops_coclustering

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ error() {
1212
if [ -n "$DISPLAY" ]; then
1313
notify-send "Khiops" "$*" -i /usr/share/pixmaps/khiops.png -u normal
1414
fi
15+
unset _IS_CONDA
1516
exit 1
1617
}
1718

@@ -52,29 +53,38 @@ if [[ ! -e $KHIOPS_COCLUSTERING_PATH ]]; then
5253
error "Binary not found ($KHIOPS_COCLUSTERING_PATH)"
5354
fi
5455

55-
# Test multiple possible errors with the java GUI
56-
if [ "$KHIOPS_BATCH_MODE" = false ]; then
57-
if [ -z "$DISPLAY" ]; then
58-
error "GUI is not available, please use the '-b' flag"
59-
elif [ -z "$KHIOPS_JAVA_PATH" ]; then
60-
if [ -z "$KHIOPS_JAVA_ERROR" ]; then
61-
error "The khiops GUI is not configured properly. Please (re)install the 'khiops' package."
62-
else
63-
error "$KHIOPS_JAVA_ERROR"
64-
fi
65-
fi
66-
fi
67-
6856
export CLASSPATH=$CLASSPATH:$KHIOPS_CLASSPATH
6957
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KHIOPS_JAVA_PATH
7058

71-
if [[ $# -eq 0 ]]; then
72-
# run without parameters
73-
# run and save scenario and log files in directory KHIOPS_LAST_RUN_DIR
74-
$KHIOPS_COCLUSTERING_PATH -o "${KHIOPS_LAST_RUN_DIR}"/scenario._kh -e "${KHIOPS_LAST_RUN_DIR}"/log.txt
59+
launch_khiops() {
60+
if [[ $# -eq 0 ]]; then
61+
# run without parameters
62+
# run and save scenario and log files in directory KHIOPS_LAST_RUN_DIR
63+
"$KHIOPS_COCLUSTERING_PATH -o ${KHIOPS_LAST_RUN_DIR}/scenario._kh -e ${KHIOPS_LAST_RUN_DIR}/log.txt"
64+
else
65+
# run with parameters
66+
"$KHIOPS_COCLUSTERING_PATH" "$@"
67+
fi
68+
}
69+
70+
# Launck Khiops
71+
if [ "$KHIOPS_BATCH_MODE" = true ]; then
72+
launch_khiops "$@"
7573
else
76-
# run with parameters
77-
$KHIOPS_COCLUSTERING_PATH "$@"
74+
if [ "$_IS_CONDA" = true ] || [ -z "$DISPLAY" ]; then
75+
error "GUI is not available, please use the '-b' flag"
76+
else
77+
if [ -z "$KHIOPS_JAVA_PATH" ]; then
78+
if [ -z "$KHIOPS_JAVA_ERROR" ]; then
79+
error "GUI is not available, please either use the '-b' flag, or install the 'khiops' native package for your host operating system."
80+
else
81+
error "$KHIOPS_JAVA_ERROR"
82+
fi
83+
else
84+
launch_khiops "$@"
85+
fi
86+
fi
7887
fi
7988

89+
unset _IS_CONDA
8090
exit $?

packaging/linux/common/khiops_env/java_settings.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
# Set java environment if Khiops GUI is installed
3+
unset KHIOPS_JAVA_ERROR
4+
unset KHIOPS_JAVA_PATH
5+
unset KHIOPS_CLASSPATH
36
if [ -f "/usr/share/khiops/khiops.jar" ]; then
47
if [[ -z $JAVA_HOME ]] && [ -f /usr/bin/java ]; then
58
JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")

packaging/linux/common/khiops_env/khiops_env.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ get_script_dir() {
5858
echo "$SCRIPT_DIR/"
5959
}
6060
@ADDITIONAL_ENV_VAR@
61+
@IS_CONDA_VAR@
6162

6263
# Setting up mpi for multiple machines
6364
if [[ -n $KHIOPS_MPI_HOST_FILE ]]; then
@@ -74,6 +75,7 @@ if [[ -z $KHIOPS_PROC_NUMBER ]]; then
7475
fi
7576

7677
if command -v mpiexec &>/dev/null; then
78+
KHIOPS_MPI_ERROR=""
7779
KHIOPS_MPI_COMMAND="@KHIOPS_MPI_PATH@mpiexec $MPI_EXTRA_FLAGS @KHIOPS_MPI_EXTRA_FLAG@ @MPIEXEC_NUMPROC_FLAG@ $KHIOPS_PROC_NUMBER"
7880
else
7981
KHIOPS_MPI_ERROR="We didn't find mpiexec in the regular path. Parallel computation is unavailable: Khiops is launched in serial"

packaging/windows/khiops.cmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ for %%i in (%*) do (
3232
:BREAK_LOOP
3333

3434
if "%KHIOPS_BATCH_MODE%" == "true" if not "%KHIOPS_JAVA_ERROR%". == "". goto ERR_JAVA
35+
if "%_IS_CONDA%" == "true" and not "%KHIOPS_BATCH_MODE%" == "true" goto ERR_CONDA
3536

3637
REM Set path
3738
set path=%~dp0;%KHIOPS_JAVA_PATH%;%path%
3839
set classpath=%KHIOPS_CLASSPATH%;%classpath%
3940

4041
REM unset local variables
4142
set "KHIOPS_BATCH_MODE="
43+
set "_IS_CONDA="
4244

4345
REM ========================================================
4446
REM Start Khiops (with or without parameteres)
@@ -80,6 +82,11 @@ goto END
8082
start "KHIOPS CONFIGURATION PROBLEM" echo ERROR "%KHIOPS_JAVA_ERROR%"
8183
exit /b 1
8284

85+
:ERR_CONDA
86+
echo "GUI is not available, please use the '-b' flag"
87+
"%KHIOPS_PATH%" -help
88+
exit /b 1
89+
8390
:END
8491
endlocal
8592

packaging/windows/khiops_coclustering.cmd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ for %%i in (%*) do (
2828
)
2929
:BREAK_LOOP
3030

31-
if "%KHIOPS_BATCH_MODE%" == "true" if not "%KHIOPS_JAVA_ERROR%". == "". goto ERR_JAVA
31+
if "%KHIOPS_BATCH_MODE%" == "true" if not "%KHIOPS_JAVA_ERROR%". == "". goto ERR_JAVA
32+
if "%_IS_CONDA%" == "true" and not "%KHIOPS_BATCH_MODE%" == "true" goto ERR_CONDA
33+
3234

3335
REM Set path
3436
set path=%~dp0;%KHIOPS_JAVA_PATH%;%path%
3537
set classpath=%KHIOPS_CLASSPATH%;%classpath%
3638

3739
REM unset local variables
3840
set "KHIOPS_BATCH_MODE="
41+
set "_IS_CONDA="
3942

4043
REM ========================================================
4144
REM Start Khiops (with or without parameteres)
@@ -77,6 +80,10 @@ goto END
7780
start "KHIOPS CONFIGURATION PROBLEM" echo ERROR "%KHIOPS_JAVA_ERROR%"
7881
exit /b 1
7982

83+
:ERR_CONDA
84+
"%KHIOPS_COCLUSTERING_PATH%" -help
85+
exit /b 1
86+
8087
:END
8188
endlocal
8289

packaging/windows/khiops_env.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ REM KHIOPS_CLASSPATH
107107
set "KHIOPS_CLASSPATH=%_KHIOPS_HOME%\bin\norm.jar"
108108
set "KHIOPS_CLASSPATH=%_KHIOPS_HOME%\bin\khiops.jar;%KHIOPS_CLASSPATH%"
109109

110+
@IS_CONDA_VAR@
111+
110112
:SKIP_GUI
111113

112114
REM unset local variables

0 commit comments

Comments
 (0)