Skip to content

Commit b87e1c1

Browse files
author
Thierry RAMORASOAVINA
committed
Ensure HOME env variable is always set (mandatory for OpenMPI 5+)
If it is missing the value of KHIOPS_MPI_HOME is copied
1 parent 18effc2 commit b87e1c1

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

khiops/core/internals/runner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,12 @@ def _initialize_khiops_environment(self):
994994
var_value = ""
995995
else:
996996
continue
997+
998+
if var_name == "KHIOPS_MPI_HOME":
999+
# Override HOME for OpenMPI 5+
1000+
os.environ["HOME"] = var_value
9971001
# Set paths to Khiops binaries
998-
if var_name == "KHIOPS_PATH":
1002+
elif var_name == "KHIOPS_PATH":
9991003
self.khiops_path = var_value
10001004
os.environ["KHIOPS_PATH"] = var_value
10011005
elif var_name == "KHIOPS_COCLUSTERING_PATH":

tests/test_khiops_integrations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ def test_runner_environment_initialization(self):
288288
.. note::
289289
To test a real initialization this test should be executed alone.
290290
"""
291+
292+
# Unset HOME to test the automatic fix for OpenMPI 5+
293+
del os.environ["HOME"]
294+
291295
# Obtain the current runner
292296
runner = kh.get_runner()
293297

@@ -304,6 +308,9 @@ def test_runner_environment_initialization(self):
304308
self.assertTrue(os.path.isfile(mpiexec_path))
305309
self.assertTrue(os.access(mpiexec_path, os.X_OK))
306310

311+
# Check `HOME` is always set (required for OpenMPI 5+)
312+
self.assertIsNotNone(os.environ["HOME"])
313+
307314
# Check that runner creation sets `KHIOPS_API_MODE` to `true`
308315
# Store original KHIOPS_API_MODE if any, then delete it from the
309316
# environment if present

0 commit comments

Comments
 (0)