File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515import io
1616import os
17- import pathlib
1817import platform
1918import shlex
2019import 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 either be a local or a remote one
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
Original file line number Diff line number Diff line change @@ -227,6 +227,32 @@ 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+ os .environ ["HOME" ] = initial_home
254+ kh .set_runner (initial_runner )
255+
230256
231257class KhiopsS3RemoteFileTests (KhiopsRemoteAccessTestsContainer .KhiopsRemoteAccessTests ):
232258 """Integration tests with Amazon S3 filesystems"""
You can’t perform that action at this time.
0 commit comments