Update DCP write api to use BaseDC spanner schema#17
Update DCP write api to use BaseDC spanner schema#17clincoln8 wants to merge 55 commits intodatacommonsorg:mainfrom
Conversation
Summary of ChangesHello, 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 focuses on migrating the DCP write API to a new Spanner schema, enhancing data integrity and storage efficiency. The changes involve significant refactoring of the Highlights
Changelog
Activity
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
|
| curl -X POST "http://localhost:5000/nodes/" -H "Content-Type: application/json" -d @examples/people.jsonld | ||
| curl -X POST "http://localhost:5000/nodes" -H "Content-Type: application/json" -d @examples/people.jsonld | ||
|
|
||
| # With default provenance |
There was a problem hiding this comment.
Code Review
This pull request introduces a major and well-executed refactoring of the data ingestion and storage layer to use a more robust, relational graph model on Spanner, aligning with the BaseDC schema. The changes are extensive, touching everything from database models and services to configuration and testing. The introduction of synthesized nodes for literals and external entities is a solid architectural improvement, and the new comprehensive test suite is a great addition.
I've identified a critical issue in the drop_tables function which appears incomplete in the provided changes, and some minor inconsistencies in the updated README.md documentation. My detailed comments are below.
| logger.info("Dropping table %s", EDGE_TABLE_NAME) | ||
| query = f"DROP TABLE {EDGE_TABLE_NAME}" | ||
| self.session.execute(text(query)) |
There was a problem hiding this comment.
The drop_tables function is incomplete as shown in the diff. It only drops the Edge table. This will leave the Node table behind, which can cause issues when re-initializing the database, as Edge has foreign keys to Node. The Node table should also be dropped, and the transaction should be committed to ensure a clean state.
| logger.info("Dropping table %s", EDGE_TABLE_NAME) | |
| query = f"DROP TABLE {EDGE_TABLE_NAME}" | |
| self.session.execute(text(query)) | |
| logger.info("Dropping table %s", EDGE_TABLE_NAME) | |
| query = f"DROP TABLE {EDGE_TABLE_NAME}" | |
| self.session.execute(text(query)) | |
| logger.info("Dropping table %s", NODE_TABLE_NAME) | |
| query = f"DROP TABLE {NODE_TABLE_NAME}" | |
| self.session.execute(text(query)) | |
| self.session.commit() | |
| logger.info("Successfully dropped Node and Edge tables") |
| curl -X POST "http://localhost:5000/nodes/" -H "Content-Type: application/json" -d @examples/person-schema.jsonld | ||
|
|
||
| # With default provenance | ||
| curl -X POST "http://localhost:5000/nodes" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d @examples/person-schema.jsonld | ||
| ``` |
There was a problem hiding this comment.
The curl examples for uploading the schema are a bit redundant and inconsistent. The command on line 182 uses a trailing slash (/nodes/), while the new example on lines 185-187 does not. To avoid confusion and improve clarity, I recommend removing the first single-line command and keeping only the more descriptive multi-line version.
| curl -X POST "http://localhost:5000/nodes" -H "Content-Type: application/json" -d @examples/people.jsonld | ||
|
|
||
| # With default provenance | ||
| curl -X POST "http://localhost:5000/nodes" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d @examples/people.jsonld | ||
| ``` |
There was a problem hiding this comment.
No description provided.