Spaces:
Running
Running
Update app.py
#3
by Narendra5805 - opened
app.py
CHANGED
|
@@ -1543,16 +1543,25 @@ with gr.Blocks(title="AI Grading (Pandoc + pdflatex)") as demo:
|
|
| 1543 |
else:
|
| 1544 |
return error_msg, "", "", None, None
|
| 1545 |
|
| 1546 |
-
#
|
| 1547 |
-
qp_path
|
| 1548 |
-
|
| 1549 |
-
|
|
|
|
| 1550 |
|
| 1551 |
-
# Run the grading pipeline
|
| 1552 |
qpms_text, as_text, grading_text, grading_pdf_path, imprinted_pdf_path, output_urls = align_and_grade_pipeline(
|
| 1553 |
qp_path, ms_path, ans_path, subject=subject_choice, imprint=imprint_flag, run_timestamp=run_timestamp
|
| 1554 |
)
|
| 1555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1556 |
# Build URLs summary
|
| 1557 |
urls_summary = ""
|
| 1558 |
if supabase_client:
|
|
|
|
| 1543 |
else:
|
| 1544 |
return error_msg, "", "", None, None
|
| 1545 |
|
| 1546 |
+
# Only extract local paths
|
| 1547 |
+
qp_path = qp_file_obj.name
|
| 1548 |
+
ms_path = ms_file_obj.name
|
| 1549 |
+
ans_path = ans_file_obj.name
|
| 1550 |
+
run_timestamp = str(int(time.time())) # generate timestamp here
|
| 1551 |
|
| 1552 |
+
# Run the grading pipeline first
|
| 1553 |
qpms_text, as_text, grading_text, grading_pdf_path, imprinted_pdf_path, output_urls = align_and_grade_pipeline(
|
| 1554 |
qp_path, ms_path, ans_path, subject=subject_choice, imprint=imprint_flag, run_timestamp=run_timestamp
|
| 1555 |
)
|
| 1556 |
|
| 1557 |
+
# Only upload to Supabase if pipeline succeeded (no error string returned)
|
| 1558 |
+
input_urls = {"qp_url": None, "ms_url": None, "ans_url": None}
|
| 1559 |
+
if supabase_client and isinstance(qpms_text, str) and not qpms_text.startswith("❌"):
|
| 1560 |
+
print("\n📤 Uploading input files to Supabase (pipeline succeeded)...")
|
| 1561 |
+
input_urls["qp_url"] = upload_file_to_supabase(qp_path, "qp", run_timestamp)
|
| 1562 |
+
input_urls["ms_url"] = upload_file_to_supabase(ms_path, "ms", run_timestamp)
|
| 1563 |
+
input_urls["ans_url"] = upload_file_to_supabase(ans_path, "ans", run_timestamp)
|
| 1564 |
+
|
| 1565 |
# Build URLs summary
|
| 1566 |
urls_summary = ""
|
| 1567 |
if supabase_client:
|