Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion mesh_missions/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,21 @@ def refresh_mission_runtime(self, mission: dict) -> dict:
cooperative_tasks.append(self.mesh.get_cooperative_task(task_id))
except Exception as exc:
cooperative_tasks.append({"id": task_id, "state": "failed", "error": str(exc), "children": []})
resolved_cooperative_jobs: dict[str, dict] = {}
for task in cooperative_tasks:
for child in list(task.get("children") or []):
job_id = str(child.get("job_id") or ((child.get("job") or {}).get("id")) or "").strip()
job = dict(child.get("job") or {})
job_id = str(child.get("job_id") or job.get("id") or "").strip()
if job_id and job_id not in child_job_ids:
child_job_ids.append(job_id)
if job_id and job:
job.setdefault("id", job_id)
resolved_cooperative_jobs[job_id] = job
child_jobs: list[dict] = []
for job_id in child_job_ids:
if job_id in resolved_cooperative_jobs:
child_jobs.append(resolved_cooperative_jobs[job_id])
continue
try:
child_jobs.append(self.mesh.get_job(job_id))
except Exception as exc:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_sovereign_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -7537,6 +7537,16 @@ def test_mission_wraps_cooperative_task_launch(self):
)
self.assertEqual(len(mission["lineage"]["cooperative_tasks"]), 1)

self.assertEqual(alpha.mesh.run_worker_once("alpha-worker")["status"], "completed")
self.assertEqual(beta.mesh.run_worker_once("beta-worker")["status"], "completed")
refreshed = alpha.mesh.get_mission(mission["id"])
self.assertEqual(refreshed["status"], "completed")
self.assertEqual(refreshed["summary"]["child_status_counts"], {"completed": 2})
self.assertEqual(
{job["target"] for job in refreshed["child_jobs"]},
{"alpha-node", "beta-node"},
)

def test_cooperative_task_endpoints_are_exposed_over_http(self):
alpha = self.make_stack("alpha")
beta = self.make_stack("beta")
Expand Down
Loading