Skip to content

Commit

Permalink
Update src/huggingface_hub/_inference_endpoints.py
Browse files Browse the repository at this point in the history
improve code clarity and added logging based on review

Co-authored-by: Célina <[email protected]>
  • Loading branch information
Ajinkya-25 and hanouticelina authored Feb 19, 2025
1 parent 2f26521 commit b0e8889
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/huggingface_hub/_inference_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,20 @@ def wait(self, timeout: Optional[int] = None, refresh_every: int = 5) -> "Infere

start = time.time()
while True:
if self.url is not None:
# Means the URL is provisioned => check if the endpoint is reachable
if self.status == InferenceEndpointStatus.FAILED:
raise InferenceEndpointError(
f"Inference Endpoint {self.name} failed to deploy. Please check the logs for more information."
)
if self.status == InferenceEndpointStatus.UPDATE_FAILED:
raise InferenceEndpointError(
f"Inference Endpoint {self.name} failed to update. Please check the logs for more information."
)
if self.status == InferenceEndpointStatus.RUNNING and self.url is not None:
# Verify the endpoint is actually reachable
response = get_session().get(self.url, headers=self._api._build_hf_headers(token=self._token))
if response.status_code == 200:
logger.info("Inference Endpoint is ready to be used.")
return self
if response.status_code == 200 and self.status not in [
InferenceEndpointStatus.UPDATING,
InferenceEndpointStatus.UPDATE_FAILED,
Expand Down

0 comments on commit b0e8889

Please sign in to comment.