-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ux: wrap httpx to uniform connection errors (#278)
* wrap httpx to uniform connection errors * Update utils.py
- Loading branch information
Showing
5 changed files
with
37 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Any | ||
from urllib.parse import urlparse | ||
|
||
import click | ||
import httpx | ||
|
||
|
||
def request( | ||
method: str, url: str | httpx.URL, *args: Any, **kwargs: Any | ||
) -> httpx.Response: | ||
try: | ||
return httpx.request(method, url, *args, **kwargs) | ||
except httpx.ConnectError: | ||
parsed_url = urlparse(str(url)) | ||
raise click.ClickException( | ||
"Llama Deploy is not responding, check that the apiserver " | ||
f"is running at {parsed_url.scheme}://{parsed_url.netloc} and try again." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters