MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / WorkflowOrchestrator

Class WorkflowOrchestrator

scripts/workflow-orchestrator.py:56–277  ·  view source on GitHub ↗

Orchestrates the execution of modular workflows.

Source from the content-addressed store, hash-verified

54
55
56class WorkflowOrchestrator:
57 """Orchestrates the execution of modular workflows."""
58
59 def __init__(self, root_path: Path):
60 """Initialize the workflow orchestrator.
61
62 Args:
63 root_path: Root path of the project
64 """
65 self.root_path = root_path
66 self.status_file = root_path / ".github" / "workflow-status.json"
67 self.artifacts_dir = root_path / ".github" / "artifacts"
68 self.results: Dict[WorkflowPhase, WorkflowResult] = {}
69
70 # Ensure directories exist
71 self.status_file.parent.mkdir(parents=True, exist_ok=True)
72 self.artifacts_dir.mkdir(parents=True, exist_ok=True)
73
74 # Load existing status if available
75 self._load_status()
76
77 def _load_status(self):
78 """Load workflow status from file."""
79 if self.status_file.exists():
80 try:
81 with open(self.status_file, "r") as f:
82 data = json.load(f)
83
84 for phase_name, result_data in data.get("results", {}).items():
85 phase = WorkflowPhase(phase_name)
86 result = WorkflowResult(
87 phase=phase,
88 status=WorkflowStatus(result_data["status"]),
89 start_time=datetime.fromisoformat(result_data["start_time"]),
90 end_time=datetime.fromisoformat(result_data["end_time"]) if result_data.get("end_time") else None,
91 duration=result_data.get("duration"),
92 artifacts=result_data.get("artifacts", []),
93 error_message=result_data.get("error_message"),
94 )
95 self.results[phase] = result
96
97 except Exception as e:
98 print(f"Warning: Could not load workflow status: {e}")
99
100 def _save_status(self):
101 """Save workflow status to file."""
102 data = {"last_updated": datetime.now().isoformat(), "results": {}}
103
104 for phase, result in self.results.items():
105 data["results"][phase.value] = {
106 "status": result.status.value,
107 "start_time": result.start_time.isoformat(),
108 "end_time": result.end_time.isoformat() if result.end_time else None,
109 "duration": result.duration,
110 "artifacts": result.artifacts,
111 "error_message": result.error_message,
112 }
113

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected