Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphrag_eval/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def update_steps_summary(
if step["status"] != "error":
try:
res = json.loads(step["output"])
if "results" in res and "bindings" in res["results"]:
if isinstance(res, dict) and "results" in res.keys() and "bindings" in res["results"]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is enough:

Suggested change
if isinstance(res, dict) and "results" in res.keys() and "bindings" in res["results"]:
if isinstance(res, dict) and "results" in res and "bindings" in res["results"]:

We do not need to specify .keys().

if not res["results"]["bindings"]:
template_steps_summary["empty_results"][name] += 1
except json.decoder.JSONDecodeError:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_aggregation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pathlib import Path

import yaml

from graphrag_eval import compute_aggregates

DATA_DIR = Path(__file__).parent / "test_data"


def test_compute_aggregates_doesnt_throw_exception():
# The issue was that the actual SPARQL query is a DESCRIBE query containing the string "results" in the text.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The issue was that the actual SPARQL query is a DESCRIBE query containing the string "results" in the text.
"""
Check that `compute_aggregates()` works when the actual SPARQL query
is a DESCRIBE query containing the string "results" in the text.
"""

evaluation_results_file = DATA_DIR / f"evaluation_3.yaml"
with open(evaluation_results_file, "r", encoding="utf-8") as yaml_file:
per_question_eval = yaml.safe_load(yaml_file)
compute_aggregates(per_question_eval)
Loading
Loading