Skip to content

Commit a73c21c

Browse files
committed
fix: resources naming (#1302)
1 parent 0e550d6 commit a73c21c

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

deploy/sdk/src/dynamo/sdk/cli/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ServiceConfig(BaseModel):
101101
service: str = "" # Fully qualified service name
102102
models: t.List[str] = Field(default_factory=list)
103103
dependencies: t.List[str] = Field(default_factory=list)
104-
resource: t.Dict[str, t.Any] = Field(default_factory=dict)
104+
resources: t.Dict[str, t.Any] = Field(default_factory=dict)
105105
workers: t.Optional[int] = None
106106
image: str = "dynamo:latest"
107107
dynamo: t.Dict[str, t.Any] = Field(default_factory=dict)
@@ -138,7 +138,7 @@ def from_service(cls, service: ServiceInterface[T]) -> ServiceInfo:
138138
config = ServiceConfig(
139139
name=name,
140140
service="",
141-
resource=service.config.resources.model_dump(),
141+
resources=service.config.resources.model_dump(),
142142
workers=service.config.workers,
143143
image=image,
144144
dynamo=service.config.dynamo.model_dump(),
@@ -212,7 +212,7 @@ def to_dict(self) -> t.Dict[str, t.Any]:
212212
"name": service["name"],
213213
"service": service["config"]["service"],
214214
"config": {
215-
"resource": service["config"]["resource"],
215+
"resources": service["config"]["resources"],
216216
"workers": service["config"]["workers"],
217217
"image": service["config"]["image"],
218218
"dynamo": service["config"]["dynamo"],

deploy/sdk/src/dynamo/sdk/core/protocol/interface.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
from abc import ABC, abstractmethod
1818
from collections import defaultdict
1919
from enum import Enum, auto
20-
from typing import Any, Dict, Generic, List, Optional, Set, Tuple, Type, TypeVar, Union
20+
from typing import Any, Dict, Generic, List, Optional, Set, Tuple, Type, TypeVar
2121

2222
from fastapi import FastAPI
23-
from pydantic import BaseModel, Field, field_validator
23+
from pydantic import BaseModel, ConfigDict, Field
2424

2525
from dynamo.sdk.core.protocol.deployment import Env
2626

@@ -59,16 +59,13 @@ class DynamoTransport(Enum):
5959
class ResourceConfig(BaseModel):
6060
"""Configuration for Dynamo resources"""
6161

62+
# auto convert gpu and cpu values to string from int
63+
model_config = ConfigDict(coerce_numbers_to_str=True)
64+
6265
cpu: str = Field(default="1")
6366
memory: str = Field(default="500Mi")
6467
gpu: str = Field(default="0")
6568

66-
@field_validator("gpu", mode="before")
67-
@classmethod
68-
def convert_gpu_to_string(cls, v: Union[str, int]) -> str:
69-
"""Convert gpu value to string if it's an integer"""
70-
return str(v)
71-
7269

7370
class ServiceConfig(BaseModel):
7471
"""Base service configuration that can be extended by adapters"""

examples/hello_world/hello_world.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ResponseType(BaseModel):
6767
dynamo={
6868
"namespace": "inference",
6969
},
70-
resource={"cpu": 1, "memory": "500Mi"},
70+
resources={"cpu": 1, "memory": "500Mi"},
7171
workers=2,
7272
image=DYNAMO_IMAGE,
7373
)

0 commit comments

Comments
 (0)