Skip to content

Commit 8f8b6dd

Browse files
author
Lokeshwaran Boopathy
committed
Updated code review feature
1 parent e276bbb commit 8f8b6dd

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/backend/neploy-build-python/ml-code-optimiser.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# Evaluate the model
3232
y_pred = model.predict(X_test)
33-
print(classification_report(y_test, y_pred))
33+
#print(classification_report(y_test, y_pred))
3434

3535
# Read the file containing the Python smart contract script
3636
with open("test.py", "r") as f:
@@ -45,9 +45,12 @@
4545
prediction = model.predict(new_code_vectorized)[0]
4646

4747
# Print the improvement suggestions
48+
if not lines[i]:
49+
print("{}".format(lines[i]))
50+
continue
4851
if prediction == "optimize":
49-
print("Line {}: The following are the suggested optimization snippets:".format(i + 1))
50-
for snippet in model.predict_proba(new_code_vectorized)[0]:
51-
print(snippet)
52+
print("[optimised]: {}".format(lines[i]))
53+
#for snippet in model.predict_proba(new_code_vectorized)[0]:
54+
# print(snippet)
5255
else:
53-
print("Line {}: The code is fine.".format(i + 1))
56+
print("[ ok ]: {}".format(lines[i]))

src/backend/neploy-build-python/neploy-build-python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def optimise_endpoint():
6868
}
6969

7070
if result.returncode != 0:
71-
response_data["message"] = "Failed to optimise code"
71+
response_data["message"] = "Failed to review code"
7272
elif 'ERROR' in result.stderr:
73-
response_data["message"] = "Failed to optimise code"
73+
response_data["message"] = "Failed to review code"
7474
else:
75-
response_data["message"] = "Code is optmized successfully"
75+
response_data["message"] = "Code is reviewed successfully"
7676
return jsonify(response_data), 200
7777
except Exception as e:
7878
os.remove(temp_filename) # Delete the temporary file

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy