2024-09-17 17:04:42 -07:00
|
|
|
# Copyright (c) 2024 Microsoft Corporation.
|
|
|
|
# Licensed under the MIT License
|
|
|
|
|
2024-11-04 17:23:29 -08:00
|
|
|
from graphrag.index.run.utils import create_run_context
|
2024-09-17 17:04:42 -07:00
|
|
|
from graphrag.index.workflows.v1.create_final_communities import (
|
|
|
|
build_steps,
|
|
|
|
workflow_name,
|
|
|
|
)
|
|
|
|
|
|
|
|
from .util import (
|
|
|
|
compare_outputs,
|
|
|
|
get_workflow_output,
|
|
|
|
load_expected,
|
|
|
|
load_input_tables,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def test_create_final_communities():
|
|
|
|
input_tables = load_input_tables([
|
|
|
|
"workflow:create_base_entity_graph",
|
|
|
|
])
|
|
|
|
expected = load_expected(workflow_name)
|
|
|
|
|
2024-11-04 17:23:29 -08:00
|
|
|
context = create_run_context(None, None, None)
|
|
|
|
await context.runtime_storage.set(
|
|
|
|
"base_entity_graph", input_tables["workflow:create_base_entity_graph"]
|
|
|
|
)
|
|
|
|
|
2024-09-17 17:04:42 -07:00
|
|
|
steps = build_steps({})
|
|
|
|
|
|
|
|
actual = await get_workflow_output(
|
|
|
|
input_tables,
|
|
|
|
{
|
|
|
|
"steps": steps,
|
|
|
|
},
|
2024-11-04 17:23:29 -08:00
|
|
|
context=context,
|
2024-09-17 17:04:42 -07:00
|
|
|
)
|
|
|
|
|
2024-11-13 15:11:19 -08:00
|
|
|
# ignore the period and id columns, because they recalculated every time
|
|
|
|
assert "period" in expected.columns
|
|
|
|
assert "id" in expected.columns
|
2024-11-04 17:23:29 -08:00
|
|
|
columns = list(expected.columns.values)
|
|
|
|
columns.remove("period")
|
2024-11-13 15:11:19 -08:00
|
|
|
columns.remove("id")
|
2024-09-17 17:04:42 -07:00
|
|
|
compare_outputs(
|
2024-10-30 11:59:44 -06:00
|
|
|
actual,
|
|
|
|
expected,
|
2024-11-04 17:23:29 -08:00
|
|
|
columns=columns,
|
2024-09-17 17:04:42 -07:00
|
|
|
)
|