Skip to content

Commit 559d38e

Browse files
author
Thierry RAMORASOAVINA
committed
Improve messages and behaviour when detecting unhappy installation paths
- in case of major version mismatch, raise immediately an error - in case of a mix between conda and something else (pip or a cloned source folder), we suggest deactivating the conda env or install the library inside this later - discourage using system-wide khiops binary and a library inside a conda env
1 parent 6e5bcb1 commit 559d38e

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

khiops/core/internals/runner.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,30 +1076,46 @@ def _initialize_khiops_version(self):
10761076
error_msg += f"\nstderr: {stderr}" if stderr else ""
10771077
raise KhiopsRuntimeError(error_msg)
10781078

1079+
# Khiops core version
10791080
self._khiops_version = KhiopsVersion(khiops_version_str)
10801081

1081-
# Warn if the khiops version does not match the Khiops Python library version
1082-
# Note: Currently the check is very strict. It may be loosened in the future
1083-
# (major.minor.patch must be the same)
1082+
# Library version
10841083
compatible_khiops_version = khiops.get_compatible_khiops_version()
1084+
1085+
operating_system = platform.system()
1086+
installation_method = _infer_khiops_installation_method()
1087+
1088+
# Fail immediately if the major versions differ
1089+
# Note: the installation status will not show at all
1090+
if self.khiops_version.major != compatible_khiops_version.major:
1091+
raise KhiopsRuntimeError(
1092+
f"Major version '{self.khiops_version.major}' of the Khiops "
1093+
"executables does not match the Khiops Python library major version "
1094+
f"'{compatible_khiops_version.major}'. "
1095+
"To avoid any compatibility error, "
1096+
"please update either the Khiops "
1097+
f"executables package for your '{operating_system}' operating "
1098+
"system, or the Khiops Python library, "
1099+
f"according to your '{installation_method}' environment. "
1100+
"See https://khiops.org for more information.",
1101+
)
1102+
1103+
# Warn if the khiops minor and patch versions do not match
1104+
# the Khiops Python library ones
10851105
# KhiopsVersion implements the equality operator, which however also
10861106
# takes pre-release tags into account.
10871107
# The restriction here does not apply to pre-release tags
10881108
if (
1089-
self.khiops_version.major,
10901109
self.khiops_version.minor,
10911110
self.khiops_version.patch,
10921111
) != (
1093-
compatible_khiops_version.major,
10941112
compatible_khiops_version.minor,
10951113
compatible_khiops_version.patch,
10961114
):
1097-
operating_system = platform.system()
1098-
installation_method = _infer_khiops_installation_method()
10991115
warnings.warn(
11001116
f"Version '{self._khiops_version}' of the Khiops executables "
11011117
"does not match the Khiops Python library version "
1102-
f"'{khiops.__version__}' (different major.minor.patch version). "
1118+
f"'{khiops.__version__}' (different minor.patch version). "
11031119
"There may be compatibility errors and "
11041120
"we recommend to update either the Khiops "
11051121
f"executables package for your '{operating_system}' operating "
@@ -1160,8 +1176,9 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11601176
f"Khiops Python library installation path '{library_root_dir}' "
11611177
"does not match the current Conda environment "
11621178
f"'{os.environ['CONDA_PREFIX']}'. "
1163-
"Please install the Khiops Python library "
1164-
"in the current Conda environment. "
1179+
"Either deactivate the current Conda environment "
1180+
"or use the Khiops Python library "
1181+
"belonging to the current Conda environment. "
11651182
"Go to https://khiops.org for instructions.\n"
11661183
)
11671184
error_list.append(error)
@@ -1172,7 +1189,7 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
11721189
f"Khiops binary path '{self.khiops_path}' "
11731190
"does not match the current Conda environment "
11741191
f"'{os.environ['CONDA_PREFIX']}'. "
1175-
"Please install the Khiops binary "
1192+
"We recommend installing the Khiops binary "
11761193
"in the current Conda environment. "
11771194
"Go to https://khiops.org for instructions.\n"
11781195
)

0 commit comments

Comments
 (0)