2024-09-19 16:38:01 -07:00
|
|
|
# Copyright (c) 2024 Microsoft Corporation.
|
|
|
|
|
# Licensed under the MIT License
|
|
|
|
|
|
2025-01-03 13:59:26 -08:00
|
|
|
|
2025-01-06 10:58:59 -08:00
|
|
|
from graphrag.callbacks.noop_workflow_callbacks import NoopWorkflowCallbacks
|
2025-01-03 13:59:26 -08:00
|
|
|
from graphrag.config.create_graphrag_config import create_graphrag_config
|
|
|
|
|
from graphrag.index.workflows.create_final_relationships import (
|
|
|
|
|
run_workflow,
|
2024-09-19 16:38:01 -07:00
|
|
|
workflow_name,
|
|
|
|
|
)
|
2025-01-03 13:59:26 -08:00
|
|
|
from graphrag.utils.storage import load_table_from_storage
|
2024-09-19 16:38:01 -07:00
|
|
|
|
|
|
|
|
from .util import (
|
2025-01-21 15:52:06 -08:00
|
|
|
DEFAULT_MODEL_CONFIG,
|
2024-09-19 16:38:01 -07:00
|
|
|
compare_outputs,
|
2025-01-03 13:59:26 -08:00
|
|
|
create_test_context,
|
2024-12-05 09:57:26 -08:00
|
|
|
load_test_table,
|
2024-09-19 16:38:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-01-03 13:59:26 -08:00
|
|
|
async def test_create_final_relationships():
|
2024-12-05 09:57:26 -08:00
|
|
|
expected = load_test_table(workflow_name)
|
2024-09-19 16:38:01 -07:00
|
|
|
|
2025-01-03 13:59:26 -08:00
|
|
|
context = await create_test_context(
|
|
|
|
|
storage=["base_relationship_edges"],
|
|
|
|
|
)
|
|
|
|
|
|
2025-01-21 15:52:06 -08:00
|
|
|
config = create_graphrag_config({"models": DEFAULT_MODEL_CONFIG})
|
2025-01-03 13:59:26 -08:00
|
|
|
|
|
|
|
|
await run_workflow(
|
|
|
|
|
config,
|
|
|
|
|
context,
|
2025-01-06 10:58:59 -08:00
|
|
|
NoopWorkflowCallbacks(),
|
2025-01-03 13:59:26 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
actual = await load_table_from_storage(workflow_name, context.storage)
|
2024-09-19 16:38:01 -07:00
|
|
|
|
2024-12-05 09:57:26 -08:00
|
|
|
assert "id" in expected.columns
|
|
|
|
|
columns = list(expected.columns.values)
|
|
|
|
|
columns.remove("id")
|
|
|
|
|
compare_outputs(actual, expected, columns)
|
|
|
|
|
assert len(actual.columns) == len(expected.columns)
|