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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Example: 10.2.1.4 is the 5th version that supports khiops 10.2.1.
- Internals: Changes in *Internals* sections are unlikely to be of interest for data scientists.

## 11.0.0.2 - 2026-01-23
## 11.0.0.2 - 2026-01-26

## Fixed
- (`core`) Samples dir path construction when HOME is a remote path
Expand Down
52 changes: 40 additions & 12 deletions tests/test_remote_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def setUp(self):
)
self.print_test_title()

# Save the runner that can be modified by the test
self.initial_runner = kh.get_runner()

def tearDown(self):
# Cleanup the output dir (the files within and the folder)
if hasattr(self, "folder_name_to_clean_in_teardown"):
Expand All @@ -160,6 +163,25 @@ def tearDown(self):
)
fs.remove(self.folder_name_to_clean_in_teardown)

# Restore the environment variables that can be left tained
# after a test failure
if hasattr(self, "env_vars_to_restore"):
for var_name in self.env_vars_to_restore:
# Delete 'var_name' from the environment if it was not
# in the environment at the beginning of each test
if (
self.env_vars_to_restore[var_name] is None
and os.environ.get(var_name) is not None
):
del os.environ[var_name]
# Set 'var_name' in the environment to the value it had
# before the beginning of each test
elif self.env_vars_to_restore.get(var_name) is not None:
os.environ[var_name] = self.env_vars_to_restore[var_name]

# Reset the current runner to the value it had before each test
kh.set_runner(self.initial_runner)

def test_train_predictor_with_remote_access(self):
"""Test train_predictor with remote resources"""
iris_data_dir = fs.get_child_path(kh.get_runner().samples_dir, "Iris")
Expand Down Expand Up @@ -227,16 +249,27 @@ def test_train_predictor_fail_and_log_with_remote_access(self):
self.assertTrue(fs.exists(log_file_path), f"Path: {log_file_path}")
fs.remove(log_file_path)

@unittest.skipIf(
docker_runner_config_exists(),
"Skip the remote path tests for docker runner",
)
def test_samples_dir_inferred_from_remote_home(self):
"""Test samples_dir is correctly inferred using a remote path in HOME"""

# Save initial state
# This runner has remote paths (for root_temp_dir for example)
initial_runner = kh.get_runner()
initial_home = os.environ.get("HOME")

# Set a remote path to HOME
os.environ["HOME"] = initial_runner.root_temp_dir
# Save the changed env vars in a dict that will be restored by tearDown
# even if the test fails
self.env_vars_to_restore = {}
for var_name in ("HOME", "KHIOPS_SAMPLES_DIR"):
print(f"Initial value of {var_name} = {os.environ.get(var_name)}")
self.env_vars_to_restore[var_name] = os.environ.get(var_name)

# The current runner kh.get_runner() has remote paths
# (in root_temp_dir attribute for example)
# Set this remote path to HOME
os.environ["HOME"] = kh.get_runner().root_temp_dir
# Delete KHIOPS_SAMPLES_DIR so that its value will be inferred using HOME
if os.environ.get("KHIOPS_SAMPLES_DIR") is not None:
del os.environ["KHIOPS_SAMPLES_DIR"]
test_runner = KhiopsLocalRunner()
kh.set_runner(test_runner)

Expand All @@ -249,11 +282,6 @@ def test_samples_dir_inferred_from_remote_home(self):
)
self.assertEqual(test_runner.samples_dir, expected_samples_dir)

# Restore initial state
if initial_home is not None:
os.environ["HOME"] = initial_home
kh.set_runner(initial_runner)


class KhiopsS3RemoteFileTests(KhiopsRemoteAccessTestsContainer.KhiopsRemoteAccessTests):
"""Integration tests with Amazon S3 filesystems"""
Expand Down
Loading