Spaces:
Sleeping
Sleeping
Push Bot
commited on
Commit
·
db31cfe
1
Parent(s):
6793c76
Debug: add image preview (first page) with PyMuPDF/pdfium; return PDF path from debug flows; chain .then to render image
Browse files
app.py
CHANGED
|
@@ -974,7 +974,7 @@ def _find_last_pipeline_zip():
|
|
| 974 |
return None
|
| 975 |
|
| 976 |
def debug_compile_last_pipeline_zip():
|
| 977 |
-
"""Find the most recent runs/*/output.zip from pipeline, compile, and preview
|
| 978 |
logs = [f"🐞 Debug(last-pipeline-zip) at {_now_str()}"]
|
| 979 |
last_zip = _find_last_pipeline_zip()
|
| 980 |
if not last_zip:
|
|
@@ -989,7 +989,7 @@ def debug_compile_last_pipeline_zip():
|
|
| 989 |
logs.append(f"❌ Auto-stage failed: {e}")
|
| 990 |
return "<div style='color:#b00'>No recent pipeline output.zip found and auto-stage failed.</div>"
|
| 991 |
else:
|
| 992 |
-
return "<div style='color:#b00'>No recent pipeline output.zip found under runs/.</div>"
|
| 993 |
|
| 994 |
# Prepare workspace
|
| 995 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
|
@@ -1006,7 +1006,7 @@ def debug_compile_last_pipeline_zip():
|
|
| 1006 |
except Exception as e:
|
| 1007 |
logs.append(f"❌ unzip failed: {e}")
|
| 1008 |
_write_logs(LOG_PATH, logs)
|
| 1009 |
-
return "<div style='color:#b00'>Unzip failed.</div>"
|
| 1010 |
|
| 1011 |
# Locate tex
|
| 1012 |
tex_path = None
|
|
@@ -1022,7 +1022,7 @@ def debug_compile_last_pipeline_zip():
|
|
| 1022 |
if tex_path is None:
|
| 1023 |
logs.append("❌ No .tex file found in last pipeline zip")
|
| 1024 |
_write_logs(LOG_PATH, logs)
|
| 1025 |
-
return "<div style='color:#b00'>No .tex found in last pipeline zip</div>"
|
| 1026 |
|
| 1027 |
# Ensure local fonts and theme precedence (same as other debug path)
|
| 1028 |
try:
|
|
@@ -1058,7 +1058,8 @@ def debug_compile_last_pipeline_zip():
|
|
| 1058 |
"<div style='color:#b00'><b>Compile failed.</b></div>"
|
| 1059 |
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
|
| 1060 |
+ "\n".join(logs)
|
| 1061 |
-
+ "</pre>"
|
|
|
|
| 1062 |
)
|
| 1063 |
try:
|
| 1064 |
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|
|
@@ -1068,11 +1069,11 @@ def debug_compile_last_pipeline_zip():
|
|
| 1068 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 1069 |
)
|
| 1070 |
_write_logs(LOG_PATH, logs)
|
| 1071 |
-
return html
|
| 1072 |
except Exception as e:
|
| 1073 |
logs.append(f"⚠️ preview failed: {e}")
|
| 1074 |
_write_logs(LOG_PATH, logs)
|
| 1075 |
-
return f"<div>Compiled but preview failed: {e}</div>"
|
| 1076 |
|
| 1077 |
def debug_compile_uploaded_zip(zip_file):
|
| 1078 |
"""Compile an uploaded poster zip (user-provided); return preview HTML + PDF path."""
|
|
@@ -1487,11 +1488,11 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 1487 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 1488 |
)
|
| 1489 |
_write_logs(LOG_PATH, logs)
|
| 1490 |
-
return html
|
| 1491 |
except Exception as e:
|
| 1492 |
logs.append(f"⚠️ preview failed: {e}")
|
| 1493 |
_write_logs(LOG_PATH, logs)
|
| 1494 |
-
return f"<div>Compiled but preview failed: {e}</div>"
|
| 1495 |
|
| 1496 |
def debug_compile_output_zip():
|
| 1497 |
"""Compile the repo-root output.zip (a real LaTeX project) and preview the resulting PDF."""
|
|
|
|
| 974 |
return None
|
| 975 |
|
| 976 |
def debug_compile_last_pipeline_zip():
|
| 977 |
+
"""Find the most recent runs/*/output.zip from pipeline, compile, and return preview HTML + PDF path."""
|
| 978 |
logs = [f"🐞 Debug(last-pipeline-zip) at {_now_str()}"]
|
| 979 |
last_zip = _find_last_pipeline_zip()
|
| 980 |
if not last_zip:
|
|
|
|
| 989 |
logs.append(f"❌ Auto-stage failed: {e}")
|
| 990 |
return "<div style='color:#b00'>No recent pipeline output.zip found and auto-stage failed.</div>"
|
| 991 |
else:
|
| 992 |
+
return "<div style='color:#b00'>No recent pipeline output.zip found under runs/.</div>", None
|
| 993 |
|
| 994 |
# Prepare workspace
|
| 995 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
|
|
|
| 1006 |
except Exception as e:
|
| 1007 |
logs.append(f"❌ unzip failed: {e}")
|
| 1008 |
_write_logs(LOG_PATH, logs)
|
| 1009 |
+
return "<div style='color:#b00'>Unzip failed.</div>", None
|
| 1010 |
|
| 1011 |
# Locate tex
|
| 1012 |
tex_path = None
|
|
|
|
| 1022 |
if tex_path is None:
|
| 1023 |
logs.append("❌ No .tex file found in last pipeline zip")
|
| 1024 |
_write_logs(LOG_PATH, logs)
|
| 1025 |
+
return "<div style='color:#b00'>No .tex found in last pipeline zip</div>", None
|
| 1026 |
|
| 1027 |
# Ensure local fonts and theme precedence (same as other debug path)
|
| 1028 |
try:
|
|
|
|
| 1058 |
"<div style='color:#b00'><b>Compile failed.</b></div>"
|
| 1059 |
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
|
| 1060 |
+ "\n".join(logs)
|
| 1061 |
+
+ "</pre>",
|
| 1062 |
+
None,
|
| 1063 |
)
|
| 1064 |
try:
|
| 1065 |
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|
|
|
|
| 1069 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 1070 |
)
|
| 1071 |
_write_logs(LOG_PATH, logs)
|
| 1072 |
+
return html, str(pdf_path)
|
| 1073 |
except Exception as e:
|
| 1074 |
logs.append(f"⚠️ preview failed: {e}")
|
| 1075 |
_write_logs(LOG_PATH, logs)
|
| 1076 |
+
return f"<div>Compiled but preview failed: {e}</div>", None
|
| 1077 |
|
| 1078 |
def debug_compile_uploaded_zip(zip_file):
|
| 1079 |
"""Compile an uploaded poster zip (user-provided); return preview HTML + PDF path."""
|
|
|
|
| 1488 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 1489 |
)
|
| 1490 |
_write_logs(LOG_PATH, logs)
|
| 1491 |
+
return html, str(pdf_path)
|
| 1492 |
except Exception as e:
|
| 1493 |
logs.append(f"⚠️ preview failed: {e}")
|
| 1494 |
_write_logs(LOG_PATH, logs)
|
| 1495 |
+
return f"<div>Compiled but preview failed: {e}</div>", None
|
| 1496 |
|
| 1497 |
def debug_compile_output_zip():
|
| 1498 |
"""Compile the repo-root output.zip (a real LaTeX project) and preview the resulting PDF."""
|