Skip to content

Commit 82c9303

Browse files
Make sure metadata is not incorrectly wiped during endpoint update (#413)
1 parent a421874 commit 82c9303

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

model-engine/model_engine_server/infra/services/live_model_endpoint_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ async def update_model_endpoint(
312312

313313
if record.current_model_bundle.id != model_bundle_id:
314314
if metadata is None:
315-
metadata = {}
315+
metadata = record.metadata if record.metadata is not None else {}
316316
# MODEL_BUNDLE_CHANGED_KEY will be checked during _create_deployment in K8SEndpointResourceDelegate
317317
metadata[MODEL_BUNDLE_CHANGED_KEY] = True
318318

model-engine/tests/unit/infra/services/test_live_model_endpoint_service.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,17 @@ async def test_create_update_model_endpoint_success(
238238
assert model_endpoint.infra_state.deployment_state.max_workers == update_kwargs["max_workers"]
239239
assert model_endpoint.infra_state.labels == update_kwargs["labels"]
240240

241+
# Now update min_worker only
242+
update_kwargs: Any = dict(
243+
min_workers=2,
244+
)
245+
updated_model_endpoint_record = await fake_live_model_endpoint_service.update_model_endpoint(
246+
model_endpoint_id=model_endpoint_record.id, **update_kwargs
247+
)
248+
249+
# Make sure metadata is not updated
250+
assert updated_model_endpoint_record.metadata == {"some_new_key": "some_new_values"}
251+
241252

242253
@pytest.mark.skip(reason="Exception is temporarily disabled due to lock flakiness")
243254
@pytest.mark.asyncio

0 commit comments

Comments
 (0)