-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyseTestResults.py
156 lines (130 loc) · 9.13 KB
/
analyseTestResults.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import json
from os import error
import numpy as np
def analysePrompts(loadfilename):
with open(loadfilename, "r") as file:
prompts = json.loads(file.read())
numFunctionsCreated = 0
numUnitTestsPassed = 0
numUnitTests = 0
numSuccessful = 0
numTests = 0
numAttempts = 0
numInterfaceSuccess = 0
statusList = {}
exceptionsList = {}
successfulList = []
for systemPromptIndex, systemPrompt in enumerate(prompts):
for tempIndex, temperature in enumerate(prompts[systemPrompt]):
for promptOptionIndex, promptOption in enumerate(prompts[systemPrompt][temperature]):
for promptNumber in prompts[systemPrompt][temperature][promptOption]:
for attemptNr, attempt in enumerate(prompts[systemPrompt][temperature][promptOption][promptNumber]["attempts"]):
currentAttempt = prompts[systemPrompt][temperature][promptOption][promptNumber]["attempts"][attemptNr]
numAttempts += 1
numTests += 1
if len(attempt["importParameters"]) > 0 and len(attempt["exportParameters"]) > 0:
numInterfaceSuccess += 1
numUnitTests+=attempt["tests"]
numUnitTestsPassed+=attempt["passed"]
for call in attempt["functionCalls"]:
status = list(call.items())[0][0] if len(list(call.items())) > 0 else "empty return value"
item: str = list(call.items())[0][1] if len(list(call.items())) > 0 else "empty return value"
if status == "exception":
if item.startswith('ExternalRuntimeError("field \'REFERENCE('):
item = 'ExternalRuntimeError("field \'REFERENCE(x)\' not found")'
elif item.startswith('ExternalRuntimeError("field \''):
item = 'ExternalRuntimeError("field \'x\' not found")'
elif item.startswith('FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_PARM_UNKNOWN'):
item = 'FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_PARM_UNKNOWN'
elif item.startswith('FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_NOT_FOUND'):
item = "FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_NOT_FOUND"
elif item.startswith('FunctionCall: RuntimeError 3 (rc=3): key=CONVT_NO_NUMBER'):
item = "FunctionCall: RuntimeError 3 (rc=3): key=CONVT_NO_NUMBER"
elif item.startswith('FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_NOT_REMOTE'):
item = "FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_NOT_REMOTE"
elif item.startswith('FunctionCall: TypeError: '):
item = "FunctionCall: TypeError"
statusList[status] = statusList.get(status, 0) + 1
exceptionsList[item] = exceptionsList.get(item, 0) + 1
break
if attempt["tests"] == attempt["passed"]:
numSuccessful += 1
successfulList.append({"systemPrompt": systemPrompt, "temperature": temperature, "promptOption": promptOption, "promptNumber": promptNumber, "attemptNr": attemptNr})
if attempt["functionCreated"] == "success":
numFunctionsCreated+=1
print(str(numFunctionsCreated) + " out of " + str(numAttempts) + " functions were successfully created")
print(str(numInterfaceSuccess) + " out of " + str(numAttempts) + " functions contained interfaces comments")
print(str(numUnitTestsPassed) + " out of " + str(numUnitTests) + " unit-tests were successful")
print(str(numSuccessful) + " out of " + str(numAttempts) + " tests were successful")
print(str(numAttempts - statusList["exception"] - numSuccessful) + " out of " + str(numAttempts) + "tests failed semantically")
print("-----Total Errors-----")
for key, value in statusList.items():
print(str(value) + "x " + str(key))
print("-----Exceptions-----")
for key, value in sorted(exceptionsList.items(), key=lambda item: item[1], reverse=True):
print(str(value) + "x " + str(key))
print("-----Successful Attempts-----")
for attempt in successfulList:
print(attempt)
print(len(successfulList))
def analysePromptsTestParameter(loadfilename):
with open(loadfilename, "r") as file:
prompts = json.loads(file.read())
summedFunctionsCreated = 0
summedSuccessful = 0
numTests = 0
for systemPromptIndex, systemPrompt in enumerate(prompts):
for tempIndex, temperature in enumerate(prompts[systemPrompt]):
for promptOptionIndex, promptOption in enumerate(prompts[systemPrompt][temperature]):
numFunctionsCreated = 0
numUnitTestsPassed = 0
numUnitTests = 0
numSuccessful = 0
numAttempts = 0
statusList = {}
exceptionsList = {}
successfulList = []
for promptNumber in prompts[systemPrompt][temperature][promptOption]:
for attemptNr, attempt in enumerate(prompts[systemPrompt][temperature][promptOption][promptNumber]["attempts"]):
currentAttempt = prompts[systemPrompt][temperature][promptOption][promptNumber]["attempts"][attemptNr]
numAttempts += 1
numTests += 1
numUnitTests+=attempt["tests"]
numUnitTestsPassed+=attempt["passed"]
for call in attempt["functionCalls"]:
status = list(call.items())[0][0] if len(list(call.items())) > 0 else "empty return value"
item: str = list(call.items())[0][1] if len(list(call.items())) > 0 else "empty return value"
if status == "exception":
if item.startswith('ExternalRuntimeError("field \'REFERENCE('):
item = 'ExternalRuntimeError("field \'REFERENCE(x)\' not found")'
elif item.startswith('ExternalRuntimeError("field \''):
item = 'ExternalRuntimeError("field \'x\' not found")'
elif item.startswith('FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_NOT_FOUND'):
item = "FunctionCall: RuntimeError 3 (rc=3): key=CALL_FUNCTION_NOT_FOUND"
elif item.startswith('FunctionCall: TypeError: '):
item = "FunctionCall: TypeError"
statusList[status] = statusList.get(status, 0) + 1
exceptionsList[item] = exceptionsList.get(item, 0) + 1
break
if attempt["tests"] == attempt["passed"]:
numSuccessful += 1
successfulList.append({"systemPrompt": systemPrompt, "temperature": temperature, "promptOption": promptOption, "promptNumber": promptNumber, "attemptNr": attemptNr})
if attempt["functionCreated"] == "success":
numFunctionsCreated+=1
summedFunctionsCreated += numFunctionsCreated
summedSuccessful += numSuccessful
print("Systemprompt: ", systemPromptIndex, "temperature: ", tempIndex, "promptOption: ", promptOptionIndex)
print(str(numFunctionsCreated) + " out of " + str(numAttempts) + " functions were successfully created")
print(str(numUnitTestsPassed) + " out of " + str(numUnitTests) + " unit-tests were successful")
print(str(numSuccessful) + " out of " + str(numAttempts) + " tests were successful")
# print("-----Total Errors-----")
# for key, value in statusList.items():
# print(str(value) + "x " + str(key))
# print("-----Exceptions-----")
# for key, value in sorted(exceptionsList.items(), key=lambda item: item[1], reverse=True):
# print(str(value) + "x " + str(key))
print("-----Successful Attempts-----")
for attempt in successfulList:
print(attempt)
print("summedFunctionsCreated " + str(summedFunctionsCreated))
print("summedSuccessful " + str(summedSuccessful))