Skip to content

Commit

Permalink
Stabilize smoke tests for query community context building (#908)
Browse files Browse the repository at this point in the history
* Stabilize smoke tests for query community context building

* Fix CODEOWNERS
  • Loading branch information
AlonsoGuevara authored Aug 12, 2024
1 parent 073f650 commit 7fd23fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .semversioner/next-release/patch-20240812182118180884.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Stabilize smoke tests for query context building"
}
3 changes: 1 addition & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @microsoft/societal-resilience
* @microsoft/graphrag-core-team
* @microsoft/societal-resilience @microsoft/graphrag-core-team
14 changes: 8 additions & 6 deletions graphrag/query/context_builder/community_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

log = logging.getLogger(__name__)

NO_COMMUNITY_RECORDS_WARNING: str = (
"Warning: No community records added when building community context."
)


def build_community_context(
community_reports: list[CommunityReport],
Expand Down Expand Up @@ -128,9 +132,9 @@ def _cut_batch() -> None:
record_df = _convert_report_context_to_df(
context_records=batch_records,
header=header,
weight_column=community_weight_name
if entities and include_community_weight
else None,
weight_column=(
community_weight_name if entities and include_community_weight else None
),
rank_column=community_rank_name if include_community_rank else None,
)
if len(record_df) == 0:
Expand Down Expand Up @@ -163,9 +167,7 @@ def _cut_batch() -> None:
_cut_batch()

if len(all_context_records) == 0:
log.warning(
"Warning: No community records added when building community context."
)
log.warning(NO_COMMUNITY_RECORDS_WARNING)
return ([], {})

return all_context_text, {
Expand Down
9 changes: 8 additions & 1 deletion tests/smoke/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import pytest

from graphrag.index.storage.blob_pipeline_storage import BlobPipelineStorage
from graphrag.query.context_builder.community_context import (
NO_COMMUNITY_RECORDS_WARNING,
)

log = logging.getLogger(__name__)

Expand All @@ -25,6 +28,8 @@
# cspell:disable-next-line well-known-key
WELL_KNOWN_AZURITE_CONNECTION_STRING = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1"

KNOWN_WARNINGS = [NO_COMMUNITY_RECORDS_WARNING]


def _load_fixtures():
"""Load all fixtures from the tests/data folder."""
Expand Down Expand Up @@ -294,6 +299,8 @@ def test_fixture(
result.stderr if "No existing dataset at" not in result.stderr else ""
)

assert stderror == "", f"Query failed with error: {stderror}"
assert (
stderror == "" or stderror.replace("\n", "") in KNOWN_WARNINGS
), f"Query failed with error: {stderror}"
assert result.stdout is not None, "Query returned no output"
assert len(result.stdout) > 0, "Query returned empty output"

0 comments on commit 7fd23fa

Please sign in to comment.