Spaces:
Runtime error
Runtime error
fix: InferenceTimeoutError outdated
Browse files
app.py
CHANGED
|
@@ -35,7 +35,7 @@ from huggingface_hub.utils import (
|
|
| 35 |
from huggingface_hub.inference._common import (
|
| 36 |
TASKS_EXPECTING_IMAGES,
|
| 37 |
ContentT,
|
| 38 |
-
InferenceTimeoutError,
|
| 39 |
ModelStatus,
|
| 40 |
_b64_encode,
|
| 41 |
_b64_to_image,
|
|
@@ -216,7 +216,7 @@ class InferenceClientUS(InferenceClient):
|
|
| 216 |
)
|
| 217 |
except TimeoutError as error:
|
| 218 |
# Convert any `TimeoutError` to a `InferenceTimeoutError`
|
| 219 |
-
raise
|
| 220 |
|
| 221 |
try:
|
| 222 |
hf_raise_for_status(response)
|
|
@@ -225,12 +225,18 @@ class InferenceClientUS(InferenceClient):
|
|
| 225 |
if error.response.status_code == 503:
|
| 226 |
# If Model is unavailable, either raise a TimeoutError...
|
| 227 |
if timeout is not None and time.time() - t0 > timeout:
|
| 228 |
-
raise InferenceTimeoutError(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
f"Model not loaded on the server: {url}. Please retry with a higher timeout (current:"
|
| 230 |
-
f" {self.timeout})
|
| 231 |
-
request=error.request,
|
| 232 |
-
response=error.response,
|
| 233 |
-
)
|
| 234 |
# ...or wait 1s and retry
|
| 235 |
logger.info(f"Waiting for model to be loaded on the server: {error}")
|
| 236 |
time.sleep(1)
|
|
|
|
| 35 |
from huggingface_hub.inference._common import (
|
| 36 |
TASKS_EXPECTING_IMAGES,
|
| 37 |
ContentT,
|
| 38 |
+
# InferenceTimeoutError,
|
| 39 |
ModelStatus,
|
| 40 |
_b64_encode,
|
| 41 |
_b64_to_image,
|
|
|
|
| 216 |
)
|
| 217 |
except TimeoutError as error:
|
| 218 |
# Convert any `TimeoutError` to a `InferenceTimeoutError`
|
| 219 |
+
raise ValueError(f"Inference call timed out: {url}, {error}") # type: ignore
|
| 220 |
|
| 221 |
try:
|
| 222 |
hf_raise_for_status(response)
|
|
|
|
| 225 |
if error.response.status_code == 503:
|
| 226 |
# If Model is unavailable, either raise a TimeoutError...
|
| 227 |
if timeout is not None and time.time() - t0 > timeout:
|
| 228 |
+
# raise InferenceTimeoutError(
|
| 229 |
+
# f"Model not loaded on the server: {url}. Please retry with a higher timeout (current:"
|
| 230 |
+
# f" {self.timeout}).",
|
| 231 |
+
# request=error.request,
|
| 232 |
+
# response=error.response,
|
| 233 |
+
# ) from error
|
| 234 |
+
raise ValueError(
|
| 235 |
f"Model not loaded on the server: {url}. Please retry with a higher timeout (current:"
|
| 236 |
+
f" {self.timeout}), Err:{error}"
|
| 237 |
+
# request=error.request,
|
| 238 |
+
# response=error.response,
|
| 239 |
+
)
|
| 240 |
# ...or wait 1s and retry
|
| 241 |
logger.info(f"Waiting for model to be loaded on the server: {error}")
|
| 242 |
time.sleep(1)
|