Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knowledge graph query: graph query endpoints #2941

Merged
merged 20 commits into from
Mar 10, 2025

Conversation

jotare
Copy link
Contributor

@jotare jotare commented Mar 5, 2025

Description

Describe the proposed changes made in this PR.

How was this PR tested?

Describe how you tested this PR.

@jotare jotare requested a review from a team March 5, 2025 12:08
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 65.88235% with 87 lines in your changes missing coverage. Please review.

Project coverage is 83.94%. Comparing base (0ad193b) to head (5de2a67).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...liadb_models/src/nucliadb_models/graph/requests.py 0.00% 49 Missing ⚠️
...iadb_models/src/nucliadb_models/graph/responses.py 0.00% 25 Missing ⚠️
...cliadb/search/search/query_parser/parsers/graph.py 87.62% 12 Missing ⚠️
...liadb_models/src/nucliadb_models/graph/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2941      +/-   ##
==========================================
- Coverage   84.01%   83.94%   -0.07%     
==========================================
  Files         487      494       +7     
  Lines       35972    36210     +238     
  Branches    10966    10966              
==========================================
+ Hits        30222    30398     +176     
- Misses       5224     5285      +61     
- Partials      526      527       +1     
Flag Coverage Δ
nidx 77.60% <ø> (+0.05%) ⬆️
nucliadb 76.06% <93.33%> (+0.26%) ⬆️
nucliadb-ingest 40.56% <33.88%> (-0.13%) ⬇️
nucliadb-reader 41.90% <33.33%> (-0.17%) ⬇️
nucliadb-search 44.85% <33.88%> (-0.17%) ⬇️
nucliadb-standalone 46.00% <33.33%> (-0.19%) ⬇️
nucliadb-train 44.62% <33.88%> (-0.17%) ⬇️
nucliadb-writer 46.65% <33.33%> (-0.22%) ⬇️
nucliadb_dataset 55.45% <ø> (ø)
nucliadb_models 80.90% <0.00%> (-3.38%) ⬇️
nucliadb_sdk 93.01% <ø> (ø)
nucliadb_telemetry 86.53% <ø> (ø)
nucliadb_utils 84.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

def build_graph_response(results: list[nodereader_pb2.GraphSearchResponse]) -> GraphSearchResponse:
paths = []
for shard_results in results:
for pb_path in shard_results.graph:
Copy link
Contributor

Choose a reason for hiding this comment

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

This may return duplicated path if the same path is present in multiple shards. This also means that top_k is not correctly used with multiple shards. We need something a bit more involved to merge shard results.

It will be much more relevant for searching nodes/entities. This has to be addressed at some point, not necessarily in this PR.

@jotare jotare marked this pull request as draft March 5, 2025 14:42
@jotare jotare force-pushed the knowledge-graph-query--graph-query-endpoints branch 2 times, most recently from 180ad41 to 09ed4d9 Compare March 7, 2025 15:15
@@ -54,6 +54,10 @@ spec:
regex: '^/api/v\d+/kb/[^/]+/suggest'
method:
regex: "GET|OPTIONS"
- uri:
regex: '^/api/v\d+/kb/[^/]+/graph'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add /graph/nodes and /graph/relations when they are more ready

@jotare jotare marked this pull request as ready for review March 10, 2025 08:55
class GraphNode(BaseModel):
value: Optional[str] = None
match: NodeMatchKind = NodeMatchKind.EXACT
type: Optional[RelationNodeType] = RelationNodeType.ENTITY
Copy link
Contributor

Choose a reason for hiding this comment

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

if you set a default value that is not none, you can remove the Optional and assume will always be set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to provide the usual default but allow users to specify type=None, i.e., any type. I can remove the default if that's confusing

@jotare jotare force-pushed the knowledge-graph-query--graph-query-endpoints branch from b9ccc9a to d836bf3 Compare March 10, 2025 12:29
@jotare jotare merged commit 37c331d into main Mar 10, 2025
42 checks passed
@jotare jotare deleted the knowledge-graph-query--graph-query-endpoints branch March 10, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants