Skip to content

Commit 0babca5

Browse files
committed
fix: Agent summary query build order (#6389)
Backported-from: main (25.16) Backported-to: 25.15 Backport-of: 6389
1 parent a41e6eb commit 0babca5

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

changes/6389.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix GQL agent_summary_list resolver

src/ai/backend/manager/models/gql_models/agent.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,24 @@ async def load_slice(
808808
filter: Optional[str] = None,
809809
order: Optional[str] = None,
810810
) -> Sequence[Self]:
811+
query = sa.select(AgentRow)
812+
813+
if raw_status is not None:
814+
query = query.where(AgentRow.status == AgentStatus[raw_status])
815+
if filter is not None:
816+
qfparser = QueryFilterParser(cls._queryfilter_fieldspec)
817+
query = qfparser.append_filter(query, filter)
818+
if order is not None:
819+
qoparser = QueryOrderParser(cls._queryorder_colmap)
820+
query = qoparser.append_ordering(query, order)
821+
else:
822+
query = query.order_by(
823+
AgentRow.status.asc(),
824+
AgentRow.scaling_group.asc(),
825+
AgentRow.id.asc(),
826+
)
811827
query = (
812-
sa.select(AgentRow)
813-
.select_from(
828+
query.select_from(
814829
sa.join(
815830
AgentRow,
816831
KernelRow,
@@ -828,21 +843,6 @@ async def load_slice(
828843
query = await _append_sgroup_from_clause(
829844
graph_ctx, query, access_key, domain_name, scaling_group
830845
)
831-
832-
if raw_status is not None:
833-
query = query.where(AgentRow.status == AgentStatus[raw_status])
834-
if filter is not None:
835-
qfparser = QueryFilterParser(cls._queryfilter_fieldspec)
836-
query = qfparser.append_filter(query, filter)
837-
if order is not None:
838-
qoparser = QueryOrderParser(cls._queryorder_colmap)
839-
query = qoparser.append_ordering(query, order)
840-
else:
841-
query = query.order_by(
842-
AgentRow.status.asc(),
843-
AgentRow.scaling_group.asc(),
844-
AgentRow.id.asc(),
845-
)
846846
agent_ids: list[AgentId] = []
847847
async with graph_ctx.db.begin_readonly_session() as db_session:
848848
result = await db_session.scalars(query)

0 commit comments

Comments
 (0)