-
Notifications
You must be signed in to change notification settings - Fork 42
Adding APIs to CreateGraphTemplate #132
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
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis change introduces several new Pydantic models and an enumeration to represent graph templates and their validation status. It adds an async controller function to upsert graph templates, updating or creating them with validation status handling. The API routing prefix and paths were adjusted, and a new authenticated PUT endpoint for graph template upsertion was added. A unique MongoDB index is specified for graph templates. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
participant DB
Client->>API: UpsertGraphTemplateRequest (name, namespace, nodes)
API->>DB: Find existing GraphTemplate by name & namespace
alt GraphTemplate exists
API->>DB: Update nodes, set validation_status to PENDING, clear validation_errors
else GraphTemplate not found
API->>DB: Insert new GraphTemplate with nodes, validation_status PENDING, empty validation_errors
end
DB-->>API: Confirmation with created_at, updated_at
API-->>Client: UpsertGraphTemplateResponse (name, namespace, nodes, validation_status, validation_errors, created_at, updated_at)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
state-manager/app/models/db/graph_template_model.py(1 hunks)state-manager/app/models/graph_models.py(1 hunks)state-manager/app/models/graph_template_validation_status.py(1 hunks)state-manager/app/models/node_template_model.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
state-manager/app/models/graph_template_validation_status.py (1)
state-manager/app/models/state_status_enum.py (1)
StateStatusEnum(4-14)
state-manager/app/models/db/graph_template_model.py (3)
state-manager/app/models/db/base.py (1)
BaseDatabaseModel(7-15)state-manager/app/models/graph_template_validation_status.py (1)
GraphTemplateValidationStatus(4-8)state-manager/app/models/node_template_model.py (1)
NodeTemplate(5-11)
state-manager/app/models/node_template_model.py (3)
state-manager/app/models/create_models.py (2)
RequestStateModel(7-9)ResponseStateModel(12-16)state-manager/app/models/enqueue_response.py (1)
StateModel(6-10)state-manager/app/models/db/state.py (1)
State(7-14)
state-manager/app/models/graph_models.py (1)
state-manager/app/models/node_template_model.py (1)
NodeTemplate(5-11)
🪛 GitHub Actions: Check spells before PR merge
state-manager/app/models/node_template_model.py
[error] 8-8: codespell detected misspelled words: 'indentifier' should be 'identifier', 'Indentifier' should be 'Identifier'.
🔇 Additional comments (4)
state-manager/app/models/node_template_model.py (1)
1-11: LGTM with minor fixes needed!The NodeTemplate model structure is well-designed with appropriate type annotations and field descriptions. Once the spelling error is fixed, this will serve as a solid foundation for the graph template system.
state-manager/app/models/graph_template_validation_status.py (1)
5-8: LGTM! Well-defined validation status flow.The validation statuses provide a clear state machine: PENDING → ONGOING → VALID/INVALID. This covers the complete validation lifecycle appropriately.
state-manager/app/models/db/graph_template_model.py (2)
16-23: Excellent use of unique compound index.The unique index on
(name, namespace)combination prevents duplicate graph templates within the same namespace while allowing the same name across different namespaces. This is a solid design choice for multi-tenant scenarios.
9-14: LGTM! Well-structured database model.The GraphTemplate model properly inherits from BaseDatabaseModel and includes all necessary fields for graph template management with validation tracking. The field types and descriptions are appropriate.
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.
Actionable comments posted: 1
♻️ Duplicate comments (1)
state-manager/app/models/node_template_model.py (1)
6-6: Field naming inconsistency remains unaddressed.Based on past review feedback, other models in the codebase use
node_nameinstead ofnamefor node identification. This inconsistency should be resolved for better maintainability.Apply this diff to maintain consistency:
- name: str = Field(..., description="Name of the node") + node_name: str = Field(..., description="Name of the node")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
state-manager/app/models/node_template_model.py(1 hunks)
🔇 Additional comments (2)
state-manager/app/models/node_template_model.py (2)
1-2: LGTM!The imports are appropriate for a Pydantic model with proper typing support.
8-8: Spelling error has been correctly fixed.The previous spelling error "indentifier" has been properly corrected to "identifier".
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.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
state-manager/app/controller/upsert_graph_template.py(1 hunks)state-manager/app/models/graph_template_validation_status.py(1 hunks)state-manager/app/routes.py(5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
state-manager/app/controller/upsert_graph_template.py (4)
state-manager/app/models/graph_models.py (2)
UpsertGraphTemplateRequest(8-11)UpsertGraphTemplateResponse(14-21)state-manager/app/models/db/graph_template_model.py (1)
GraphTemplate(9-23)state-manager/app/models/graph_template_validation_status.py (1)
GraphTemplateValidationStatus(4-8)state-manager/app/routes.py (1)
upsert_graph_template(113-122)
🔇 Additional comments (3)
state-manager/app/models/graph_template_validation_status.py (1)
4-8: LGTM! Enum follows established patterns.The implementation correctly inherits from
(str, Enum)as suggested in previous reviews, ensuring consistency with existing enums likeStateStatusEnumand providing proper string serialization support. The validation status values are well-defined and appropriate for tracking graph template validation states.state-manager/app/routes.py (2)
28-28: LGTM! Router prefix change improves API organization.The change from a states-specific prefix to a more general namespace prefix allows for better organization of different resource types under the same namespace. The existing state endpoints correctly maintain their paths by adding "/states".
113-122: LGTM! Endpoint follows established patterns.The new graph template upsert endpoint correctly follows the established patterns for API key validation, request ID handling, and error responses. The authentication flow and logging are consistent with existing endpoints.
This reverts commit c1a74ed.
No description provided.