Skip to content

Commit 810e7d3

Browse files
committed
Fix lint issues, rebased
Signed-off-by: Mihai Criveti <[email protected]>
1 parent c8e41e1 commit 810e7d3

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

mcpgateway/services/prompt_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# Third-Party
2525
from jinja2 import Environment, meta, select_autoescape
26-
from sqlalchemy import case, delete, desc, func, not_, select, Float
26+
from sqlalchemy import case, delete, desc, Float, func, not_, select
2727
from sqlalchemy.exc import IntegrityError
2828
from sqlalchemy.orm import Session
2929

@@ -169,7 +169,7 @@ async def get_top_prompts(self, db: Session, limit: int = 5) -> List[TopPerforme
169169
case(
170170
(
171171
func.count(PromptMetric.id) > 0, # pylint: disable=not-callable
172-
func.sum(case((PromptMetric.is_success.is_(True), 1), else_=0)).cast(Float) / func.count(PromptMetric.id) * 100, # pylint: disable=not-callable
172+
func.sum(case((PromptMetric.is_success == 1, 1), else_=0)).cast(Float) / func.count(PromptMetric.id) * 100, # pylint: disable=not-callable
173173
),
174174
else_=None,
175175
).label("success_rate"),
@@ -1050,8 +1050,8 @@ async def aggregate_metrics(self, db: Session) -> Dict[str, Any]:
10501050
"""
10511051

10521052
total = db.execute(select(func.count(PromptMetric.id))).scalar() or 0 # pylint: disable=not-callable
1053-
successful = db.execute(select(func.count(PromptMetric.id)).where(PromptMetric.is_success)).scalar() or 0 # pylint: disable=not-callable
1054-
failed = db.execute(select(func.count(PromptMetric.id)).where(not_(PromptMetric.is_success))).scalar() or 0 # pylint: disable=not-callable
1053+
successful = db.execute(select(func.count(PromptMetric.id)).where(PromptMetric.is_success == 1)).scalar() or 0 # pylint: disable=not-callable
1054+
failed = db.execute(select(func.count(PromptMetric.id)).where(PromptMetric.is_success == 0)).scalar() or 0 # pylint: disable=not-callable
10551055
failure_rate = failed / total if total > 0 else 0.0
10561056
min_rt = db.execute(select(func.min(PromptMetric.response_time))).scalar()
10571057
max_rt = db.execute(select(func.max(PromptMetric.response_time))).scalar()

mcpgateway/services/resource_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
# Third-Party
3535
import parse
36-
from sqlalchemy import case, delete, desc, func, not_, select, Float
36+
from sqlalchemy import case, delete, desc, Float, func, not_, select
3737
from sqlalchemy.exc import IntegrityError
3838
from sqlalchemy.orm import Session
3939

@@ -142,7 +142,7 @@ async def get_top_resources(self, db: Session, limit: int = 5) -> List[TopPerfor
142142
case(
143143
(
144144
func.count(ResourceMetric.id) > 0, # pylint: disable=not-callable
145-
func.sum(case((ResourceMetric.is_success.is_(True), 1), else_=0)).cast(Float) / func.count(ResourceMetric.id) * 100, # pylint: disable=not-callable
145+
func.sum(case((ResourceMetric.is_success == 1, 1), else_=0)).cast(Float) / func.count(ResourceMetric.id) * 100, # pylint: disable=not-callable
146146
),
147147
else_=None,
148148
).label("success_rate"),
@@ -1040,9 +1040,9 @@ async def aggregate_metrics(self, db: Session) -> ResourceMetrics:
10401040
"""
10411041
total_executions = db.execute(select(func.count()).select_from(ResourceMetric)).scalar() or 0 # pylint: disable=not-callable
10421042

1043-
successful_executions = db.execute(select(func.count()).select_from(ResourceMetric).where(ResourceMetric.is_success)).scalar() or 0 # pylint: disable=not-callable
1043+
successful_executions = db.execute(select(func.count()).select_from(ResourceMetric).where(ResourceMetric.is_success == 1)).scalar() or 0 # pylint: disable=not-callable
10441044

1045-
failed_executions = db.execute(select(func.count()).select_from(ResourceMetric).where(not_(ResourceMetric.is_success))).scalar() or 0 # pylint: disable=not-callable
1045+
failed_executions = db.execute(select(func.count()).select_from(ResourceMetric).where(ResourceMetric.is_success == 0)).scalar() or 0 # pylint: disable=not-callable
10461046

10471047
min_response_time = db.execute(select(func.min(ResourceMetric.response_time))).scalar()
10481048

mcpgateway/services/server_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# Third-Party
2121
import httpx
22-
from sqlalchemy import case, delete, desc, func, not_, select, Float
22+
from sqlalchemy import case, delete, desc, Float, func, select
2323
from sqlalchemy.exc import IntegrityError
2424
from sqlalchemy.orm import Session
2525

@@ -157,7 +157,7 @@ async def get_top_servers(self, db: Session, limit: int = 5) -> List[TopPerforme
157157
case(
158158
(
159159
func.count(ServerMetric.id) > 0, # pylint: disable=not-callable
160-
func.sum(case((ServerMetric.is_success.is_(True), 1), else_=0)).cast(Float) / func.count(ServerMetric.id) * 100, # pylint: disable=not-callable
160+
func.sum(case((ServerMetric.is_success == 1, 1), else_=0)).cast(Float) / func.count(ServerMetric.id) * 100, # pylint: disable=not-callable
161161
),
162162
else_=None,
163163
).label("success_rate"),
@@ -833,9 +833,9 @@ async def aggregate_metrics(self, db: Session) -> ServerMetrics:
833833
"""
834834
total_executions = db.execute(select(func.count()).select_from(ServerMetric)).scalar() or 0 # pylint: disable=not-callable
835835

836-
successful_executions = db.execute(select(func.count()).select_from(ServerMetric).where(ServerMetric.is_success)).scalar() or 0 # pylint: disable=not-callable
836+
successful_executions = db.execute(select(func.count()).select_from(ServerMetric).where(ServerMetric.is_success == 1)).scalar() or 0 # pylint: disable=not-callable
837837

838-
failed_executions = db.execute(select(func.count()).select_from(ServerMetric).where(not_(ServerMetric.is_success))).scalar() or 0 # pylint: disable=not-callable
838+
failed_executions = db.execute(select(func.count()).select_from(ServerMetric).where(ServerMetric.is_success == 0)).scalar() or 0 # pylint: disable=not-callable
839839

840840
min_response_time = db.execute(select(func.min(ServerMetric.response_time))).scalar()
841841

mcpgateway/services/tool_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from mcp import ClientSession
2929
from mcp.client.sse import sse_client
3030
from mcp.client.streamable_http import streamablehttp_client
31-
from sqlalchemy import case, delete, desc, func, not_, select, Float
31+
from sqlalchemy import case, delete, desc, Float, func, not_, select
3232
from sqlalchemy.exc import IntegrityError
3333
from sqlalchemy.orm import Session
3434

@@ -219,7 +219,7 @@ async def get_top_tools(self, db: Session, limit: int = 5) -> List[TopPerformer]
219219
case(
220220
(
221221
func.count(ToolMetric.id) > 0, # pylint: disable=not-callable
222-
func.sum(case((ToolMetric.is_success.is_(True), 1), else_=0)).cast(Float) / func.count(ToolMetric.id) * 100, # pylint: disable=not-callable
222+
func.sum(case((ToolMetric.is_success == 1, 1), else_=0)).cast(Float) / func.count(ToolMetric.id) * 100, # pylint: disable=not-callable
223223
),
224224
else_=None,
225225
).label("success_rate"),
@@ -1111,8 +1111,8 @@ async def aggregate_metrics(self, db: Session) -> Dict[str, Any]:
11111111
"""
11121112

11131113
total = db.execute(select(func.count(ToolMetric.id))).scalar() or 0 # pylint: disable=not-callable
1114-
successful = db.execute(select(func.count(ToolMetric.id)).where(ToolMetric.is_success)).scalar() or 0 # pylint: disable=not-callable
1115-
failed = db.execute(select(func.count(ToolMetric.id)).where(not_(ToolMetric.is_success))).scalar() or 0 # pylint: disable=not-callable
1114+
successful = db.execute(select(func.count(ToolMetric.id)).where(ToolMetric.is_success == 1)).scalar() or 0 # pylint: disable=not-callable
1115+
failed = db.execute(select(func.count(ToolMetric.id)).where(ToolMetric.is_success == 0)).scalar() or 0 # pylint: disable=not-callable
11161116
failure_rate = failed / total if total > 0 else 0.0
11171117
min_rt = db.execute(select(func.min(ToolMetric.response_time))).scalar()
11181118
max_rt = db.execute(select(func.max(ToolMetric.response_time))).scalar()

0 commit comments

Comments
 (0)