-
Notifications
You must be signed in to change notification settings - Fork 64
Fix/ignore unknown nodes #157
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
Conversation
Summary of ChangesHello @ChenZiHong-Gavin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the behavior of the knowledge graph builder when encountering edges with undefined source or target nodes. The change moves away from automatically generating placeholder 'UNKNOWN' nodes for missing entities. Instead, it prioritizes data integrity by logging a warning and preventing the creation of edges that do not have both endpoints explicitly defined within the graph. This ensures that only well-formed and complete relationships are added to the knowledge graph. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request changes the behavior of merge_edges when encountering an edge with source or target nodes that do not exist in the knowledge graph. Previously, it would create placeholder 'UNKNOWN' nodes. The new implementation logs a warning and skips merging the edge entirely. This change also removes logic that had a bug in calculating the length of these placeholder nodes. The new approach of ignoring edges with missing nodes is cleaner and avoids polluting the graph with incomplete 'UNKNOWN' entities.
| if not kg_instance.has_node(src_id) or not kg_instance.has_node(tgt_id): | ||
| logger.warning("Edge (%s, %s) has missing nodes.", src_id, tgt_id) | ||
| return {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type of this function (dict) is inconsistent with its definition in the base class BaseKGBuilder, where merge_edges is annotated to return None. This violates the Liskov Substitution Principle. While this is a pre-existing issue, it's good practice to ensure method signatures are consistent in an inheritance hierarchy. It is recommended to create a follow-up task to update the base class method's return type to dict to resolve this inconsistency.
This pull request changes the behavior of
merge_edgeswhen encountering an edge with source or target nodes that do not exist in the knowledge graph. Previously, it would create placeholder 'UNKNOWN' nodes. The new implementation logs a warning and skips merging the edge entirely. This change also removes logic that had a bug in calculating the length of these placeholder nodes. The new approach of ignoring edges with missing nodes is cleaner and avoids polluting the graph with incomplete 'UNKNOWN' entities.