Skip to content

Commit 8632bc6

Browse files
committed
Create remote output dir if not existing, in remote tests
1 parent e09a9d2 commit 8632bc6

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

tests/test_remote_access.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# see the "LICENSE.md" file for more details. #
66
######################################################################################
77
"""Integration tests with remote filesystems and Khiops runners"""
8-
import io
98
import os
109
import shutil
1110
import signal
@@ -17,8 +16,6 @@
1716
from contextlib import suppress
1817
from urllib.request import Request, urlopen
1918

20-
import pandas as pd
21-
2219
import khiops.core as kh
2320
import khiops.core.internals.filesystems as fs
2421
from khiops.core.internals.runner import KhiopsLocalRunner
@@ -171,6 +168,16 @@ def test_train_predictor_with_remote_access(self):
171168
self.results_dir_root(),
172169
f"test_{self.remote_access_test_case()}_remote_files_{uuid.uuid4()}",
173170
)
171+
172+
# Attempt to make directory if not existing:
173+
# - make dir if local
174+
# - else, write "dir-like" object
175+
if not fs.exists(output_dir):
176+
if fs.is_local_resource(output_dir):
177+
fs.make_dir(output_dir)
178+
else:
179+
fs.write(f"{output_dir}/")
180+
174181
report_file_path = fs.get_child_path(output_dir, "IrisAnalysisResults.khj")
175182

176183
# When using `kh`, the log file will be by default
@@ -197,10 +204,20 @@ def test_train_predictor_fail_and_log_with_remote_access(self):
197204

198205
# no cleaning required as an exception would be raised
199206
# without any result produced
200-
output_dir = fs.get_child_path(
207+
self.folder_name_to_clean_in_teardown = output_dir = fs.get_child_path(
201208
self.results_dir_root(),
202209
f"test_{self.remote_access_test_case()}_remote_files_{uuid.uuid4()}",
203210
)
211+
212+
# Attempt to make directory if not existing:
213+
# - make dir if local
214+
# - else, write "dir-like" object
215+
if not fs.exists(output_dir):
216+
if fs.is_local_resource(output_dir):
217+
fs.make_dir(output_dir)
218+
else:
219+
fs.write(f"{output_dir}/")
220+
204221
report_file_path = fs.get_child_path(
205222
output_dir,
206223
"IrisAnalysisResults.khj",

0 commit comments

Comments
 (0)