Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -141,66 +141,6 @@ def generate_css(line_counts, token_counts, cyclomatic_complexity, problem_type,
|
|
141 |
|
142 |
|
143 |
|
144 |
-
def generate_file(file_obj, user_string, user_number,dataset_choice):
|
145 |
-
tmpdir = 'tmpdir'
|
146 |
-
|
147 |
-
print('临时文件夹地址:{}'.format(tmpdir))
|
148 |
-
FilePath = file_obj.name
|
149 |
-
print('上传文件的地址:{}'.format(file_obj.name))
|
150 |
-
|
151 |
-
shutil.copy(file_obj.name, tmpdir)
|
152 |
-
|
153 |
-
|
154 |
-
FileName = os.path.basename(file_obj.name)
|
155 |
-
|
156 |
-
print(FilePath)
|
157 |
-
|
158 |
-
with open(FilePath, 'r', encoding="utf-8") as file_obj:
|
159 |
-
|
160 |
-
outputPath = os.path.join('F:/Desktop/test', FileName)
|
161 |
-
data = json.load(file_obj)
|
162 |
-
print("data:", data)
|
163 |
-
|
164 |
-
|
165 |
-
with open(outputPath, 'w', encoding="utf-8") as w:
|
166 |
-
json.dump(data, w, ensure_ascii=False, indent=4)
|
167 |
-
|
168 |
-
|
169 |
-
file_content = json.dumps(data)
|
170 |
-
url = "http://localhost:6222/submit"
|
171 |
-
files = {'file': (FileName, file_content, 'application/json')}
|
172 |
-
payload = {
|
173 |
-
'user_string': user_string,
|
174 |
-
'user_number': user_number,
|
175 |
-
'dataset_choice':dataset_choice
|
176 |
-
}
|
177 |
-
|
178 |
-
response = requests.post(url, files=files, data=payload)
|
179 |
-
print(response)
|
180 |
-
|
181 |
-
if response.status_code == 200:
|
182 |
-
|
183 |
-
output_data = response.json()
|
184 |
-
|
185 |
-
|
186 |
-
output_file_path = os.path.join('E:/python-testn/pythonProject3/hh_2/evaluate_result', 'new-model.json')
|
187 |
-
with open(output_file_path, 'w', encoding="utf-8") as f:
|
188 |
-
json.dump(output_data, f, ensure_ascii=False, indent=4)
|
189 |
-
|
190 |
-
print(f"File saved at: {output_file_path}")
|
191 |
-
|
192 |
-
|
193 |
-
directory_list = ['E:\python-testn\pythonProject3\hh_2\dividing_into_different_subsets\5\QS']
|
194 |
-
file_list = ["calculate_cata_result.py"]
|
195 |
-
|
196 |
-
execute_specified_python_files(directory_list, file_list)
|
197 |
-
|
198 |
-
return {"status": "success", "message": "File received and saved"}
|
199 |
-
else:
|
200 |
-
return {"status": "error", "message": response.text}
|
201 |
-
|
202 |
-
|
203 |
-
return {"status": "success", "message": response.text}
|
204 |
|
205 |
def update_radio_options(token_counts, line_counts, cyclomatic_complexity, problem_type):
|
206 |
options = []
|
|
|
141 |
|
142 |
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
def update_radio_options(token_counts, line_counts, cyclomatic_complexity, problem_type):
|
146 |
options = []
|