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
4 changes: 4 additions & 0 deletions .semversioner/next-release/patch-20260223204942781936.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "write stats.json per workflow"
}
15 changes: 11 additions & 4 deletions packages/graphrag/graphrag/index/run/run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ async def _run_pipeline(
last_workflow = "<startup>"

try:
await _dump_json(context)
await _dump_stats_json(context)
await _dump_context_json(context)

logger.info("Executing pipeline...")
for name, workflow_function in pipeline.run():
Expand All @@ -138,13 +139,15 @@ async def _run_pipeline(
workflow=name, result=result.result, state=context.state, error=None
)
context.stats.workflows[name] = profiler.metrics
await _dump_stats_json(context)
if result.stop:
logger.info("Halting pipeline at workflow request")
break

context.stats.total_runtime = time.time() - start_time
logger.info("Indexing pipeline complete.")
await _dump_json(context)
await _dump_stats_json(context)
await _dump_context_json(context)

except Exception as e:
logger.exception("error running workflow %s", last_workflow)
Expand All @@ -153,11 +156,15 @@ async def _run_pipeline(
)


async def _dump_json(context: PipelineRunContext) -> None:
"""Dump the stats and context state to the storage."""
async def _dump_stats_json(context: PipelineRunContext) -> None:
"""Dump stats state to storage."""
await context.output_storage.set(
"stats.json", json.dumps(asdict(context.stats), indent=4, ensure_ascii=False)
)


async def _dump_context_json(context: PipelineRunContext) -> None:
"""Dump context state to storage."""
# Dump context state, excluding additional_context
temp_context = context.state.pop(
"additional_context", None
Expand Down
Loading