Skip campus images in handbook generation for reliability
Browse files- app/services/normalizer.py +3 -10
app/services/normalizer.py
CHANGED
|
@@ -205,23 +205,16 @@ def normalize_university(
|
|
| 205 |
sec_map[k] = s
|
| 206 |
|
| 207 |
# Campus image
|
|
|
|
|
|
|
| 208 |
img_section = sec_map.get("campus_image") or sec_map.get("image")
|
| 209 |
campus_image = ""
|
| 210 |
campus_caption = ""
|
| 211 |
if img_section:
|
| 212 |
j = img_section.get("section_json", {})
|
| 213 |
if isinstance(j, dict):
|
| 214 |
-
campus_url = str(j.get("image_url", "")).strip()
|
| 215 |
campus_caption = str(j.get("caption", "")).strip()
|
| 216 |
-
|
| 217 |
-
embedded = fetch_image_data_uri(campus_url)
|
| 218 |
-
if embedded:
|
| 219 |
-
campus_image = embedded
|
| 220 |
-
stats["images_embedded"] = stats.get("images_embedded", 0) + 1
|
| 221 |
-
else:
|
| 222 |
-
stats["images_placeholder"] = stats.get("images_placeholder", 0) + 1
|
| 223 |
-
else:
|
| 224 |
-
stats["images_placeholder"] = stats.get("images_placeholder", 0) + 1
|
| 225 |
|
| 226 |
# Overview and website
|
| 227 |
resolved_website = (uni_raw.get("website") or "").strip()
|
|
|
|
| 205 |
sec_map[k] = s
|
| 206 |
|
| 207 |
# Campus image
|
| 208 |
+
# Disable university campus-image embedding in the generation path.
|
| 209 |
+
# Large per-school images were the main source of handbook timeouts in Space.
|
| 210 |
img_section = sec_map.get("campus_image") or sec_map.get("image")
|
| 211 |
campus_image = ""
|
| 212 |
campus_caption = ""
|
| 213 |
if img_section:
|
| 214 |
j = img_section.get("section_json", {})
|
| 215 |
if isinstance(j, dict):
|
|
|
|
| 216 |
campus_caption = str(j.get("caption", "")).strip()
|
| 217 |
+
stats["images_placeholder"] = stats.get("images_placeholder", 0) + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
# Overview and website
|
| 220 |
resolved_website = (uni_raw.get("website") or "").strip()
|