Skip to content

Commit bc16789

Browse files
authored
Ci/unit tests for tool (#66)
* remove responses models * adding tests to the other tools * refactor tests * add pytest-async * replace logging with custom logger
1 parent ec13c18 commit bc16789

34 files changed

Lines changed: 1316 additions & 1765 deletions

src/api/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from typing import List
22
import requests
33
import json
4-
import logging
54

65
from starlette.exceptions import HTTPException
76

87
from src.api.types import MCPConcept, AVAILABLE_FLAGS
98
from src.config.config import get_session_request, get_settings
9+
from src.logger import get_logger
1010

1111
# Set up logger for this module
12-
logger = logging.getLogger(__name__)
12+
logger = get_logger()
1313

1414

1515
def filter_mcp_concepts(mcp_concepts: List[MCPConcept], **flags) -> List[MCPConcept]:

src/api/prompts/prompts.py

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,6 @@
11
from src.api.prompts.types import Prompt
2-
from src.api.responses import prompt_response
32

4-
5-
@prompt_response
6-
def sql_optimization_prompt(query: str, database_type: str = "singlestore") -> str:
7-
"""
8-
Generate a prompt for SQL query optimization analysis.
9-
10-
Args:
11-
query: The SQL query to optimize
12-
database_type: The type of database (default: singlestore)
13-
"""
14-
return f"""
15-
Please analyze and optimize the following {database_type.upper()} SQL query:
16-
17-
```sql
18-
{query}
19-
```
20-
21-
Consider the following optimization strategies:
22-
1. Index usage and recommendations
23-
2. Query structure improvements
24-
3. JOIN optimization
25-
4. WHERE clause efficiency
26-
5. SingleStore-specific optimizations (if applicable)
27-
28-
Provide:
29-
- Optimized query version
30-
- Explanation of changes
31-
- Performance impact estimation
32-
- Index recommendations
33-
"""
34-
35-
36-
@prompt_response
37-
def data_modeling_prompt(
38-
table_description: str, use_case: str = "analytics", scale: str = "medium"
39-
) -> str:
40-
"""
41-
Generate a prompt for SingleStore data modeling guidance.
42-
43-
Args:
44-
table_description: Description of the data to model
45-
use_case: The primary use case (analytics, transactional, hybrid)
46-
scale: Expected data scale (small, medium, large, enterprise)
47-
"""
48-
return f"""
49-
Design an optimal SingleStore data model for the following requirements:
50-
51-
**Data Description:** {table_description}
52-
**Use Case:** {use_case}
53-
**Scale:** {scale}
54-
55-
Please provide:
56-
1. **Table Schema Design**
57-
- Column definitions with appropriate data types
58-
- Primary key strategy
59-
- Distribution key recommendations
60-
- Sort key optimization
61-
62-
2. **SingleStore-Specific Optimizations**
63-
- Columnstore vs Rowstore recommendations
64-
- Partitioning strategy
65-
- Shard key selection
66-
- Reference table considerations
67-
68-
3. **Performance Considerations**
69-
- Query pattern optimization
70-
- Index strategy
71-
- Memory usage optimization
72-
- Scaling recommendations
73-
74-
4. **Best Practices**
75-
- Data ingestion patterns
76-
- ETL considerations
77-
- Monitoring and maintenance
78-
79-
Ensure the design leverages SingleStore's distributed architecture and hybrid transactional/analytical capabilities.
80-
"""
81-
82-
83-
prompts_definitions = [
84-
{
85-
"title": "SQL Query Optimization Assistant",
86-
"func": sql_optimization_prompt,
87-
},
88-
{
89-
"title": "SingleStore Data Modeling Guide",
90-
"func": data_modeling_prompt,
91-
},
92-
]
3+
prompts_definitions = []
934

945
# Export the prompts using create_from_dict for consistency
956
prompts = [Prompt.create_from_dict(prompt) for prompt in prompts_definitions]

src/api/resources/resources.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from pathlib import Path
22
from src.api.resources.types import Resource
3-
from src.api.responses import resource_response
43

54

6-
@resource_response
7-
def get_singlestore_drizzle_guide() -> str:
5+
def get_singlestore_drizzle_guide() -> dict:
86
"""
97
SingleStore and Drizzle ORM Integration Guide
108
@@ -21,9 +19,26 @@ def get_singlestore_drizzle_guide() -> str:
2119

2220
try:
2321
with open(docs_path, "r", encoding="utf-8") as f:
24-
return f.read()
22+
content = f.read()
23+
return {
24+
"status": "success",
25+
"message": "SingleStore Drizzle integration guide retrieved successfully",
26+
"content": content,
27+
"uri": "docs://singlestore/drizzle-integration",
28+
"metadata": {
29+
"content_length": len(content),
30+
"file_path": str(docs_path),
31+
},
32+
}
2533
except FileNotFoundError:
26-
return "SingleStore Drizzle integration guide not found."
34+
return {
35+
"status": "error",
36+
"message": "SingleStore Drizzle integration guide not found",
37+
"content": "SingleStore Drizzle integration guide not found.",
38+
"uri": "docs://singlestore/drizzle-integration",
39+
"error_code": "FileNotFound",
40+
"error_details": {"file_path": str(docs_path)},
41+
}
2742

2843

2944
resources_definitions = [

0 commit comments

Comments
 (0)