Skip to content

Commit 70cc88d

Browse files
committed
cleanup logging messages
1 parent d8b0733 commit 70cc88d

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

graphrag/api/index.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async def build_index(
6868

6969
pipeline = PipelineFactory.create_pipeline(config, method, is_update_run)
7070

71+
logger.info("Pipeline started: %s", pipeline.names())
7172
workflow_callbacks.pipeline_start(pipeline.names())
7273

7374
async for output in run_pipeline(
@@ -83,6 +84,7 @@ async def build_index(
8384
logger.info("Workflow %s completed successfully", output.workflow)
8485
logger.debug(str(output.result))
8586

87+
logger.info("Pipeline completed with %d workflows", len(outputs))
8688
workflow_callbacks.pipeline_end(outputs)
8789
return outputs
8890

graphrag/callbacks/noop_workflow_callbacks.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ def __init__(self, logger_name: str = "graphrag"):
1919

2020
def pipeline_start(self, names: list[str]) -> None:
2121
"""Execute this callback to signal when the entire pipeline starts."""
22-
self.logger.info("Pipeline started: %s", names)
2322

2423
def pipeline_end(self, results: list[PipelineRunResult]) -> None:
2524
"""Execute this callback to signal when the entire pipeline ends."""
26-
self.logger.info("Pipeline completed with %d workflows", len(results))
2725

2826
def workflow_start(self, name: str, instance: object) -> None:
2927
"""Execute this callback when a workflow starts."""
30-
self.logger.info("Workflow started: %s", name)
3128

3229
def workflow_end(self, name: str, instance: object) -> None:
3330
"""Execute this callback when a workflow ends."""
34-
self.logger.info("Workflow completed: %s", name)
3531

3632
def progress(self, progress: Progress) -> None:
3733
"""Handle when progress occurs."""

graphrag/index/run/run_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ async def _run_pipeline(
116116

117117
for name, workflow_function in pipeline.run():
118118
last_workflow = name
119-
logger.info("Starting workflow: %s", name)
119+
logger.info("Workflow started: %s", name)
120120
context.callbacks.workflow_start(name, None)
121121
work_time = time.time()
122122
result = await workflow_function(config, context)
123-
logger.info("Completed workflow: %s", name)
123+
logger.info("Workflow completed: %s", name)
124124
context.callbacks.workflow_end(name, result)
125125
yield PipelineRunResult(
126126
workflow=name, result=result.result, state=context.state, errors=None

graphrag/index/workflows/create_base_text_units.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""A module containing run_workflow method definition."""
55

66
import json
7+
import logging
78
from typing import Any, cast
89

910
import pandas as pd
@@ -19,6 +20,8 @@
1920
from graphrag.logger.progress import Progress
2021
from graphrag.utils.storage import load_table_from_storage, write_table_to_storage
2122

23+
logger = logging.getLogger(__name__)
24+
2225

2326
async def run_workflow(
2427
config: GraphRagConfig,

graphrag/logger/progress.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
"""Progress reporting types."""
55

6+
import logging
67
from collections.abc import Callable, Iterable
78
from dataclasses import dataclass
89
from typing import TypeVar
910

1011
T = TypeVar("T")
12+
logger = logging.getLogger(__name__)
1113

1214

1315
@dataclass
@@ -24,7 +26,7 @@ class Progress:
2426
"""Total number of items"""
2527

2628
completed_items: int | None = None
27-
"""Number of items completed""" ""
29+
"""Number of items completed"""
2830

2931

3032
ProgressHandler = Callable[[Progress], None]
@@ -47,11 +49,11 @@ def __call__(self, num_ticks: int = 1) -> None:
4749
"""Emit progress."""
4850
self._num_complete += num_ticks
4951
if self._callback is not None:
50-
self._callback(
51-
Progress(
52-
total_items=self._num_total, completed_items=self._num_complete
53-
)
52+
p = Progress(
53+
total_items=self._num_total, completed_items=self._num_complete
5454
)
55+
logger.info("Progress: %s/%s", str(p.completed_items), str(p.total_items))
56+
self._callback(p)
5557

5658
def done(self) -> None:
5759
"""Mark the progress as done."""

graphrag/logger/standard_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def init_loggers(
136136
case ReportingType.console:
137137
# Only add console handler if not already added
138138
if not enable_console:
139-
handler = logging.StreamHandler(sys.stdout)
139+
handler = logging.StreamHandler()
140140
handler.setFormatter(formatter)
141141
logger.addHandler(handler)
142142
case ReportingType.blob:

0 commit comments

Comments
 (0)