Skip to content

Commit bd06d8b

Browse files
authored
Context property bag ("state") (#1774)
* Add pipeline state property bag to run context * Move state creation out of context util * Move callbacks into PipelineRunContext * Semver * Rename state.json to context.json to avoid confusion with stats.json * Expand smoke test row count * Add util to create storage and cache
1 parent a159426 commit bd06d8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+286
-272
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "Adds general-purpose pipeline run state object."
4+
}

graphrag/api/index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks
1515
from graphrag.config.enums import IndexingMethod
1616
from graphrag.config.models.graph_rag_config import GraphRagConfig
17-
from graphrag.index.run.pipeline_run_result import PipelineRunResult
1817
from graphrag.index.run.run_pipeline import run_pipeline
1918
from graphrag.index.run.utils import create_callback_chain
20-
from graphrag.index.typing import WorkflowFunction
19+
from graphrag.index.typing.pipeline_run_result import PipelineRunResult
20+
from graphrag.index.typing.workflow import WorkflowFunction
2121
from graphrag.index.workflows.factory import PipelineFactory
2222
from graphrag.logger.base import ProgressLogger
2323
from graphrag.logger.null_progress import NullProgressLogger

graphrag/callbacks/noop_workflow_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""A no-op implementation of WorkflowCallbacks."""
55

66
from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks
7-
from graphrag.index.run.pipeline_run_result import PipelineRunResult
7+
from graphrag.index.typing.pipeline_run_result import PipelineRunResult
88
from graphrag.logger.progress import Progress
99

1010

graphrag/callbacks/workflow_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from typing import Protocol
77

8-
from graphrag.index.run.pipeline_run_result import PipelineRunResult
8+
from graphrag.index.typing.pipeline_run_result import PipelineRunResult
99
from graphrag.logger.progress import Progress
1010

1111

graphrag/callbacks/workflow_callbacks_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""A module containing the WorkflowCallbacks registry."""
55

66
from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks
7-
from graphrag.index.run.pipeline_run_result import PipelineRunResult
7+
from graphrag.index.typing.pipeline_run_result import PipelineRunResult
88
from graphrag.logger.progress import Progress
99

1010

graphrag/cli/query.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from graphrag.config.load_config import load_config
1414
from graphrag.config.models.graph_rag_config import GraphRagConfig
1515
from graphrag.logger.print_progress import PrintProgressLogger
16-
from graphrag.storage.factory import StorageFactory
16+
from graphrag.utils.api import create_storage_from_config
1717
from graphrag.utils.storage import load_table_from_storage, storage_has_table
1818

1919
if TYPE_CHECKING:
@@ -497,10 +497,7 @@ def _resolve_output_files(
497497
dataframe_dict["num_indexes"] = len(config.outputs)
498498
dataframe_dict["index_names"] = config.outputs.keys()
499499
for output in config.outputs.values():
500-
output_config = output.model_dump()
501-
storage_obj = StorageFactory().create_storage(
502-
storage_type=output_config["type"], kwargs=output_config
503-
)
500+
storage_obj = create_storage_from_config(output)
504501
for name in output_list:
505502
if name not in dataframe_dict:
506503
dataframe_dict[name] = []
@@ -527,10 +524,7 @@ def _resolve_output_files(
527524
return dataframe_dict
528525
# Loading output files for single-index search
529526
dataframe_dict["multi-index"] = False
530-
output_config = config.output.model_dump()
531-
storage_obj = StorageFactory().create_storage(
532-
storage_type=output_config["type"], kwargs=output_config
533-
)
527+
storage_obj = create_storage_from_config(config.output)
534528
for name in output_list:
535529
df_value = asyncio.run(load_table_from_storage(name=name, storage=storage_obj))
536530
dataframe_dict[name] = df_value

graphrag/index/context.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

graphrag/index/operations/build_noun_graph/build_noun_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from graphrag.index.operations.build_noun_graph.np_extractors.base import (
1414
BaseNounPhraseExtractor,
1515
)
16-
from graphrag.index.run.derive_from_rows import derive_from_rows
16+
from graphrag.index.utils.derive_from_rows import derive_from_rows
1717
from graphrag.index.utils.hashing import gen_sha512_hash
1818

1919

graphrag/index/operations/extract_covariates/claim_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import tiktoken
1212

1313
from graphrag.config.defaults import ENCODING_MODEL, graphrag_config_defaults
14-
from graphrag.index.typing import ErrorHandlerFn
14+
from graphrag.index.typing.error_handler import ErrorHandlerFn
1515
from graphrag.language_model.protocol.base import ChatModel
1616
from graphrag.prompts.index.extract_claims import (
1717
CONTINUE_PROMPT,

graphrag/index/operations/extract_covariates/extract_covariates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Covariate,
2121
CovariateExtractionResult,
2222
)
23-
from graphrag.index.run.derive_from_rows import derive_from_rows
23+
from graphrag.index.utils.derive_from_rows import derive_from_rows
2424
from graphrag.language_model.manager import ModelManager
2525

2626
log = logging.getLogger(__name__)

0 commit comments

Comments
 (0)