Skip to content

Commit

Permalink
Fix wrong type
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Oct 26, 2023
1 parent ec009e9 commit 0eeebf7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/ai/backend/manager/scheduler/drf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
SessionId,
)

from ..models import AgentRow, SessionRow
from ..models import AgentRow, KernelRow, SessionRow
from ..models.scaling_group import ScalingGroupOpts
from .types import AbstractScheduler, KernelInfo
from .types import AbstractScheduler

log = BraceStyleAdapter(logging.getLogger("ai.backend.manager.scheduler"))

Expand Down Expand Up @@ -83,7 +83,7 @@ def pick_session(
async def _assign_agent(
self,
possible_agents: Sequence[AgentRow],
pending_session_or_kernel: SessionRow | KernelInfo,
pending_session_or_kernel: SessionRow | KernelRow,
roundrobin_context: Optional[RoundRobinContext] = None,
) -> Optional[AgentId]:
# If some predicate checks for a picked session fail,
Expand Down Expand Up @@ -132,7 +132,7 @@ async def assign_agent_for_session(
async def assign_agent_for_kernel(
self,
possible_agents: Sequence[AgentRow],
pending_kernel: KernelInfo,
pending_kernel: KernelRow,
) -> Optional[AgentId]:
return await self._assign_agent(
possible_agents,
Expand Down
8 changes: 4 additions & 4 deletions src/ai/backend/manager/scheduler/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
SessionId,
)

from ..models import AgentRow, SessionRow
from .types import AbstractScheduler, KernelInfo
from ..models import AgentRow, KernelRow, SessionRow
from .types import AbstractScheduler


def get_num_extras(agent: AgentRow, requested_slots: ResourceSlot) -> int:
Expand Down Expand Up @@ -78,7 +78,7 @@ async def assign_agent_for_session(
async def assign_agent_for_kernel(
self,
agents: Sequence[AgentRow],
pending_kernel: KernelInfo,
pending_kernel: KernelRow,
) -> Optional[AgentId]:
return await self.select_agent(
agents,
Expand Down Expand Up @@ -115,7 +115,7 @@ async def assign_agent_for_session(
async def assign_agent_for_kernel(
self,
agents: Sequence[AgentRow],
pending_kernel: KernelInfo,
pending_kernel: KernelRow,
) -> Optional[AgentId]:
return await self.select_agent(
agents,
Expand Down
12 changes: 6 additions & 6 deletions src/ai/backend/manager/scheduler/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ async def assign_agent_for_session(
async def assign_agent_for_kernel(
self,
possible_agents: Sequence[AgentRow],
pending_kernel: KernelInfo,
pending_kernel: KernelRow,
) -> Optional[AgentId]:
"""
Assign an agent for a kernel of the session.
Expand All @@ -471,7 +471,7 @@ async def assign_agent_for_kernel(
async def select_agent(
self,
possible_agents: Sequence[AgentRow],
pending_session_or_kernel: SessionRow | KernelInfo,
pending_session_or_kernel: SessionRow | KernelRow,
use_num_extras: bool,
roundrobin_context: Optional[RoundRobinContext] = None,
) -> Optional[AgentId]:
Expand All @@ -498,15 +498,15 @@ async def select_agent(
# Note that ROUNDROBIN is not working with the multi-node multi-container session.
# It assumes the pending session type is single-node session.
# Otherwise, it will use 'Dispersed' strategy as default strategy.
if (
agent_selection_strategy == AgentSelectionStrategy.ROUNDROBIN
and type(pending_session_or_kernel) is KernelInfo

if agent_selection_strategy == AgentSelectionStrategy.ROUNDROBIN and isinstance(
pending_session_or_kernel, KernelRow
):
agent_selection_strategy = AgentSelectionStrategy.DISPERSED

match agent_selection_strategy:
case AgentSelectionStrategy.ROUNDROBIN:
assert type(pending_session_or_kernel) is SessionRow
assert isinstance(pending_session_or_kernel, SessionRow)
assert roundrobin_context is not None
sched_ctx = roundrobin_context.sched_ctx
sgroup_name = roundrobin_context.sgroup_name
Expand Down

0 comments on commit 0eeebf7

Please sign in to comment.