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

fix: inference session not created when service name is too long #1642

Merged
merged 5 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1642.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lower limit of maximum available characters to name of model service to fix model service session refuses to be created when service name is longer than 28 characters
2 changes: 1 addition & 1 deletion src/ai/backend/manager/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def get_info(request: web.Request) -> web.Response:
t.Dict(
{
tx.AliasedKey(["name", "service_name", "clientSessionToken"])
>> "service_name": t.Regexp(r"^(?=.{4,64}$)\w[\w.-]*\w$", re.ASCII),
>> "service_name": t.Regexp(r"^(?=.{4,24}$)\w[\w.-]*\w$", re.ASCII),
tx.AliasedKey(["desired_session_count", "desiredSessionCount"]): t.Int,
tx.AliasedKey(["image", "lang"]): t.String,
tx.AliasedKey(["arch", "architecture"], default=DEFAULT_IMAGE_ARCH)
Expand Down
11 changes: 11 additions & 0 deletions src/ai/backend/manager/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,3 +1063,14 @@ async def populate_fixture(
for row in rows:
row[col.name] = col.type._schema.from_json(row[col.name])
await conn.execute(sa.dialects.postgresql.insert(table, rows).on_conflict_do_nothing())


class InferenceSessionError(graphene.ObjectType):
class InferenceSessionErrorInfo(graphene.ObjectType):
src = graphene.String(required=True)
name = graphene.String(required=True)
repr = graphene.String(required=True)

session_id = graphene.UUID()

errors = graphene.List(graphene.NonNull(InferenceSessionErrorInfo), required=True)
12 changes: 1 addition & 11 deletions src/ai/backend/manager/models/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
EnumValueType,
ForeignKeyIDColumn,
IDColumn,
InferenceSessionError,
Item,
PaginatedList,
ResourceSlotColumn,
Expand Down Expand Up @@ -354,17 +355,6 @@ async def get(
return row


class InferenceSessionError(graphene.ObjectType):
class InferenceSessionErrorInfo(graphene.ObjectType):
src = graphene.String(required=True)
name = graphene.String(required=True)
repr = graphene.String(required=True)

session_id = graphene.UUID()

errors = graphene.List(graphene.NonNull(InferenceSessionErrorInfo), required=True)


class Endpoint(graphene.ObjectType):
class Meta:
interfaces = (Item,)
Expand Down
23 changes: 21 additions & 2 deletions src/ai/backend/manager/models/routing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import uuid
from enum import Enum
from typing import TYPE_CHECKING, Optional, Sequence
from typing import TYPE_CHECKING, Any, Optional, Sequence

import graphene
import sqlalchemy as sa
Expand All @@ -14,7 +14,7 @@
from ai.backend.common.logging_utils import BraceStyleAdapter

from ..api.exceptions import RoutingNotFound
from .base import GUID, Base, EnumValueType, IDColumn, Item, PaginatedList
from .base import GUID, Base, EnumValueType, IDColumn, InferenceSessionError, Item, PaginatedList

if TYPE_CHECKING:
# from .gql import GraphQueryContext
Expand Down Expand Up @@ -209,6 +209,7 @@ class Meta:
status = graphene.String()
traffic_ratio = graphene.Float()
created_at = GQLDateTime()
error = InferenceSessionError()
error_data = graphene.JSONString()

@classmethod
Expand Down Expand Up @@ -329,6 +330,24 @@ async def load_item(
raise RoutingNotFound
return await Routing.from_row(ctx, row)

async def resolve_error(self, info: graphene.ResolveInfo) -> Any:
if self.status != RouteStatus.FAILED_TO_START or not self.error_data:
return None
match self.error_data["type"]:
case "session_cancelled":
session_id = self.error_data["session_id"]
case _:
session_id = None
return InferenceSessionError(
session_id=session_id,
errors=[
InferenceSessionError.InferenceSessionErrorInfo(
src=e["src"], name=e["name"], repr=e["repr"]
)
for e in self.error_data["errors"]
],
)


class RoutingList(graphene.ObjectType):
class Meta:
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/manager/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3689,7 +3689,7 @@ async def handle_route_creation(
)

await context.create_session(
f"{endpoint.name}-{uuid.uuid4()}",
f"{endpoint.name}-{str(event.route_id)}",
endpoint.image_row.name,
endpoint.image_row.architecture,
UserScope(
Expand Down
Loading