Push Bot commited on
Commit
f2fe9ba
Β·
1 Parent(s): acd3aeb

Debug: add image preview (first page) with PyMuPDF/pdfium; return PDF path from debug flows; chain .then to render image

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -1851,7 +1851,8 @@ def debug_compile_output_zip():
1851
  if not zip_path.exists():
1852
  return (
1853
  "<div style='color:#b00'><b>output.zip not found at repo root.</b></div>"
1854
- + f"<div>Expected at: {zip_path}</div>"
 
1855
  )
1856
 
1857
  # Prepare workspace
@@ -2166,7 +2167,7 @@ def debug_compile_output_zip():
2166
  except Exception as e:
2167
  logs.append(f"❌ unzip failed: {e}")
2168
  _write_logs(LOG_PATH, logs)
2169
- return "<div style='color:#b00'>Unzip failed.</div>"
2170
 
2171
  # Locate poster_output.tex (fallback to poster.tex)
2172
  tex_path = None
@@ -2662,17 +2663,17 @@ def debug_compile_last_pipeline_zip():
2662
  + _pdf_to_iframe_html(pdf_path, height="700px")
2663
  )
2664
  _write_logs(LOG_PATH, logs)
2665
- return html
2666
  except Exception as e:
2667
  logs.append(f"⚠️ preview failed: {e}")
2668
  _write_logs(LOG_PATH, logs)
2669
- return f"<div>Compiled but preview failed: {e}</div>"
2670
 
2671
  def debug_compile_uploaded_zip(zip_file):
2672
- """Compile an uploaded poster zip (user-provided) and preview PDF."""
2673
  logs = [f"🐞 Debug(upload) at {_now_str()}"]
2674
  if not zip_file:
2675
- return "<div style='color:#b00'>Please upload a .zip file first.</div>"
2676
  # Prepare workspace
2677
  run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
2678
  work_zip_dir = WORK_DIR / "zip_upload"
@@ -2684,7 +2685,7 @@ def debug_compile_uploaded_zip(zip_file):
2684
  except Exception as e:
2685
  logs.append(f"❌ save upload failed: {e}")
2686
  _write_logs(LOG_PATH, logs)
2687
- return "<div style='color:#b00'>Save upload failed.</div>"
2688
  # Extract
2689
  try:
2690
  import zipfile as _zf
@@ -2693,7 +2694,7 @@ def debug_compile_uploaded_zip(zip_file):
2693
  except Exception as e:
2694
  logs.append(f"❌ unzip failed: {e}")
2695
  _write_logs(LOG_PATH, logs)
2696
- return "<div style='color:#b00'>Unzip failed.</div>"
2697
  # Find tex
2698
  tex_path = None
2699
  for name in ("poster_output.tex", "poster.tex"):
@@ -2737,7 +2738,8 @@ def debug_compile_uploaded_zip(zip_file):
2737
  "<div style='color:#b00'><b>Compile failed.</b></div>"
2738
  + "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
2739
  + "\n".join(logs)
2740
- + "</pre>"
 
2741
  )
2742
  try:
2743
  b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
 
1851
  if not zip_path.exists():
1852
  return (
1853
  "<div style='color:#b00'><b>output.zip not found at repo root.</b></div>"
1854
+ + f"<div>Expected at: {zip_path}</div>",
1855
+ None,
1856
  )
1857
 
1858
  # Prepare workspace
 
2167
  except Exception as e:
2168
  logs.append(f"❌ unzip failed: {e}")
2169
  _write_logs(LOG_PATH, logs)
2170
+ return "<div style='color:#b00'>Unzip failed.</div>", None
2171
 
2172
  # Locate poster_output.tex (fallback to poster.tex)
2173
  tex_path = None
 
2663
  + _pdf_to_iframe_html(pdf_path, height="700px")
2664
  )
2665
  _write_logs(LOG_PATH, logs)
2666
+ return html, str(pdf_path)
2667
  except Exception as e:
2668
  logs.append(f"⚠️ preview failed: {e}")
2669
  _write_logs(LOG_PATH, logs)
2670
+ return f"<div>Compiled but preview failed: {e}</div>", None
2671
 
2672
  def debug_compile_uploaded_zip(zip_file):
2673
+ """Compile an uploaded poster zip (user-provided); return preview HTML + PDF path."""
2674
  logs = [f"🐞 Debug(upload) at {_now_str()}"]
2675
  if not zip_file:
2676
+ return "<div style='color:#b00'>Please upload a .zip file first.</div>", None
2677
  # Prepare workspace
2678
  run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
2679
  work_zip_dir = WORK_DIR / "zip_upload"
 
2685
  except Exception as e:
2686
  logs.append(f"❌ save upload failed: {e}")
2687
  _write_logs(LOG_PATH, logs)
2688
+ return "<div style='color:#b00'>Save upload failed.</div>", None
2689
  # Extract
2690
  try:
2691
  import zipfile as _zf
 
2694
  except Exception as e:
2695
  logs.append(f"❌ unzip failed: {e}")
2696
  _write_logs(LOG_PATH, logs)
2697
+ return "<div style='color:#b00'>Unzip failed.</div>", None
2698
  # Find tex
2699
  tex_path = None
2700
  for name in ("poster_output.tex", "poster.tex"):
 
2738
  "<div style='color:#b00'><b>Compile failed.</b></div>"
2739
  + "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
2740
  + "\n".join(logs)
2741
+ + "</pre>",
2742
+ None,
2743
  )
2744
  try:
2745
  b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")