Spaces:
Sleeping
Sleeping
Commit
·
2e45e3f
1
Parent(s):
cd1d4e4
fix: CRITICAL - Store pipelines in BOTH session.pipelines_history AND pipelines collection
Browse files- Root cause: GET /pipelines reads from pipelines collection
- But _create_pipeline_record only wrote to session.pipelines_history
- Solution: Call pipeline_manager.create_pipeline_metadata() too
- Also updated _update_pipeline_status to update both locations
- Pipelines now appear in GET /sessions/{id}/pipelines endpoint
- Fixes empty pipelines array issue
- api_routes_v2.py +28 -1
api_routes_v2.py
CHANGED
|
@@ -259,14 +259,30 @@ def _create_pipeline_record(
|
|
| 259 |
"model_provider": pipeline_def.get("_model_provider"), # To be filled during execution
|
| 260 |
"model_name": pipeline_def.get("_model"),
|
| 261 |
"pipeline_s3_key": s3_key,
|
| 262 |
-
# Preview fields allowed in metadata
|
| 263 |
"result_preview": None
|
| 264 |
}
|
| 265 |
|
|
|
|
| 266 |
current_session = session_manager.get_session(session_id) or {}
|
| 267 |
hist = list(current_session.get("pipelines_history", []))
|
| 268 |
hist.insert(0, pipeline_meta)
|
| 269 |
session_manager.update_session(session_id, {"pipelines_history": hist})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
return pipeline_id
|
| 272 |
|
|
@@ -318,6 +334,17 @@ def _update_pipeline_status(pipeline_id: str, session_id: str, status: str, resu
|
|
| 318 |
p["result_preview"] = text[:500]
|
| 319 |
break
|
| 320 |
session_manager.update_session(session_id, {"pipelines_history": hist})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
except Exception:
|
| 322 |
pass
|
| 323 |
|
|
|
|
| 259 |
"model_provider": pipeline_def.get("_model_provider"), # To be filled during execution
|
| 260 |
"model_name": pipeline_def.get("_model"),
|
| 261 |
"pipeline_s3_key": s3_key,
|
|
|
|
| 262 |
"result_preview": None
|
| 263 |
}
|
| 264 |
|
| 265 |
+
# V3 CRITICAL: Update session.pipelines_history
|
| 266 |
current_session = session_manager.get_session(session_id) or {}
|
| 267 |
hist = list(current_session.get("pipelines_history", []))
|
| 268 |
hist.insert(0, pipeline_meta)
|
| 269 |
session_manager.update_session(session_id, {"pipelines_history": hist})
|
| 270 |
+
|
| 271 |
+
# V3 CRITICAL: Also create record in pipelines collection (for GET /pipelines endpoint)
|
| 272 |
+
try:
|
| 273 |
+
from services.pipeline_manager import get_pipeline_manager
|
| 274 |
+
pipeline_mgr = get_pipeline_manager()
|
| 275 |
+
pipeline_mgr.create_pipeline_metadata(
|
| 276 |
+
pipeline_id=pipeline_id,
|
| 277 |
+
session_id=session_id,
|
| 278 |
+
pipeline_name=pipeline_def.get("pipeline_name", "Untitled"),
|
| 279 |
+
s3_key=s3_key,
|
| 280 |
+
status=status,
|
| 281 |
+
created_by_message=""
|
| 282 |
+
)
|
| 283 |
+
except Exception as e:
|
| 284 |
+
print(f"Warning: Failed to create pipelines collection record: {e}")
|
| 285 |
+
# Don't fail the whole operation if this fails
|
| 286 |
|
| 287 |
return pipeline_id
|
| 288 |
|
|
|
|
| 334 |
p["result_preview"] = text[:500]
|
| 335 |
break
|
| 336 |
session_manager.update_session(session_id, {"pipelines_history": hist})
|
| 337 |
+
|
| 338 |
+
# 3. Also update pipelines collection (for GET /pipelines endpoint)
|
| 339 |
+
try:
|
| 340 |
+
from services.pipeline_manager import get_pipeline_manager
|
| 341 |
+
pipeline_mgr = get_pipeline_manager()
|
| 342 |
+
pipeline_mgr.update_pipeline_status(
|
| 343 |
+
pipeline_id=pipeline_id,
|
| 344 |
+
status=status
|
| 345 |
+
)
|
| 346 |
+
except Exception as e:
|
| 347 |
+
print(f"Warning: Failed to update pipelines collection: {e}")
|
| 348 |
except Exception:
|
| 349 |
pass
|
| 350 |
|