Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,29 @@ jobs:
fi

# Print status
python -c \
"import sys; import khiops.core as kh; return_code = kh.get_runner().print_status(); sys.exit(return_code)"
RETCODE=$?
PATTERN=$(python -c \
"import sys; import khiops.core as kh; return_code = kh.get_runner().print_status(); sys.exit(return_code)" 2> >(grep -Ei 'with.*?unknown.*?installer') )
# The installation status check will fail
# because the library was not installed properly (the source code was only cloned)
if [ $RETCODE -ne 0 ]; then
if [ -n "$PATTERN" ]; then
echo "::error::Status error: improper setup, as expected: khiops-python has been cloned, not installed from a package"
fi

# Run integration tests on Ubuntu and Rocky
# Run the library against an incompatible Khiops (with a different major version)
# This instance of Khiops is isolated in a dedicated conda environment
CONDA="/root/miniforge3/bin/conda"
# Check an error is raised because of the major version mismatch
# The khiops-python library from the cloned sources is used here
PATTERN=$($CONDA run -n py3_khiops10_conda python -c "import khiops.core as kh; print(kh.get_runner().khiops_version)" 2> >(grep -Ei 'major version.*?does not match'))
if [ -z "$PATTERN" ]; then
echo "::error::Status error: khiops-python should fail because of the major version mismatch"
if [[ "${{ matrix.container }}" == "debian13" ]]; then
deactivate
fi
exit 1;
fi

# Run the remaining integration tests
python -m unittest -v tests.test_khiops_integrations

# Execute Khiops sample (train and deploy model), which uses MPI
Expand Down
39 changes: 28 additions & 11 deletions khiops/core/internals/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,30 +1076,46 @@ def _initialize_khiops_version(self):
error_msg += f"\nstderr: {stderr}" if stderr else ""
raise KhiopsRuntimeError(error_msg)

# Khiops core version
self._khiops_version = KhiopsVersion(khiops_version_str)

# Warn if the khiops version does not match the Khiops Python library version
# Note: Currently the check is very strict. It may be loosened in the future
# (major.minor.patch must be the same)
# Library version
compatible_khiops_version = khiops.get_compatible_khiops_version()

operating_system = platform.system()
installation_method = _infer_khiops_installation_method()

# Fail immediately if the major versions differ
# Note: the installation status will not show at all
if self.khiops_version.major != compatible_khiops_version.major:
raise KhiopsRuntimeError(
f"Major version '{self.khiops_version.major}' of the Khiops "
"executables does not match the Khiops Python library major version "
f"'{compatible_khiops_version.major}'. "
"To avoid any compatibility error, "
"please update either the Khiops "
f"executables package for your '{operating_system}' operating "
"system, or the Khiops Python library, "
f"according to your '{installation_method}' environment. "
"See https://khiops.org for more information.",
)

# Warn if the khiops minor and patch versions do not match
# the Khiops Python library ones
# KhiopsVersion implements the equality operator, which however also
# takes pre-release tags into account.
# The restriction here does not apply to pre-release tags
if (
self.khiops_version.major,
self.khiops_version.minor,
self.khiops_version.patch,
) != (
compatible_khiops_version.major,
compatible_khiops_version.minor,
compatible_khiops_version.patch,
):
operating_system = platform.system()
installation_method = _infer_khiops_installation_method()
warnings.warn(
f"Version '{self._khiops_version}' of the Khiops executables "
"does not match the Khiops Python library version "
f"'{khiops.__version__}' (different major.minor.patch version). "
f"'{khiops.__version__}' (different minor.patch version). "
"There may be compatibility errors and "
"we recommend to update either the Khiops "
f"executables package for your '{operating_system}' operating "
Expand Down Expand Up @@ -1160,8 +1176,9 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
f"Khiops Python library installation path '{library_root_dir}' "
"does not match the current Conda environment "
f"'{os.environ['CONDA_PREFIX']}'. "
"Please install the Khiops Python library "
"in the current Conda environment. "
"Either deactivate the current Conda environment "
"or use the Khiops Python library "
"belonging to the current Conda environment. "
"Go to https://khiops.org for instructions.\n"
)
error_list.append(error)
Expand All @@ -1172,7 +1189,7 @@ def _detect_library_installation_incompatibilities(self, library_root_dir):
f"Khiops binary path '{self.khiops_path}' "
"does not match the current Conda environment "
f"'{os.environ['CONDA_PREFIX']}'. "
"Please install the Khiops binary "
"We recommend installing the Khiops binary "
"in the current Conda environment. "
"Go to https://khiops.org for instructions.\n"
)
Expand Down
7 changes: 6 additions & 1 deletion packaging/docker/khiopspydev/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ RUN true \
$CONDA install -y -n py${version}_conda \
khiops-driver-s3==${KHIOPS_S3_DRIVER_REVISION} \
khiops-driver-gcs==${KHIOPS_GCS_DRIVER_REVISION}; \
done' \
done; \
# Install Khiops from a different major version in a dedicated conda environment \
# The python interpreter version of the base environment is used as no specific version is given \
$CONDA create -y -n py3_khiops10_conda; \
$CONDA install -y -n py3_khiops10_conda khiops::khiops-core==10.3.1; \
' \
&& true

RUN mkdir -p /scripts
Expand Down
9 changes: 7 additions & 2 deletions packaging/docker/khiopspydev/Dockerfile.rocky
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ RUN true \
do \
$CONDA create -y -n $CONDA_ENV python=${version}; \
done; \
$CONDA install -y -n py${version}_conda ${RC_LABEL}khiops-core=$(echo ${KHIOPS_REVISION} | tr -d "-") ; \
done' \
$CONDA install -y -n py${version}_conda ${RC_LABEL}khiops-core==$(echo ${KHIOPS_REVISION} | tr -d "-") ; \
done; \
# Install Khiops from a different major version in a dedicated conda environment \
# The python interpreter version of the base environment is used as no specific version is given \
$CONDA create -y -n py3_khiops10_conda; \
$CONDA install -y -n py3_khiops10_conda khiops::khiops-core==10.3.1; \
' \
&& true

RUN mkdir -p /scripts
Expand Down
7 changes: 6 additions & 1 deletion packaging/docker/khiopspydev/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ RUN true \
$CONDA install -y -n py${version}_conda \
khiops-driver-s3==${KHIOPS_S3_DRIVER_REVISION} \
khiops-driver-gcs==${KHIOPS_GCS_DRIVER_REVISION}; \
done' \
done; \
# Install Khiops from a different major version in a dedicated conda environment \
# The python interpreter version of the base environment is used as no specific version is given \
$CONDA create -y -n py3_khiops10_conda; \
$CONDA install -y -n py3_khiops10_conda khiops::khiops-core==10.3.1; \
' \
&& true

RUN mkdir -p /scripts
Expand Down
Loading