Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions khiops/core/internals/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import io
import os
import pathlib
import platform
import shlex
import shutil
Expand Down Expand Up @@ -65,7 +64,11 @@ def get_default_samples_dir():
elif platform.system() == "Windows" and "PUBLIC" in os.environ:
samples_dir = os.path.join(os.environ["PUBLIC"], "khiops_data", "samples")
else:
samples_dir = str(pathlib.Path.home() / "khiops_data" / "samples")
# The filesystem abstract layer is used here
# as the path can be either local or remote
samples_dir = fs.get_child_path(
fs.get_child_path(os.environ["HOME"], "khiops_data"), "samples"
)
return samples_dir


Expand Down
27 changes: 27 additions & 0 deletions tests/test_remote_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,33 @@ 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)

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
test_runner = KhiopsLocalRunner()
kh.set_runner(test_runner)

# Test the home path is indeed remote
self.assertFalse(fs.is_local_resource(os.environ["HOME"]))

# Test that samples_dir is built according to the expectations
expected_samples_dir = fs.get_child_path(
fs.get_child_path(os.environ["HOME"], "khiops_data"), "samples"
)
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