Spaces:
Running
Running
burtenshaw
commited on
Commit
·
00ba9d0
1
Parent(s):
d19c5e3
restore caching
Browse files- app/app.py +18 -2
app/app.py
CHANGED
|
@@ -306,7 +306,19 @@ def step1_fetch_and_generate_presentation(url, progress=gr.Progress(track_tqdm=T
|
|
| 306 |
presentation_md = cached_data.get("presentation_md")
|
| 307 |
slides_data = cached_data.get("slides_data")
|
| 308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
if presentation_md and slides_data:
|
|
|
|
|
|
|
|
|
|
| 310 |
temp_dir = tempfile.mkdtemp()
|
| 311 |
md_path = os.path.join(temp_dir, "presentation.md")
|
| 312 |
try:
|
|
@@ -375,8 +387,11 @@ def step1_fetch_and_generate_presentation(url, progress=gr.Progress(track_tqdm=T
|
|
| 375 |
logger.error(f"Error writing cached markdown: {e}")
|
| 376 |
if os.path.exists(temp_dir):
|
| 377 |
shutil.rmtree(temp_dir)
|
|
|
|
|
|
|
| 378 |
else:
|
| 379 |
-
|
|
|
|
| 380 |
# --- Cache Miss or Failed Cache Load ---
|
| 381 |
logger.info(f"Cache miss for URL: {url}. Proceeding with generation.")
|
| 382 |
progress(0.1, desc="Fetching webpage content...")
|
|
@@ -1131,7 +1146,8 @@ with gr.Blocks(
|
|
| 1131 |
)
|
| 1132 |
with gr.Column(scale=4):
|
| 1133 |
gr.Markdown(
|
| 1134 |
-
"### Instructions\n1. Finalize notes below.\n2. Click 'Generate Audio'.\n3. Regenerate if needed.\n4. Go to next tab."
|
|
|
|
| 1135 |
|
| 1136 |
# Tab 4: Generate Video
|
| 1137 |
with gr.TabItem("4. Create Video", id=3):
|
|
|
|
| 306 |
presentation_md = cached_data.get("presentation_md")
|
| 307 |
slides_data = cached_data.get("slides_data")
|
| 308 |
|
| 309 |
+
if not presentation_md:
|
| 310 |
+
logger.warning(
|
| 311 |
+
f"Cache for {url} missing 'presentation_md'. Regenerating."
|
| 312 |
+
)
|
| 313 |
+
if not slides_data:
|
| 314 |
+
logger.warning(
|
| 315 |
+
f"Cache for {url} missing 'slides_data'. Regenerating."
|
| 316 |
+
)
|
| 317 |
+
|
| 318 |
if presentation_md and slides_data:
|
| 319 |
+
logger.info(
|
| 320 |
+
f"Found complete cache entry for {url} with {len(slides_data)} slides."
|
| 321 |
+
)
|
| 322 |
temp_dir = tempfile.mkdtemp()
|
| 323 |
md_path = os.path.join(temp_dir, "presentation.md")
|
| 324 |
try:
|
|
|
|
| 387 |
logger.error(f"Error writing cached markdown: {e}")
|
| 388 |
if os.path.exists(temp_dir):
|
| 389 |
shutil.rmtree(temp_dir)
|
| 390 |
+
# If writing cache fails, raise to trigger full regeneration flow
|
| 391 |
+
raise gr.Error(f"Failed to write cached markdown: {e}")
|
| 392 |
else:
|
| 393 |
+
# This case is now covered by the more specific logging above
|
| 394 |
+
pass # Continue to regeneration
|
| 395 |
# --- Cache Miss or Failed Cache Load ---
|
| 396 |
logger.info(f"Cache miss for URL: {url}. Proceeding with generation.")
|
| 397 |
progress(0.1, desc="Fetching webpage content...")
|
|
|
|
| 1146 |
)
|
| 1147 |
with gr.Column(scale=4):
|
| 1148 |
gr.Markdown(
|
| 1149 |
+
"### Instructions\n1. Finalize notes below.\n2. Click 'Generate Audio'.\n3. Regenerate if needed.\n4. Go to next tab."
|
| 1150 |
+
)
|
| 1151 |
|
| 1152 |
# Tab 4: Generate Video
|
| 1153 |
with gr.TabItem("4. Create Video", id=3):
|