10
10
11
11
@pytest .fixture (scope = "module" )
12
12
def setup_file_structure ():
13
+ print ("Start file structure setup function" )
13
14
OUTPUT_PATH = "trained_models/test_tool"
14
15
DATA_PATH = "input/data/example_binary_titanic.csv"
15
16
@@ -33,23 +34,35 @@ def setup_file_structure():
33
34
except FileExistsError :
34
35
sys .exit ("Error: Model directory already exists" )
35
36
37
+ print ("finish file structure setup function" )
36
38
yield OUTPUT_PATH , DATA_PATH
37
39
38
40
# Remove the folder and its contents
39
41
shutil .rmtree (OUTPUT_PATH )
40
42
41
43
42
44
def test_main_script (setup_file_structure ):
45
+ print ("Start main calling function" )
43
46
OUTPUT_PATH , DATA_PATH = setup_file_structure
44
47
45
48
# Check platform, windows is different from linux/mac
46
49
if sys .platform == "win32" :
47
50
executable = ".ml2sql\\ Scripts\\ python.exe"
51
+ command = [
52
+ executable ,
53
+ "scripts\\ main.py" ,
54
+ "--name" ,
55
+ OUTPUT_PATH ,
56
+ "--data_path" ,
57
+ DATA_PATH ,
58
+ "--configuration" ,
59
+ "input\\ configuration\\ example_binary_titanic.json" ,
60
+ "--model" ,
61
+ "ebm" ,
62
+ ]
48
63
else :
49
64
executable = ".ml2sql/bin/python"
50
-
51
- result = subprocess .run (
52
- [
65
+ command = [
53
66
executable ,
54
67
"scripts/main.py" ,
55
68
"--name" ,
@@ -60,7 +73,10 @@ def test_main_script(setup_file_structure):
60
73
"input/configuration/example_binary_titanic.json" ,
61
74
"--model" ,
62
75
"ebm" ,
63
- ],
76
+ ]
77
+
78
+ result = subprocess .run (
79
+ command ,
64
80
# stdout=subprocess.PIPE,
65
81
capture_output = True ,
66
82
text = True ,
@@ -75,32 +91,45 @@ def test_main_script(setup_file_structure):
75
91
assert "Target column has 2 unique values" in result .stderr
76
92
assert "This problem will be treated as a classification problem" in result .stderr
77
93
94
+ print ("Finish calling main function" )
95
+
78
96
79
97
def test_modeltester_script (setup_file_structure ):
98
+ print ("Start calling modeltester function" )
80
99
OUTPUT_PATH , DATA_PATH = setup_file_structure
81
- MODEL_PATH = f"{ OUTPUT_PATH } /model/ebm_classification.sav"
82
- DATASET_NAME = DATA_PATH .split ("/" )[- 1 ].split ("." )[0 ]
83
- DESTINATION_PATH = f"{ OUTPUT_PATH } /tested_datasets/{ DATASET_NAME } "
100
+ DATASET_NAME = os .path .split (DATA_PATH )[- 1 ].split ("." )[0 ]
84
101
85
102
# Check platform, windows is different from linux/mac
86
103
if sys .platform == "win32" :
87
104
executable = ".ml2sql\\ Scripts\\ python.exe"
105
+ command = [
106
+ executable ,
107
+ "scripts\\ modeltester.py" ,
108
+ "--model_path" ,
109
+ f"{ OUTPUT_PATH } \\ model\\ ebm_classification.sav" ,
110
+ "--data_path" ,
111
+ DATA_PATH ,
112
+ "--destination_path" ,
113
+ f"{ OUTPUT_PATH } \\ tested_datasets\\ { DATASET_NAME } " ,
114
+ ]
88
115
else :
89
116
executable = ".ml2sql/bin/python"
90
-
91
- result = subprocess .run (
92
- [
117
+ command = [
93
118
executable ,
94
119
"scripts/modeltester.py" ,
95
120
"--model_path" ,
96
- MODEL_PATH ,
121
+ f" { OUTPUT_PATH } /model/ebm_classification.sav" ,
97
122
"--data_path" ,
98
123
DATA_PATH ,
99
124
"--destination_path" ,
100
- DESTINATION_PATH ,
101
- ],
125
+ f"{ OUTPUT_PATH } /tested_datasets/{ DATASET_NAME } " ,
126
+ ]
127
+
128
+ result = subprocess .run (
129
+ command ,
102
130
stdout = subprocess .PIPE ,
103
131
text = True ,
104
132
check = False ,
105
133
)
106
134
assert result .returncode == 0
135
+ print ("Finish calling modeltester function" )
0 commit comments