Save plan_cid to database immediately after plan creation
- Add plan_cid column to pending_runs table schema - Add update_pending_run_plan() function to save plan_cid - Update get_pending_run() to return plan_cid - Save plan_cid right after storing plan to IPFS (before execution) - Plan is now available even if run fails Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -649,6 +649,24 @@ def execute_recipe(self, recipe_sexp: str, input_hashes: Dict[str, str], run_id:
|
||||
plan_path = CACHE_DIR / plan_cid
|
||||
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
plan_path.write_text(plan_sexp)
|
||||
|
||||
# Save plan_cid to database immediately so it's available even if run fails
|
||||
if run_id:
|
||||
import asyncio
|
||||
import database
|
||||
async def save_plan_cid():
|
||||
if database.pool is None:
|
||||
await database.init_db()
|
||||
await database.update_pending_run_plan(run_id, plan_cid)
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
if loop.is_running():
|
||||
asyncio.ensure_future(save_plan_cid())
|
||||
else:
|
||||
loop.run_until_complete(save_plan_cid())
|
||||
except RuntimeError:
|
||||
asyncio.run(save_plan_cid())
|
||||
logger.info(f"Saved plan_cid to pending run: {run_id}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to store plan to IPFS: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user