-
Notifications
You must be signed in to change notification settings - Fork 102
Rob 1254 holmes send toolset version json schema #416
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
base: master
Are you sure you want to change the base?
Rob 1254 holmes send toolset version json schema #416
Conversation
WalkthroughThe changes introduce new metadata and schema-related attributes to toolset classes and their database models, including configuration schema and version information. Synchronization logic is updated to handle these attributes, and tests are expanded to validate the new fields and their correct handling in both basic and configuration-aware toolsets. Changes
Sequence Diagram(s)sequenceDiagram
participant SyncScript as holmes_sync_toolsets_status
participant Toolset as Toolset
participant DBModel as ToolsetDBModel
SyncScript->>Toolset: Inspect config_class and version
alt Toolset has config_class
SyncScript->>Toolset: Generate config_schema from config_class
else Toolset has no config_class
SyncScript->>Toolset: Set config_schema to None
end
SyncScript->>DBModel: Create ToolsetDBModel with config_schema, version, is_default, etc.
DBModel-->>SyncScript: ToolsetDBModel instance ready for sync
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (16)
✅ Files skipped from review due to trivial changes (12)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (9)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 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: 1
🧹 Nitpick comments (2)
tests/test_holmes_sync_toolsets.py (2)
322-325
: Enhance schema validation in the test.The test verifies basic schema properties but could be more thorough in validating the complete schema structure.
Add more detailed schema validation:
config_schema = toolset_data["config_schema"] assert config_schema is not None assert config_schema["type"] == "object" assert config_schema["title"] == "SampleConfig" + # Validate properties structure + assert "properties" in config_schema + assert "param" in config_schema["properties"] + assert config_schema["properties"]["param"]["type"] == "string" + # Validate required fields + assert "required" in config_schema + assert "param" in config_schema["required"]
306-326
: Consider adding negative test cases.While the current test covers the happy path scenario, it would be beneficial to add test cases for error scenarios as well.
For example, you could add a test for invalid configuration classes or version formats:
def test_sync_toolsets_with_invalid_config_class(mock_dal, mock_config, sample_toolset): # Use a non-BaseModel class as config_class class InvalidConfig: param: str SampleToolset.config_class = InvalidConfig mock_config.create_tool_executor.return_value = Mock(toolsets=[sample_toolset]) # Should handle gracefully or raise appropriate error holmes_sync_toolsets_status(mock_dal, mock_config) # Cleanup SampleToolset.config_class = None
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
holmes/core/tools.py
(3 hunks)holmes/plugins/toolsets/grafana/base_grafana_toolset.py
(2 hunks)holmes/plugins/toolsets/opensearch/opensearch.py
(1 hunks)holmes/utils/holmes_sync_toolsets.py
(2 hunks)tests/test_holmes_sync_toolsets.py
(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
holmes/plugins/toolsets/grafana/base_grafana_toolset.py (1)
holmes/plugins/toolsets/grafana/common.py (1)
GrafanaConfig
(9-21)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: build (3.12)
- GitHub Check: build (3.11)
- GitHub Check: build (3.10)
- GitHub Check: build (3.9)
- GitHub Check: build (3.12)
- GitHub Check: build (3.11)
- GitHub Check: build (3.10)
- GitHub Check: build (3.9)
- GitHub Check: build (3.12)
🔇 Additional comments (9)
holmes/plugins/toolsets/opensearch/opensearch.py (1)
188-188
: LGTM: Added config_class attribute to associate with configuration schemaThis change explicitly associates the
OpenSearchToolset
with its configuration model, enabling the toolset to expose its configuration schema during synchronization.holmes/plugins/toolsets/grafana/base_grafana_toolset.py (2)
2-2
: LGTM: Simplified typing importsThe import statement has been simplified by removing unnecessary type annotations that are no longer needed.
15-15
: LGTM: Updated config_class attribute declarationChanged from a typed class variable to a simple attribute assignment while maintaining the same functionality. This matches the pattern used in other toolset classes.
holmes/utils/holmes_sync_toolsets.py (2)
54-56
: LGTM: Added schema extraction logicGood implementation for extracting the JSON schema from the toolset's configuration class if it exists, with proper null handling for cases where config_class is not defined.
67-68
: LGTM: Added new fields to toolset database modelProperly adds the configuration schema and version information to the toolset database model, allowing this metadata to be persisted.
holmes/core/tools.py (2)
332-334
: LGTM: Added new class variables to ToolsetAdded
config_class
andversion
class variables to theToolset
base class to support configuration schema and version information. These are appropriately marked as optional.
578-580
: LGTM: Extended ToolsetDBModel with new fieldsAdded corresponding fields to the database model to store configuration schema, version information, and default status. The fields have appropriate types and optionality.
tests/test_holmes_sync_toolsets.py (2)
36-38
: Good addition of Pydantic model for testing configuration schemas.The
SampleConfig
class provides a clean way to test the JSON schema generation from configuration classes in toolsets.
75-77
: Appropriate test coverage for default values.Good additions to verify that the new fields have expected default values when not explicitly set.
Summary by CodeRabbit