-
Notifications
You must be signed in to change notification settings - Fork 65
fix: skip upserting edges when nodes don't exist #158
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 enhances the robustness of edge creation across different graph storage implementations by enforcing stricter validation. It ensures that edges are only established between pre-existing nodes, preventing the creation of orphaned edges or unintended implicit node generation. This change leads to more predictable graph states and improved data integrity within the graph generation process. 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 upsert_edge in both KuzuStorage and NetworkXStorage. Instead of creating nodes if they don't exist when an edge is being upserted, the new implementation skips the edge upsert operation if either the source or target node is missing. This change is consistent with the pull request's title and is applied uniformly across both storage backends.
My main feedback is regarding the use of print() to report that the edge upsert is being skipped. While this is consistent with other parts of the codebase, using the logging module would be a better practice for library code, as it provides more flexibility for consumers to handle log messages. I've left specific comments on this.
| print( | ||
| f"Cannot upsert edge {source_node_id}->{target_node_id} as one or both nodes do not exist." | ||
| ) |
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.
Using print() for logging is generally discouraged in library code because it's not configurable by the application using the library. It's better to use the logging module. This allows consumers to control log levels, format, and output destinations.
I suggest using logging.warning here. This also uses the recommended practice of passing arguments to logging methods to defer string formatting.
Note: You will need to add import logging at the top of the file.
| print( | |
| f"Cannot upsert edge {source_node_id}->{target_node_id} as one or both nodes do not exist." | |
| ) | |
| logging.warning( | |
| "Cannot upsert edge %s->%s as one or both nodes do not exist.", | |
| source_node_id, | |
| target_node_id, | |
| ) |
| print( | ||
| f"Cannot upsert edge {source_node_id} -> {target_node_id} because one or both nodes do not exist." | ||
| ) |
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.
As with the other storage implementation, using print() for logging is not ideal. Using the logging module provides better control for consumers of this library.
I suggest using logging.warning here. This also uses the recommended practice of passing arguments to logging methods to defer string formatting.
Note: You will need to add import logging at the top of the file.
| print( | |
| f"Cannot upsert edge {source_node_id} -> {target_node_id} because one or both nodes do not exist." | |
| ) | |
| logging.warning( | |
| "Cannot upsert edge %s -> %s because one or both nodes do not exist.", | |
| source_node_id, | |
| target_node_id, | |
| ) |
No description provided.