Skip to content

Commit 63d7c38

Browse files
Run on custom benchmark
1 parent 2d7112d commit 63d7c38

File tree

5 files changed

+201
-33
lines changed

5 files changed

+201
-33
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,6 @@ src/config.yaml
178178
src/target_tools/ollama/src/fine_tuning/auto_generation/generated_dataset/*
179179
src/target_tools/ollama/src/fine_tuning/wandb/*
180180
src/target_tools/ollama/src/fine_tuning/outputs/*
181+
182+
# Ignore autogen files
183+
autogen/data

src/main_runner.py

+43-8
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def get_args():
7777
"--nocache", action="store_true", help="Do not use docker image cache."
7878
)
7979

80+
parser.add_argument("--custom_benchmark_dir", default=None, type=str)
81+
8082
return parser.parse_args()
8183

8284

@@ -89,35 +91,68 @@ def main():
8991
available_runners = {
9092
"headergen": (
9193
HeaderGenRunner,
92-
{"debug": args.debug, "nocache": args.nocache},
94+
{
95+
"debug": args.debug,
96+
"nocache": args.nocache,
97+
"custom_benchmark_dir": args.custom_benchmark_dir,
98+
},
9399
),
94100
"pyright": (
95101
PyrightRunner,
96-
{"debug": False, "nocache": args.nocache},
102+
{
103+
"debug": False,
104+
"nocache": args.nocache,
105+
"custom_benchmark_dir": args.custom_benchmark_dir,
106+
},
97107
),
98108
"scalpel": (
99109
ScalpelRunner,
100-
{"debug": False, "nocache": args.nocache},
110+
{
111+
"debug": False,
112+
"nocache": args.nocache,
113+
"custom_benchmark_dir": args.custom_benchmark_dir,
114+
},
101115
),
102116
"hityper": (
103117
HityperRunner,
104-
{"debug": False, "nocache": args.nocache},
118+
{
119+
"debug": False,
120+
"nocache": args.nocache,
121+
"custom_benchmark_dir": args.custom_benchmark_dir,
122+
},
105123
),
106124
"type4py": (
107125
Type4pyRunner,
108-
{"debug": False, "nocache": args.nocache},
126+
{
127+
"debug": False,
128+
"nocache": args.nocache,
129+
"custom_benchmark_dir": args.custom_benchmark_dir,
130+
},
109131
),
110132
"hityperdl": (
111133
HityperDLRunner,
112-
{"debug": False, "nocache": args.nocache},
134+
{
135+
"debug": False,
136+
"nocache": args.nocache,
137+
"custom_benchmark_dir": args.custom_benchmark_dir,
138+
},
113139
),
114140
"jedi": (
115141
JediRunner,
116-
{"debug": args.debug, "nocache": args.nocache},
142+
{
143+
"debug": args.debug,
144+
"nocache": args.nocache,
145+
"custom_benchmark_dir": args.custom_benchmark_dir,
146+
},
117147
),
118148
"ollama": (
119149
OllamaRunner,
120-
{"debug": args.debug, "nocache": args.nocache, "config": config},
150+
{
151+
"debug": args.debug,
152+
"nocache": args.nocache,
153+
"custom_benchmark_dir": args.custom_benchmark_dir,
154+
"config": config,
155+
},
121156
),
122157
# PySonar2Runner,
123158
# PytypeRunner,

src/result_analyzer/analysis_tables.py

+3
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ def create_comparison_table(stats):
475475

476476
def analysis_sensitivities_table(stats):
477477
stats = utils.sort_stats(stats)
478+
# check if sensitivity_sound_data is present in the stats
479+
if not stats[list(stats.keys())[0]].get("sensitivity_sound_data"):
480+
return
478481

479482
with open(f"tools_sensitivities_data.csv", "w", newline="") as csvfile:
480483
fieldnames = [

src/runner_class.py

+151-24
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ def __init__(
2121
dockerfile_name="Dockerfile",
2222
volumes={},
2323
nocache=False,
24+
custom_benchmark_dir=None,
2425
):
2526
self.docker_client = docker.from_env()
2627
self.tool_name = tool_name
2728
self.dockerfile_path = dockerfile_path
2829
self.dockerfile_name = dockerfile_name
2930
self.test_runner_script_path = f"/tmp/src/runner.py"
3031
self.benchmark_path = "/tmp/micro-benchmark"
32+
33+
if custom_benchmark_dir:
34+
self.local_benchmark_path = custom_benchmark_dir
35+
else:
36+
self.local_benchmark_path = os.path.abspath("../micro-benchmark")
37+
3138
self.host_results_path = host_results_path
3239
self.volumes = volumes
3340
self.nocache = nocache
@@ -79,7 +86,7 @@ def run_tool_test(self):
7986
self._build_docker_image()
8087
self.container = self.spawn_docker_instance()
8188

82-
src = "../micro-benchmark"
89+
src = self.local_benchmark_path
8390
dst = "/tmp"
8491
self.file_handler.copy_files_to_container(self.container, src, dst)
8592

@@ -103,35 +110,81 @@ def run_tool_test(self):
103110

104111

105112
class ScalpelRunner(TypeEvalPyRunner):
106-
def __init__(self, host_results_path, debug=False, nocache=False):
113+
def __init__(
114+
self,
115+
host_results_path,
116+
debug=False,
117+
nocache=False,
118+
custom_benchmark_dir=None,
119+
):
107120
super().__init__(
108-
"scalpel", "./target_tools/scalpel", host_results_path, nocache=nocache
121+
"scalpel",
122+
"./target_tools/scalpel",
123+
host_results_path,
124+
nocache=nocache,
125+
custom_benchmark_dir=custom_benchmark_dir,
109126
)
110127

111128

112129
class PyreRunner(TypeEvalPyRunner):
113-
def __init__(self, host_results_path, debug=False, nocache=False):
130+
def __init__(
131+
self,
132+
host_results_path,
133+
debug=False,
134+
nocache=False,
135+
custom_benchmark_dir=None,
136+
):
114137
super().__init__(
115-
"pyre", "./target_tools/pyre", host_results_path, nocache=nocache
138+
"pyre",
139+
"./target_tools/pyre",
140+
host_results_path,
141+
nocache=nocache,
142+
custom_benchmark_dir=custom_benchmark_dir,
116143
)
117144

118145

119146
class PyrightRunner(TypeEvalPyRunner):
120-
def __init__(self, host_results_path, debug=False, nocache=False):
147+
def __init__(
148+
self,
149+
host_results_path,
150+
debug=False,
151+
nocache=False,
152+
custom_benchmark_dir=None,
153+
):
121154
super().__init__(
122-
"pyright", "./target_tools/pyright", host_results_path, nocache=nocache
155+
"pyright",
156+
"./target_tools/pyright",
157+
host_results_path,
158+
nocache=nocache,
159+
custom_benchmark_dir=custom_benchmark_dir,
123160
)
124161

125162

126163
class PytypeRunner(TypeEvalPyRunner):
127-
def __init__(self, host_results_path, debug=False, nocache=False):
164+
def __init__(
165+
self,
166+
host_results_path,
167+
debug=False,
168+
nocache=False,
169+
custom_benchmark_dir=None,
170+
):
128171
super().__init__(
129-
"pytype", "./target_tools/pytype", host_results_path, nocache=nocache
172+
"pytype",
173+
"./target_tools/pytype",
174+
host_results_path,
175+
nocache=nocache,
176+
custom_benchmark_dir=custom_benchmark_dir,
130177
)
131178

132179

133180
class JediRunner(TypeEvalPyRunner):
134-
def __init__(self, host_results_path, debug=False, nocache=False):
181+
def __init__(
182+
self,
183+
host_results_path,
184+
debug=False,
185+
nocache=False,
186+
custom_benchmark_dir=None,
187+
):
135188
if debug:
136189
super().__init__(
137190
"jedi",
@@ -145,24 +198,49 @@ def __init__(self, host_results_path, debug=False, nocache=False):
145198
}
146199
},
147200
nocache=nocache,
201+
custom_benchmark_dir=custom_benchmark_dir,
148202
)
149203
else:
150204
super().__init__(
151-
"jedi", "./target_tools/jedi", host_results_path, nocache=nocache
205+
"jedi",
206+
"./target_tools/jedi",
207+
host_results_path,
208+
nocache=nocache,
209+
custom_benchmark_dir=custom_benchmark_dir,
152210
)
153211

154212

155213
class HityperRunner(TypeEvalPyRunner):
156-
def __init__(self, host_results_path, debug=False, nocache=False):
214+
def __init__(
215+
self,
216+
host_results_path,
217+
debug=False,
218+
nocache=False,
219+
custom_benchmark_dir=None,
220+
):
157221
super().__init__(
158-
"hityper", "./target_tools/hityper", host_results_path, nocache=nocache
222+
"hityper",
223+
"./target_tools/hityper",
224+
host_results_path,
225+
nocache=nocache,
226+
custom_benchmark_dir=custom_benchmark_dir,
159227
)
160228

161229

162230
class HityperDLRunner(TypeEvalPyRunner):
163-
def __init__(self, host_results_path, debug=False, nocache=False):
231+
def __init__(
232+
self,
233+
host_results_path,
234+
debug=False,
235+
nocache=False,
236+
custom_benchmark_dir=None,
237+
):
164238
super().__init__(
165-
"hityperdl", "./target_tools/hityperdl", host_results_path, nocache=nocache
239+
"hityperdl",
240+
"./target_tools/hityperdl",
241+
host_results_path,
242+
nocache=nocache,
243+
custom_benchmark_dir=custom_benchmark_dir,
166244
)
167245

168246
def spawn_docker_instance(self):
@@ -179,7 +257,13 @@ def spawn_docker_instance(self):
179257

180258

181259
class HeaderGenRunner(TypeEvalPyRunner):
182-
def __init__(self, host_results_path, debug=False, nocache=False):
260+
def __init__(
261+
self,
262+
host_results_path,
263+
debug=False,
264+
nocache=False,
265+
custom_benchmark_dir=None,
266+
):
183267
if debug:
184268
super().__init__(
185269
"headergen",
@@ -199,20 +283,41 @@ def __init__(self, host_results_path, debug=False, nocache=False):
199283
"./target_tools/headergen",
200284
host_results_path,
201285
nocache=nocache,
286+
custom_benchmark_dir=custom_benchmark_dir,
202287
)
203288

204289

205290
class PySonar2Runner(TypeEvalPyRunner):
206-
def __init__(self, host_results_path, debug=False, nocache=False):
291+
def __init__(
292+
self,
293+
host_results_path,
294+
debug=False,
295+
nocache=False,
296+
custom_benchmark_dir=None,
297+
):
207298
super().__init__(
208-
"pysonar2", "./target_tools/pysonar2", host_results_path, nocache=nocache
299+
"pysonar2",
300+
"./target_tools/pysonar2",
301+
host_results_path,
302+
nocache=nocache,
303+
custom_benchmark_dir=custom_benchmark_dir,
209304
)
210305

211306

212307
class Type4pyRunner(TypeEvalPyRunner):
213-
def __init__(self, host_results_path, debug=False, nocache=False):
308+
def __init__(
309+
self,
310+
host_results_path,
311+
debug=False,
312+
nocache=False,
313+
custom_benchmark_dir=None,
314+
):
214315
super().__init__(
215-
"type4py", "./target_tools/type4py", host_results_path, nocache=nocache
316+
"type4py",
317+
"./target_tools/type4py",
318+
host_results_path,
319+
nocache=nocache,
320+
custom_benchmark_dir=custom_benchmark_dir,
216321
)
217322

218323
def spawn_docker_instance(self):
@@ -229,9 +334,20 @@ def spawn_docker_instance(self):
229334

230335

231336
class OllamaRunner(TypeEvalPyRunner):
232-
def __init__(self, host_results_path, config, debug=False, nocache=False):
337+
def __init__(
338+
self,
339+
host_results_path,
340+
config,
341+
debug=False,
342+
nocache=False,
343+
custom_benchmark_dir=None,
344+
):
233345
super().__init__(
234-
"ollama", "./target_tools/ollama", host_results_path, nocache=nocache
346+
"ollama",
347+
"./target_tools/ollama",
348+
host_results_path,
349+
nocache=nocache,
350+
custom_benchmark_dir=custom_benchmark_dir,
235351
)
236352
self.config = config
237353

@@ -266,9 +382,20 @@ def copy_results_from_container(self):
266382

267383

268384
class OllamaRunner(TypeEvalPyRunner):
269-
def __init__(self, host_results_path, config, debug=False, nocache=False):
385+
def __init__(
386+
self,
387+
host_results_path,
388+
config,
389+
debug=False,
390+
nocache=False,
391+
custom_benchmark_dir=None,
392+
):
270393
super().__init__(
271-
"ollama", "./target_tools/ollama", host_results_path, nocache=nocache
394+
"ollama",
395+
"./target_tools/ollama",
396+
host_results_path,
397+
nocache=nocache,
398+
custom_benchmark_dir=custom_benchmark_dir,
272399
)
273400
self.config = config
274401

src/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def copy_files_to_container(self, container, src, dst):
88
# Create tar of micro-bench folder
99
temp_path = "/tmp/temp.tar"
1010
with tarfile.open(temp_path, "w:gz") as tar:
11-
base_folder = os.path.basename(src)
11+
base_folder = "micro-benchmark"
1212
tar.add(src, arcname=base_folder)
1313

1414
with open(temp_path, "rb") as file:

0 commit comments

Comments
 (0)