Skip to content

Commit b22205e

Browse files
rnetserdbasunag
authored andcommitted
fix: address 503 (opendatahub-io#274)
1 parent 32ee5f8 commit b22205e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

utilities/inference_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import shlex
44
from contextlib import contextmanager
5+
from http import HTTPStatus
56
from json import JSONDecodeError
67
from string import Template
78
from typing import Any, Optional, Generator
@@ -16,7 +17,7 @@
1617
from simple_logger.logger import get_logger
1718
from timeout_sampler import TimeoutWatch, retry
1819

19-
from utilities.exceptions import InvalidStorageArgumentError
20+
from utilities.exceptions import InferenceResponseError, InvalidStorageArgumentError
2021
from utilities.infra import (
2122
get_inference_serving_runtime,
2223
get_model_route,
@@ -440,7 +441,14 @@ def run_inference(self, cmd: str) -> str:
440441
else:
441442
res, out, err = run_command(command=shlex.split(cmd), verify_stderr=False, check=False)
442443

443-
if not res:
444+
if res:
445+
if f"http/1.0 {HTTPStatus.SERVICE_UNAVAILABLE}" in out.lower():
446+
raise InferenceResponseError(
447+
f"The Route for {self.get_inference_url()} is not ready yet. "
448+
f"Got {HTTPStatus.SERVICE_UNAVAILABLE} error."
449+
)
450+
451+
else:
444452
raise ValueError(f"Inference failed with error: {err}\nOutput: {out}\nCommand: {cmd}")
445453

446454
LOGGER.info(f"Inference output:\n{out}")

0 commit comments

Comments
 (0)