Spaces:
Sleeping
Sleeping
Push Bot
commited on
Commit
Β·
4cdcea7
1
Parent(s):
3e1704b
Fix SyntaxError; simplify debug; stage repo zip; make packages.txt empty
Browse files
app.py
CHANGED
|
@@ -572,58 +572,29 @@ def _ensure_left_logo_or_disable(OUTPUT_DIR: Path, logs):
|
|
| 572 |
return False
|
| 573 |
|
| 574 |
def debug_compile():
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
# Prepare workspace
|
| 578 |
-
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
| 579 |
-
dbg_dir = WORK_DIR / "debug"
|
| 580 |
-
dbg_dir.mkdir(parents=True, exist_ok=True)
|
| 581 |
-
tex_path = dbg_dir / "test.tex"
|
| 582 |
-
tex_path.write_text(r"""
|
| 583 |
-
\documentclass{article}
|
| 584 |
-
\usepackage[T1]{fontenc}
|
| 585 |
-
\usepackage{lmodern}
|
| 586 |
-
\usepackage[margin=1in]{geometry}
|
| 587 |
-
\begin{document}
|
| 588 |
-
Hello, PDF!\\
|
| 589 |
-
This is a debug build generated at \today.
|
| 590 |
-
\end{document}
|
| 591 |
-
""".strip(), encoding="utf-8")
|
| 592 |
-
|
| 593 |
-
logs.append(f"Workspace: runs/{WORK_DIR.name}")
|
| 594 |
-
logs.append(f"Writing: debug/test.tex")
|
| 595 |
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
|
|
|
| 600 |
return (
|
| 601 |
-
"<div style='color:#b00'><b>
|
| 602 |
-
+ "<
|
| 603 |
-
+ "\n".join(logs)
|
| 604 |
-
+ "</pre>"
|
| 605 |
)
|
| 606 |
-
|
| 607 |
-
|
| 608 |
try:
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
html = (
|
| 612 |
-
f"<div style='margin-bottom:8px'>{open_tab}</div>"
|
| 613 |
-
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 614 |
-
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px;margin-top:8px'>"
|
| 615 |
-
+ "\n".join(logs[-60:])
|
| 616 |
-
+ "</pre>"
|
| 617 |
-
)
|
| 618 |
_write_logs(LOG_PATH, logs)
|
| 619 |
-
return html
|
| 620 |
except Exception as e:
|
| 621 |
-
logs.append(f"
|
| 622 |
_write_logs(LOG_PATH, logs)
|
| 623 |
-
return
|
| 624 |
-
|
| 625 |
-
def debug_compile_output_zip():
|
| 626 |
-
"""Compile the repo-root output.zip (a real LaTeX project) and preview the resulting PDF."""
|
| 627 |
logs = [f"π Debug(real) at {_now_str()}"]
|
| 628 |
zip_path = ROOT / "output.zip"
|
| 629 |
if not zip_path.exists():
|
|
@@ -777,7 +748,18 @@ def debug_compile_last_pipeline_zip():
|
|
| 777 |
logs = [f"π Debug(last-pipeline-zip) at {_now_str()}"]
|
| 778 |
last_zip = _find_last_pipeline_zip()
|
| 779 |
if not last_zip:
|
| 780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 781 |
|
| 782 |
# Prepare workspace
|
| 783 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
|
@@ -1218,51 +1200,8 @@ def run_pipeline(arxiv_url, pdf_file, openai_key, logo_files, meeting_logo_file,
|
|
| 1218 |
|
| 1219 |
|
| 1220 |
def debug_compile():
|
| 1221 |
-
|
| 1222 |
-
|
| 1223 |
-
# Prepare workspace
|
| 1224 |
-
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
| 1225 |
-
dbg_dir = WORK_DIR / "debug"
|
| 1226 |
-
dbg_dir.mkdir(parents=True, exist_ok=True)
|
| 1227 |
-
tex_path = dbg_dir / "test.tex"
|
| 1228 |
-
tex_path.write_text(r"""
|
| 1229 |
-
\documentclass{article}
|
| 1230 |
-
\usepackage[T1]{fontenc}
|
| 1231 |
-
\usepackage{lmodern}
|
| 1232 |
-
\usepackage[margin=1in]{geometry}
|
| 1233 |
-
\begin{document}
|
| 1234 |
-
Hello, PDF!\\
|
| 1235 |
-
This is a debug build generated at \today.
|
| 1236 |
-
\end{document}
|
| 1237 |
-
""".strip(), encoding="utf-8")
|
| 1238 |
-
|
| 1239 |
-
logs.append(f"Workspace: runs/{WORK_DIR.name}")
|
| 1240 |
-
logs.append(f"Writing: debug/test.tex")
|
| 1241 |
-
|
| 1242 |
-
pdf_path = _compile_tex_to_pdf(tex_path, logs)
|
| 1243 |
-
if not pdf_path or not pdf_path.exists():
|
| 1244 |
-
logs.append("β Failed to compile debug PDF.")
|
| 1245 |
-
_write_logs(LOG_PATH, logs)
|
| 1246 |
-
return (
|
| 1247 |
-
"<div style='color:#b00'><b>Debug PDF compile failed.</b></div>"
|
| 1248 |
-
+ f"<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>{'\n'.join(logs)}</pre>"
|
| 1249 |
-
)
|
| 1250 |
-
|
| 1251 |
-
# Build preview + open-new-tab link
|
| 1252 |
-
try:
|
| 1253 |
-
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|
| 1254 |
-
open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
|
| 1255 |
-
html = (
|
| 1256 |
-
f"<div style='margin-bottom:8px'>{open_tab}</div>"
|
| 1257 |
-
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 1258 |
-
+ f"<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px;margin-top:8px'>{'\n'.join(logs[-60:])}</pre>"
|
| 1259 |
-
)
|
| 1260 |
-
_write_logs(LOG_PATH, logs)
|
| 1261 |
-
return html
|
| 1262 |
-
except Exception as e:
|
| 1263 |
-
logs.append(f"β οΈ Building preview failed: {e}")
|
| 1264 |
-
_write_logs(LOG_PATH, logs)
|
| 1265 |
-
return f"<div>Compiled but preview failed: {e}</div>"
|
| 1266 |
|
| 1267 |
|
| 1268 |
# =====================
|
|
@@ -1319,22 +1258,16 @@ The framework builds upon [CAMEL-ai](https://github.com/camel-ai/camel).
|
|
| 1319 |
pdf_out = gr.HTML(label="π Poster (PDF Preview)")
|
| 1320 |
zip_out = gr.File(label="π¦ Download Results (.zip)")
|
| 1321 |
overleaf_out = gr.HTML(label="Open in Overleaf")
|
| 1322 |
-
debug_btn = gr.Button("π Debug PDF", variant="secondary")
|
| 1323 |
-
debug_out = gr.HTML(label="π Debug Preview")
|
| 1324 |
debug_zip_btn= gr.Button("π Test repo output.zip", variant="secondary")
|
| 1325 |
debug_zip_out= gr.HTML(label="π Real Output Preview")
|
| 1326 |
debug_last_btn= gr.Button("π Test last pipeline zip", variant="secondary")
|
| 1327 |
debug_last_out= gr.HTML(label="π Last Pipeline Preview")
|
| 1328 |
-
debug_zip_upload = gr.File(label="π Upload poster zip", file_types=[".zip"])
|
| 1329 |
-
debug_zip_upload_out = gr.HTML(label="π Uploaded Zip Preview")
|
| 1330 |
run_btn.click(
|
| 1331 |
fn=run_pipeline,
|
| 1332 |
inputs=[arxiv_in, pdf_in, key_in, inst_logo_in, conf_logo_in, theme_in],
|
| 1333 |
outputs=[logs_out, pdf_out, zip_out, overleaf_out],
|
| 1334 |
)
|
| 1335 |
-
debug_btn.click(fn=debug_compile, inputs=[], outputs=[debug_out])
|
| 1336 |
debug_zip_btn.click(fn=debug_compile_output_zip, inputs=[], outputs=[debug_zip_out])
|
| 1337 |
-
debug_zip_upload.change(fn=debug_compile_uploaded_zip, inputs=[debug_zip_upload], outputs=[debug_zip_upload_out])
|
| 1338 |
debug_last_btn.click(fn=debug_compile_last_pipeline_zip, inputs=[], outputs=[debug_last_out])
|
| 1339 |
|
| 1340 |
if __name__ == "__main__":
|
|
|
|
| 572 |
return False
|
| 573 |
|
| 574 |
def debug_compile():
|
| 575 |
+
# Disabled minimal LaTeX debug; use the two pipeline-zip tests instead.
|
| 576 |
+
return "<div style='color:#555'>Minimal debug disabled. Use 'Test repo output.zip' or 'Test last pipeline zip'.</div>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
|
| 578 |
+
def debug_compile_output_zip():
|
| 579 |
+
"""Compile the repo-root output.zip (a real LaTeX project) and preview the resulting PDF."""
|
| 580 |
+
# Stage repo output.zip to runs/<id>/output.zip to follow pipeline layout, then delegate
|
| 581 |
+
zip_path = ROOT / "output.zip"
|
| 582 |
+
if not zip_path.exists():
|
| 583 |
return (
|
| 584 |
+
"<div style='color:#b00'><b>output.zip not found at repo root.</b></div>"
|
| 585 |
+
+ f"<div>Expected at: {zip_path}</div>"
|
|
|
|
|
|
|
| 586 |
)
|
| 587 |
+
logs = [f"π Stage(repo zip) at {_now_str()}"]
|
| 588 |
+
_, WORK_DIR, LOG_PATH, ZIP_PATH = _prepare_workspace(logs)
|
| 589 |
try:
|
| 590 |
+
shutil.copy2(zip_path, ZIP_PATH)
|
| 591 |
+
logs.append(f"π¦ Staged repo output.zip β runs/{WORK_DIR.name}/output.zip")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
_write_logs(LOG_PATH, logs)
|
|
|
|
| 593 |
except Exception as e:
|
| 594 |
+
logs.append(f"β Failed staging output.zip: {e}")
|
| 595 |
_write_logs(LOG_PATH, logs)
|
| 596 |
+
return "<div style='color:#b00'>Failed to stage output.zip</div>"
|
| 597 |
+
return debug_compile_last_pipeline_zip()
|
|
|
|
|
|
|
| 598 |
logs = [f"π Debug(real) at {_now_str()}"]
|
| 599 |
zip_path = ROOT / "output.zip"
|
| 600 |
if not zip_path.exists():
|
|
|
|
| 748 |
logs = [f"π Debug(last-pipeline-zip) at {_now_str()}"]
|
| 749 |
last_zip = _find_last_pipeline_zip()
|
| 750 |
if not last_zip:
|
| 751 |
+
repo_zip = ROOT / "output.zip"
|
| 752 |
+
if repo_zip.exists():
|
| 753 |
+
try:
|
| 754 |
+
_, W, L, Z = _prepare_workspace(logs)
|
| 755 |
+
shutil.copy2(repo_zip, Z)
|
| 756 |
+
logs.append(f"π¦ Auto-staged repo output.zip β runs/{W.name}/output.zip")
|
| 757 |
+
last_zip = Z
|
| 758 |
+
except Exception as e:
|
| 759 |
+
logs.append(f"β Auto-stage failed: {e}")
|
| 760 |
+
return "<div style='color:#b00'>No recent pipeline output.zip found and auto-stage failed.</div>"
|
| 761 |
+
else:
|
| 762 |
+
return "<div style='color:#b00'>No recent pipeline output.zip found under runs/.</div>"
|
| 763 |
|
| 764 |
# Prepare workspace
|
| 765 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
|
|
|
| 1200 |
|
| 1201 |
|
| 1202 |
def debug_compile():
|
| 1203 |
+
# Minimal debug disabled to simplify UI.
|
| 1204 |
+
return "<div style='color:#555'>Minimal debug disabled. Use 'Test repo output.zip' or 'Test last pipeline zip'.</div>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1205 |
|
| 1206 |
|
| 1207 |
# =====================
|
|
|
|
| 1258 |
pdf_out = gr.HTML(label="π Poster (PDF Preview)")
|
| 1259 |
zip_out = gr.File(label="π¦ Download Results (.zip)")
|
| 1260 |
overleaf_out = gr.HTML(label="Open in Overleaf")
|
|
|
|
|
|
|
| 1261 |
debug_zip_btn= gr.Button("π Test repo output.zip", variant="secondary")
|
| 1262 |
debug_zip_out= gr.HTML(label="π Real Output Preview")
|
| 1263 |
debug_last_btn= gr.Button("π Test last pipeline zip", variant="secondary")
|
| 1264 |
debug_last_out= gr.HTML(label="π Last Pipeline Preview")
|
|
|
|
|
|
|
| 1265 |
run_btn.click(
|
| 1266 |
fn=run_pipeline,
|
| 1267 |
inputs=[arxiv_in, pdf_in, key_in, inst_logo_in, conf_logo_in, theme_in],
|
| 1268 |
outputs=[logs_out, pdf_out, zip_out, overleaf_out],
|
| 1269 |
)
|
|
|
|
| 1270 |
debug_zip_btn.click(fn=debug_compile_output_zip, inputs=[], outputs=[debug_zip_out])
|
|
|
|
| 1271 |
debug_last_btn.click(fn=debug_compile_last_pipeline_zip, inputs=[], outputs=[debug_last_out])
|
| 1272 |
|
| 1273 |
if __name__ == "__main__":
|