Spaces:
Sleeping
Sleeping
sethmcknight
commited on
Commit
·
f5bc2a6
1
Parent(s):
f60c17f
feat(startup): allow triggering embedding rebuild via env var
Browse files- src/app_factory.py +8 -0
src/app_factory.py
CHANGED
|
@@ -1091,6 +1091,14 @@ def create_app(
|
|
| 1091 |
except Exception as e:
|
| 1092 |
logging.warning(f"Failed to register document management blueprint: {e}")
|
| 1093 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1094 |
# Add Render-specific memory middleware if running on Render and
|
| 1095 |
# memory monitoring is enabled
|
| 1096 |
if is_render and memory_monitoring_enabled:
|
|
|
|
| 1091 |
except Exception as e:
|
| 1092 |
logging.warning(f"Failed to register document management blueprint: {e}")
|
| 1093 |
|
| 1094 |
+
# Conditionally run ingestion pipeline on startup based on environment variable
|
| 1095 |
+
if os.getenv("REBUILD_EMBEDDINGS_ON_START", "false").lower() == "true":
|
| 1096 |
+
with app.app_context():
|
| 1097 |
+
logging.info("REBUILD_EMBEDDINGS_ON_START is true, ensuring embeddings exist.")
|
| 1098 |
+
ensure_embeddings_on_startup()
|
| 1099 |
+
else:
|
| 1100 |
+
logging.info("REBUILD_EMBEDDINGS_ON_START is not set to true, skipping initial embedding.")
|
| 1101 |
+
|
| 1102 |
# Add Render-specific memory middleware if running on Render and
|
| 1103 |
# memory monitoring is enabled
|
| 1104 |
if is_render and memory_monitoring_enabled:
|