Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove session scheduler related types no longer used #2705

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jopemachine
Copy link
Member

@jopemachine jopemachine commented Aug 13, 2024

Overview

During the process of refactoring tasks of different characters, I discovered that these types are no longer in use.
It seems advisable to remove these types for maintenance.

Details

  • Remove the following types no longer used.

  • Replace the KernelInfo type argument of assign_agent_for_kernel with KernelRow.
    The KernelInfo type is not actually used, and at the call site of assign_agent_for_kernel, a value of type KernelRow is passed to that parameter. You can see the kernel passed to the assign_agent_for_kernel is KernelRow type in the below code.

    kernel: KernelRow
    for kernel in sess_ctx.kernels:
    agent_alloc_ctx: AgentAllocationContext | None = None
    try:
    agent_id: Optional[AgentId] = None
    agent: Optional[AgentRow] = kernel.agent_row
    if agent is not None:
    # Check the resource availability of the manually designated agent
    result = (
    await agent_db_sess.execute(
    sa.select([
    AgentRow.available_slots,
    AgentRow.occupied_slots,
    ]).where(AgentRow.id == agent.id)
    )
    ).fetchall()[0]
    if result is None:
    raise GenericBadRequest(f"No such agent exist in DB: {agent_id}")
    available_slots, occupied_slots = result
    for key in available_slots.keys():
    if (
    available_slots[key] - occupied_slots[key]
    >= kernel.requested_slots[key]
    ):
    continue
    else:
    raise InstanceNotAvailable(
    extra_msg=(
    f"The designated agent ({agent.id}) does not have "
    f"the enough remaining capacity ({key}, "
    f"requested: {sess_ctx.requested_slots[key]}, "
    f"remaining: {available_slots[key] - occupied_slots[key]})."
    ),
    )
    agent_id = agent.id
    else:
    # Each kernel may have different images and different architectures
    compatible_candidate_agents = [
    ag for ag in candidate_agents if ag.architecture == kernel.architecture
    ]
    if not candidate_agents:
    raise InstanceNotAvailable(
    extra_msg="No agents are available for scheduling"
    )
    if not compatible_candidate_agents:
    raise InstanceNotAvailable(
    extra_msg=(
    "No agents found to be compatible with the image architecture "
    f"(image: {kernel.image_ref}, "
    f"arch: {kernel.architecture})"
    ),
    )
    available_candidate_agents = await self._filter_agent_by_container_limit(
    compatible_candidate_agents
    )
    if not available_candidate_agents:
    raise InstanceNotAvailable(
    extra_msg=(
    "No agents found to be available because all agents have"
    " reached the hard limit of the number of containers."
    ),
    )
    # Let the scheduler check the resource availability and decide the target agent
    agent_id = scheduler.assign_agent_for_kernel(
    available_candidate_agents,
    kernel,

Note

Unlike other types, I couldn't find any evidence that the SchedulingPredicate type was used in the past, so there might be some misunderstanding on my part.
If that's the case, please let me know. If it is a useful type somewhere, we can fix it by replacing the removed PendingSession type with SessionRow.


Checklist: (if applicable)

  • Milestone metadata specifying the target backport version

@github-actions github-actions bot added comp:manager Related to Manager component size:L 100~500 LoC labels Aug 13, 2024
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @jopemachine and the rest of your teammates on Graphite Graphite

@jopemachine jopemachine changed the title chore: Remove types that are no longer used chore: Remove Session Scheduler related types that are no longer used Aug 13, 2024
@jopemachine jopemachine changed the title chore: Remove Session Scheduler related types that are no longer used chore: Remove session scheduler related types that are no longer used Aug 13, 2024
@jopemachine jopemachine marked this pull request as ready for review August 13, 2024 04:37
@jopemachine jopemachine changed the title chore: Remove session scheduler related types that are no longer used chore: Remove session scheduler related types no longer used Aug 13, 2024
@jopemachine jopemachine added this to the 24.09 milestone Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component size:L 100~500 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant