update error printing
Browse files- Dockerfile +1 -1
- app.py +14 -8
Dockerfile
CHANGED
|
@@ -24,4 +24,4 @@ ENV HOME=/home/user \
|
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
# Command to run the application
|
| 27 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--interface", "wsgi"]
|
|
|
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
# Command to run the application
|
| 27 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--interface", "wsgi", "--log-level", "debug"]
|
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from flask import Flask, render_template, request, jsonify
|
| 2 |
import numpy as np
|
|
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
import sys
|
|
@@ -68,14 +69,19 @@ def index():
|
|
| 68 |
|
| 69 |
@app.route('/process_sentence', methods=['POST'])
|
| 70 |
def process_sentence():
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# if __name__ == '__main__':
|
| 81 |
# _test_repo()
|
|
|
|
| 1 |
from flask import Flask, render_template, request, jsonify
|
| 2 |
import numpy as np
|
| 3 |
+
import traceback # <--- Add this import
|
| 4 |
import torch
|
| 5 |
|
| 6 |
import sys
|
|
|
|
| 69 |
|
| 70 |
@app.route('/process_sentence', methods=['POST'])
|
| 71 |
def process_sentence():
|
| 72 |
+
try:
|
| 73 |
+
req_data = request.json
|
| 74 |
+
sentence = req_data.get('sentence', '')
|
| 75 |
+
layer = int(req_data.get('layer', 5))
|
| 76 |
+
head = int(req_data.get('head', 0))
|
| 77 |
+
# Calculate data
|
| 78 |
+
results = model.forward(sentence, layer, head)
|
| 79 |
+
return jsonify({"status": "success", "data": results})
|
| 80 |
+
except Exception as e:
|
| 81 |
+
# 1. Print full error to the Server Logs (so you can see it in HF console)
|
| 82 |
+
print("Error processing request:", flush=True)
|
| 83 |
+
print(traceback.format_exc(), flush=True)
|
| 84 |
+
|
| 85 |
|
| 86 |
# if __name__ == '__main__':
|
| 87 |
# _test_repo()
|