Skip to content

Commit

Permalink
Remove $CONDA_PREFIX/bin from PATH when testing installation on UNIX …
Browse files Browse the repository at this point in the history
…/ Conda

Also remove all *CONDA* environment variables, so as to match
"Conda-based" environments as much as possible.

A "Conda-based" environment is a Conda environment whose packages are
launched outside of the environment, as e.g. when using the Khiops Python
library from a JuPyter notebook which:
- is installed outside the Conda environment where Khiops is installed
- uses a Python kernel (via the `ipykernel` Conda package) which is
  installed inside the Conda envirovnment.

This configuration results in two particularities:
- `sys.path` is correctly set according to the Conda environment (as
  the Python kernel is installed therein)
- `PATH` and the operating system environment (except for Python
  aspects) does not take this Conda environment into account:
  - `*CONDA*` variables are not set (most notably, `CONDA_PREFIX` is not
    set)
  - `$CONDA_PREFIX/bin` is not in the `PATH`.
  • Loading branch information
popescu-v committed Dec 4, 2024
1 parent bb5cf6e commit 3df48cf
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions .github/actions/test-khiops-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ runs:
using: composite
steps:
- name: Test that the executables are installed (Linux/macOS)
# We store path to khiops_env
# We remove $CONDA_PREFIX/bin from PATH (with effect only in Conda
# environments)
# We unset all *CONDA* variables (to test correct functioning of
# khiops_env in Conda-based environments)
# We call khiops_env a first time to test the calling of _khiopsgetprocnumber
# then we play with KHIOPS_PROC_NUMBER:
# - with KHIOPS_PROC_NUMBER=2, khiops should not use MPI, we check that KHIOPS_MPI_COMMAND is empty
Expand All @@ -19,13 +24,37 @@ runs:
OMPI_MCA_rmaps_base_oversubscribe: true
KHIOPS_MPI_VERBOSE: true
run: |
# Set khiops_env directory
KHIOPS_ENV_DIR=$(dirname $(type -P khiops_env))
# If CONDA_PREFIX is defined, then remove $CONDA_PREFIX/bin from the
# PATH and unset all *CONDA* environment variables
if [[ -n ${{ env.CONDA_PREFIX }} ]]
then
echo
echo --- CONDA_PREFIX is set to $CONDA_PREFIX
# Remove $CONDA_PREFIX/bin from the PATH
export PATH=$(echo $PATH | sed "s#$CONDA_PREFIX/bin:##g")
# Unset *CONDA* environment variables
# As a corrolary, CONDA_PREFIX is unset
# Note: There is no way to remove these variables from GITHUB_ENV
# (see https://github.com/actions/runner/issues/1126)
for CONDA_VAR in $(env | grep CONDA)
do
unset $(echo $CONDA_VAR | cut -d '=' -f 1)
done
fi
echo
echo --- Khiops environment with KHIOPS_PROC_NUMBER not set
khiops_env --env
# khiops_env is not in the path anymore, for Conda environments
$KHIOPS_ENV_DIR/khiops_env --env
echo
export KHIOPS_PROC_NUMBER=2
echo --- Khiops environment with KHIOPS_PROC_NUMBER=$KHIOPS_PROC_NUMBER
source khiops_env --env
source $KHIOPS_ENV_DIR/khiops_env --env
if [ ! -z "$KHIOPS_MPI_COMMAND" ];
then
echo "::error::MPI is used even though there are only 2 procs available"
Expand All @@ -34,7 +63,7 @@ runs:
echo
export KHIOPS_PROC_NUMBER=8
echo --- Khiops environment with KHIOPS_PROC_NUMBER=$KHIOPS_PROC_NUMBER
source khiops_env --env
source $KHIOPS_ENV_DIR/khiops_env --env
if [ ! -z "$KHIOPS_MPI_ERROR" ];
then
echo "::error::Unexpected MPI error: $KHIOPS_MPI_ERROR"
Expand All @@ -47,10 +76,10 @@ runs:
fi
echo
echo --- Khiops status
khiops -s
$KHIOPS_ENV_DIR/khiops -s
echo
echo --- Khiops Coclustering status
khiops_coclustering -s
$KHIOPS_ENV_DIR/khiops_coclustering -s
- name: Test that the executables are installed (windows)
if: runner.os == 'Windows'
shell: cmd /C call {0}
Expand Down

0 comments on commit 3df48cf

Please sign in to comment.