lablup / lablup/backend.ai

order and filter is unabled in endpointlist query

Open
#2,722 0 comments 0 reactions 1 assignee Claimed by @ggstargame45 View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

### Main idea

Because in src/ai/backend/manager/models/endpoint.py load_slice is like this, filter and order isn't used. So we need to change the query of it.

```Java
@classmethod
async def load_slice(
cls,
ctx, # ctx: GraphQueryContext,
limit: int,
offset: int,
*,
domain_name: Optional[str] = None,
user_uuid: Optional[uuid.UUID] = None,
project: Optional[uuid.UUID] = None,
filter: Optional[str] = None,
order: Optional[str] = None,
) -> Sequence["Endpoint"]:
query = (
sa.select(EndpointRow)
.limit(limit)
.offset(offset)
.options(selectinload(EndpointRow.image_row).selectinload(ImageRow.aliases))
.options(selectinload(EndpointRow.routings))
.options(selectinload(EndpointRow.created_user_row))
.options(selectinload(EndpointRow.session_owner_row))
.order_by(sa.desc(EndpointRow.created_at))
.filter(
EndpointRow.lifecycle_stage.in_([
EndpointLifecycle.CREATED,
EndpointLifecycle.DESTROYING,
])
)
)
if project is not None:
query = query.where(EndpointRow.project == project)
if domain_name is not None:
query = query.where(EndpointRow.domain == domain_name)
if user_uuid is not None:
query = query.where(EndpointRow.session_owner == user_uuid)
"""
if filter is not None:
parser = QueryFilterParser(cls._queryfilter_fieldspec)
query = parser.append_filter(query, filter)
if order is not None:
parser = QueryOrderParser(cls._queryorder_colmap)
query = parser.append_ordering(query, order)
"""
async with ctx.db.begin_readonly_session() as session:
result = await session.execute(query)
return [await cls.from_row(ctx, row) for row in result.scalars().all()]
```

Related issues :[Improve GraphQL Schema\|#1286][feat: sort and filter for serving list #1822](https://github.com/lablup/backend.ai-webui/issues/1822)

### Alternative ideas

_No response_

### Anything else?

_No response_

JIRA Issue: BA-93

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.