Skip to content

Commit

Permalink
fix: Outdated KernelNode.from_row
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Dec 9, 2024
1 parent 8f63fbd commit 18906ff
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/ai/backend/manager/models/gql_models/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
TYPE_CHECKING,
Any,
Self,
cast,
)

import graphene
Expand All @@ -14,14 +15,16 @@

from ai.backend.common import msgpack, redis_helper
from ai.backend.common.types import AgentId, KernelId, SessionId
from ai.backend.manager.models.base import (
from ai.backend.manager.models.session import SessionStatus

from ..base import (
batch_multiresult_in_scalar_stream,
batch_multiresult_in_session,
)

from ..gql_relay import AsyncNode, Connection
from ..kernel import KernelRow, KernelStatus
from ..kernel import KernelRow
from ..user import UserRole
from ..utils import get_lastest_timestamp_for_status
from .image import ImageNode

if TYPE_CHECKING:
Expand Down Expand Up @@ -113,7 +116,12 @@ def from_row(cls, ctx: GraphQueryContext, row: KernelRow) -> Self:
hide_agents = False
else:
hide_agents = ctx.local_config["manager"]["hide-agents"]
status_history = row.status_history or {}

timestamp = get_lastest_timestamp_for_status(
cast(list[dict[str, str]], row.status_history), SessionStatus.SCHEDULED
)
scheduled_at = str(timestamp) if timestamp is not None else None

return KernelNode(
id=row.id, # auto-converted to Relay global ID
row_id=row.id,
Expand All @@ -129,7 +137,7 @@ def from_row(cls, ctx: GraphQueryContext, row: KernelRow) -> Self:
created_at=row.created_at,
terminated_at=row.terminated_at,
starts_at=row.starts_at,
scheduled_at=status_history.get(KernelStatus.SCHEDULED.name),
scheduled_at=scheduled_at,
occupied_slots=row.occupied_slots.to_json(),
agent_id=row.agent if not hide_agents else None,
agent_addr=row.agent_addr if not hide_agents else None,
Expand Down

0 comments on commit 18906ff

Please sign in to comment.