ritianyu commited on
Commit
bc84e54
·
1 Parent(s): d084688
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -220,12 +220,17 @@ def _append_trace(trace_path: str, stage: str) -> None:
220
  handle.flush()
221
 
222
 
223
- def _read_trace(trace_path: str, max_lines: int = 12) -> str:
224
  trace_file = Path(trace_path)
225
  if not trace_file.exists():
226
  return ""
227
- lines = trace_file.read_text(encoding="utf-8").splitlines()
228
- return "\n".join(lines[-max_lines:])
 
 
 
 
 
229
 
230
 
231
  def _export_glb_from_points(xyz: np.ndarray, rgb: np.ndarray, output_path: Path) -> None:
@@ -368,7 +373,7 @@ def run_demo(
368
  return result.depth_vis, glb_path.as_posix(), download_files, status
369
  except Exception as exc:
370
  error_trace = traceback.format_exc()
371
- trace_summary = _read_trace(trace_path)
372
  Log.exception(f"[{request_id}] run_demo failed")
373
 
374
  # Classify the error for clearer diagnostics
@@ -387,13 +392,13 @@ def run_demo(
387
  else:
388
  error_message = f"Error [{request_id}] ({exc_type}): {exc}"
389
 
390
- if trace_summary:
391
- error_message = f"{error_message}\n\nLast worker stages:\n{trace_summary}"
392
- if os.getenv("INFINIDEPTH_SHOW_TRACEBACK", "0") == "1":
393
  error_message = f"{error_message}\n\n{error_trace}"
394
  # Always log full traceback to server logs (visible in HF Space Logs tab)
395
  Log.error(f"[{request_id}] trace_path={trace_path}")
396
- Log.error(f"[{request_id}] Last worker stages:\n{trace_summary or '<none>'}")
397
  Log.error(f"[{request_id}] Full traceback:\n{error_trace}")
398
  return None, None, [], error_message
399
 
 
220
  handle.flush()
221
 
222
 
223
+ def _read_trace(trace_path: str) -> str:
224
  trace_file = Path(trace_path)
225
  if not trace_file.exists():
226
  return ""
227
+ return trace_file.read_text(encoding="utf-8").rstrip()
228
+
229
+
230
+ def _should_show_full_traceback() -> bool:
231
+ if SPACE_RUNTIME:
232
+ return True
233
+ return os.getenv("INFINIDEPTH_SHOW_TRACEBACK", "0") == "1"
234
 
235
 
236
  def _export_glb_from_points(xyz: np.ndarray, rgb: np.ndarray, output_path: Path) -> None:
 
373
  return result.depth_vis, glb_path.as_posix(), download_files, status
374
  except Exception as exc:
375
  error_trace = traceback.format_exc()
376
+ trace_content = _read_trace(trace_path)
377
  Log.exception(f"[{request_id}] run_demo failed")
378
 
379
  # Classify the error for clearer diagnostics
 
392
  else:
393
  error_message = f"Error [{request_id}] ({exc_type}): {exc}"
394
 
395
+ if trace_content:
396
+ error_message = f"{error_message}\n\nWorker trace:\n{trace_content}"
397
+ if _should_show_full_traceback():
398
  error_message = f"{error_message}\n\n{error_trace}"
399
  # Always log full traceback to server logs (visible in HF Space Logs tab)
400
  Log.error(f"[{request_id}] trace_path={trace_path}")
401
+ Log.error(f"[{request_id}] Worker trace:\n{trace_content or '<none>'}")
402
  Log.error(f"[{request_id}] Full traceback:\n{error_trace}")
403
  return None, None, [], error_message
404