Skip to content

Commit a03bba3

Browse files
authored
Merge pull request #530 from KhiopsML/528-remote-home
Fix a buggy samples_dir path construction when HOME contains a remote path
2 parents 9d19781 + 9942c3e commit a03bba3

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
- Example: 10.2.1.4 is the 5th version that supports khiops 10.2.1.
77
- Internals: Changes in *Internals* sections are unlikely to be of interest for data scientists.
88

9+
## Unreleased
10+
11+
## Fixed
12+
- (`core`) Samples dir path construction when HOME is a remote path
13+
914
## 11.0.0.1 - 2026-01-14
1015

1116
### Fixed

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ ipykernel>=6.9.1
44
nbconvert==6.4.4
55
nbformat==5.3.0
66
numpydoc>=1.5.0
7-
pandas>=0.25.3
7+
pandas>=0.25.3,<=2.3.3
88
scikit-learn>=0.22.2,<=1.7.2
99
sphinx-copybutton>=0.5.0

khiops/core/internals/runner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import io
1616
import os
17-
import pathlib
1817
import platform
1918
import shlex
2019
import shutil
@@ -65,7 +64,11 @@ def get_default_samples_dir():
6564
elif platform.system() == "Windows" and "PUBLIC" in os.environ:
6665
samples_dir = os.path.join(os.environ["PUBLIC"], "khiops_data", "samples")
6766
else:
68-
samples_dir = str(pathlib.Path.home() / "khiops_data" / "samples")
67+
# The filesystem abstract layer is used here
68+
# as the path can be either local or remote
69+
samples_dir = fs.get_child_path(
70+
fs.get_child_path(os.environ["HOME"], "khiops_data"), "samples"
71+
)
6972
return samples_dir
7073

7174

packaging/conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ requirements:
2424
run:
2525
- python
2626
- khiops-core =11.0.0
27-
- pandas >=0.25.3
27+
- pandas >=0.25.3,<=2.3.3
2828
- scikit-learn >=0.22.2
2929
run_constrained:
3030
# do not necessary use the latest version

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ classifiers = [
104104
]
105105
requires-python = ">=3.8"
106106
dependencies = [
107-
"pandas>=0.25.3",
108-
# do not use the latest version, to avoid undesired breaking changes
107+
# do not use the latest versions, to avoid undesired breaking changes
108+
"pandas>=0.25.3,<=2.3.3",
109109
"scikit-learn>=0.22.2,<=1.7.2",
110110
]
111111

tests/test_remote_access.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,33 @@ def test_train_predictor_fail_and_log_with_remote_access(self):
227227
self.assertTrue(fs.exists(log_file_path), f"Path: {log_file_path}")
228228
fs.remove(log_file_path)
229229

230+
def test_samples_dir_inferred_from_remote_home(self):
231+
"""Test samples_dir is correctly inferred using a remote path in HOME"""
232+
233+
# Save initial state
234+
# This runner has remote paths (for root_temp_dir for example)
235+
initial_runner = kh.get_runner()
236+
initial_home = os.environ.get("HOME")
237+
238+
# Set a remote path to HOME
239+
os.environ["HOME"] = initial_runner.root_temp_dir
240+
test_runner = KhiopsLocalRunner()
241+
kh.set_runner(test_runner)
242+
243+
# Test the home path is indeed remote
244+
self.assertFalse(fs.is_local_resource(os.environ["HOME"]))
245+
246+
# Test that samples_dir is built according to the expectations
247+
expected_samples_dir = fs.get_child_path(
248+
fs.get_child_path(os.environ["HOME"], "khiops_data"), "samples"
249+
)
250+
self.assertEqual(test_runner.samples_dir, expected_samples_dir)
251+
252+
# Restore initial state
253+
if initial_home is not None:
254+
os.environ["HOME"] = initial_home
255+
kh.set_runner(initial_runner)
256+
230257

231258
class KhiopsS3RemoteFileTests(KhiopsRemoteAccessTestsContainer.KhiopsRemoteAccessTests):
232259
"""Integration tests with Amazon S3 filesystems"""

0 commit comments

Comments
 (0)