Skip to content

Commit b1e9e29

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 b1e9e29

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ 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+
# when initializing the KhiopsLocalRunner environment
294+
if os.environ.get("KHIOPS_MPI_HOME") is not None:
295+
del os.environ["HOME"]
296+
291297
# Obtain the current runner
292298
runner = kh.get_runner()
293299

@@ -304,6 +310,9 @@ def test_runner_environment_initialization(self):
304310
self.assertTrue(os.path.isfile(mpiexec_path))
305311
self.assertTrue(os.access(mpiexec_path, os.X_OK))
306312

313+
# Check `HOME` is always set (required for OpenMPI 5+)
314+
self.assertIsNotNone(os.environ.get("HOME"))
315+
307316
# Check that runner creation sets `KHIOPS_API_MODE` to `true`
308317
# Store original KHIOPS_API_MODE if any, then delete it from the
309318
# environment if present

0 commit comments

Comments
 (0)