Skip to content

Commit b8fc601

Browse files
committed
Added a extra check in isvc to make sure model is fully loaded
Signed-off-by: Milind Waykole <mwaykole@redhat.com>
1 parent 63a327f commit b8fc601

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

utilities/inference_utils.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,21 @@ def create_isvc(
769769
timeout=timeout_watch.remaining_time(),
770770
)
771771

772+
# After the InferenceService reports Ready, the backing model should be fully loaded and up to date,
773+
# when modelStatus is reported by the runtime.
774+
model_status = getattr(inference_service.instance.status, "modelStatus", None)
775+
if model_status and getattr(model_status, "states", None):
776+
active_state = model_status.states.activeModelState
777+
target_state = model_status.states.targetModelState
778+
transition_status = model_status.transitionStatus
779+
if not (active_state == "Loaded" and target_state == "Loaded" and transition_status == "UpToDate"):
780+
raise AssertionError(
781+
"InferenceService modelStatus is not in Loaded/UpToDate state. "
782+
f"activeModelState={active_state!r}, "
783+
f"targetModelState={target_state!r}, "
784+
f"transitionStatus={transition_status!r}"
785+
)
786+
772787
yield inference_service
773788

774789

@@ -777,7 +792,7 @@ def _check_storage_arguments(
777792
storage_key: Optional[str],
778793
storage_path: Optional[str],
779794
) -> None:
780-
"""
795+
"""
781796
Check if storage_uri, storage_key and storage_path are valid.
782797
783798
Args:

0 commit comments

Comments
 (0)