Skip to content

Commit 799748b

Browse files
authored
fix: service args and operator fixes (#1297)
1 parent 3447e31 commit 799748b

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const (
8282
KubeAnnotationLWSSize = "nvidia.com/lws-size"
8383
DeploymentTypeStandard = "standard"
8484
DeploymentTypeLeaderWorker = "leader-worker"
85+
ComponentTypePlanner = "Planner"
8586
)
8687

8788
// DynamoComponentDeploymentReconciler reconciles a DynamoComponentDeployment object
@@ -1454,7 +1455,9 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
14541455
if opt.dynamoComponentDeployment.Spec.DynamoNamespace != nil && *opt.dynamoComponentDeployment.Spec.DynamoNamespace != "" {
14551456
args = append(args, fmt.Sprintf("--%s.ServiceArgs.dynamo.namespace=%s", opt.dynamoComponentDeployment.Spec.ServiceName, *opt.dynamoComponentDeployment.Spec.DynamoNamespace))
14561457
}
1457-
args = append(args, fmt.Sprintf("--%s.environment=%s", opt.dynamoComponentDeployment.Spec.ServiceName, KubernetesDeploymentStrategy))
1458+
if componentType, exists := opt.dynamoComponentDeployment.Labels[commonconsts.KubeLabelDynamoComponent]; exists && componentType == ComponentTypePlanner {
1459+
args = append(args, fmt.Sprintf("--%s.environment=%s", opt.dynamoComponentDeployment.Spec.ServiceName, KubernetesDeploymentStrategy))
1460+
}
14581461
}
14591462

14601463
if len(opt.dynamoComponentDeployment.Spec.Envs) > 0 {

deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ func TestDynamoComponentDeploymentReconciler_generateLeaderWorkerSet(t *testing.
934934
Name: "main",
935935
Image: "test-image:latest",
936936
Command: []string{"sh", "-c"},
937-
Args: []string{"ray start --head --port=6379 && cd src && uv run dynamo serve --system-app-port 5000 --enable-system-app --use-default-health-checks --service-name test-lws-deploy-service test-tag --test-lws-deploy-service.ServiceArgs.dynamo.namespace=default --test-lws-deploy-service.environment=kubernetes"},
937+
Args: []string{"ray start --head --port=6379 && cd src && uv run dynamo serve --system-app-port 5000 --enable-system-app --use-default-health-checks --service-name test-lws-deploy-service test-tag --test-lws-deploy-service.ServiceArgs.dynamo.namespace=default"},
938938
Env: []corev1.EnvVar{{Name: "DYNAMO_PORT", Value: "3000"}},
939939
VolumeMounts: []corev1.VolumeMount{
940940
{

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,18 @@ def from_service(cls, service: ServiceInterface[T]) -> ServiceInfo:
129129
if DynamoTransport.HTTP in endpoint.transports:
130130
api_endpoints.append(f"/{ep_name}")
131131

132+
image = service.config.image or DYNAMO_IMAGE
133+
assert (
134+
image is not None
135+
), "Please set DYNAMO_IMAGE environment variable or image field in service config"
136+
132137
# Create config
133138
config = ServiceConfig(
134139
name=name,
135140
service="",
136-
resource=service.config.resource.model_dump(),
141+
resource=service.config.resources.model_dump(),
137142
workers=service.config.workers,
138-
image=service.config.image,
143+
image=image,
139144
dynamo=service.config.dynamo.model_dump(),
140145
http_exposed=len(api_endpoints) > 0,
141146
api_endpoints=api_endpoints,
@@ -423,7 +428,6 @@ def to_package_name(name: str) -> str:
423428
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
424429
s2 = re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1)
425430
ret = s2.replace(":", "_")
426-
print(f"Converting {name} to snake_case: {ret}")
427431
return ret
428432

429433
@staticmethod

deploy/sdk/src/dynamo/sdk/core/lib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def service(
6060
) -> Any:
6161
"""Service decorator that's adapter-agnostic"""
6262
config = ServiceConfig(**kwargs)
63-
logger.info(f"inner: {inner} config: {config}")
6463

6564
def decorator(inner: Type[G]) -> ServiceInterface[G]:
6665
provider = get_target()

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

Lines changed: 12 additions & 6 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
20+
from typing import Any, Dict, Generic, List, Optional, Set, Tuple, Type, TypeVar, Union
2121

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

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

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

62-
cpu: int = 1
63-
memory: str = "100Mi"
64-
gpu: str = "0"
62+
cpu: str = Field(default="1")
63+
memory: str = Field(default="500Mi")
64+
gpu: str = Field(default="0")
65+
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)
6571

6672

6773
class ServiceConfig(BaseModel):
6874
"""Base service configuration that can be extended by adapters"""
6975

7076
dynamo: DynamoConfig
71-
resource: ResourceConfig = ResourceConfig()
77+
resources: ResourceConfig = ResourceConfig()
7278
workers: int = 1
7379
image: str | None = None
7480
envs: List[Env] | None = None

deploy/sdk/src/dynamo/sdk/tests/test_resources.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pytest
1717

1818
from dynamo.sdk.cli.utils import configure_target_environment
19+
from dynamo.sdk.core.protocol.interface import ServiceInterface
1920
from dynamo.sdk.core.runner import TargetEnum
2021

2122
pytestmark = pytest.mark.pre_merge
@@ -40,4 +41,8 @@ class MyService:
4041
def __init__(self) -> None:
4142
pass
4243

43-
assert MyService.config is not None # type: ignore
44+
dyn_svc: ServiceInterface = MyService
45+
assert dyn_svc.config is not None # type: ignore
46+
assert dyn_svc.config.resources.cpu == "2"
47+
assert dyn_svc.config.resources.gpu == "1"
48+
assert dyn_svc.config.resources.memory == "4Gi"

examples/llm/configs/agg_router.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ VllmWorker:
4040
workers: 1
4141
resources:
4242
gpu: '1'
43+
cpu: '10'
44+
memory: '20Gi'
4345
common-configs: [model, block-size, max-model-len, router, kv-transfer-config]
4446

4547
Planner:

0 commit comments

Comments
 (0)