| 1 | from json import loads |
| 2 | from graphrag_sdk.orchestrator.step import PlanStep, StepBlockType |
| 3 | |
| 4 | |
| 5 | class ExecutionPlan: |
| 6 | |
| 7 | steps: list[PlanStep] = [] |
| 8 | |
| 9 | def __init__(self, steps: list[PlanStep]): |
| 10 | self.steps = steps |
| 11 | |
| 12 | @staticmethod |
| 13 | def from_json(json: str | dict) -> "ExecutionPlan": |
| 14 | if isinstance(json, str): |
| 15 | json = loads(json) |
| 16 | return ExecutionPlan([PlanStep.from_json(step) for step in json]) |
| 17 | |
| 18 | def to_json(self) -> dict: |
| 19 | return {"steps": [step.to_json() for step in self.steps]} |
| 20 | |
| 21 | def __str__(self) -> str: |
| 22 | return f"ExecutionPlan(steps={self.to_json()})" |