Skip to content

Commit

Permalink
[release] Handle exceptions on requests failure when retrieving wheel (
Browse files Browse the repository at this point in the history
…#28685)

Exceptions currently not caught when getting wheel URL, causing tests to fail

Signed-off-by: rickyyx <rickyx@anyscale.com>
Signed-off-by: Kai Fricke <kai@anyscale.com>
Co-authored-by: Kai Fricke <kai@anyscale.com>
  • Loading branch information
rickyyx and Kai Fricke committed Oct 29, 2022
1 parent e4040ee commit 399d383
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions release/ray_release/tests/test_wheels.py
Expand Up @@ -9,6 +9,7 @@
from ray_release.config import Test
from ray_release.template import load_test_cluster_env
from ray_release.exception import RayWheelsNotFoundError, RayWheelsTimeoutError
from ray_release.util import url_exists
from ray_release.wheels import (
get_ray_version,
DEFAULT_REPO,
Expand Down Expand Up @@ -243,6 +244,11 @@ def override_env(path, env):
assert sha in this_env["env"]["RAY_WHEELS_SANITY_CHECK"]


def test_url_exist():
assert url_exists("https://github.com/")
assert not url_exists("invalid://somewhere")


if __name__ == "__main__":
import pytest

Expand Down
6 changes: 5 additions & 1 deletion release/ray_release/util.py
Expand Up @@ -42,7 +42,11 @@ def dict_hash(dt: Dict[Any, Any]) -> str:


def url_exists(url: str) -> bool:
return requests.head(url, allow_redirects=True).status_code == 200
try:
return requests.head(url, allow_redirects=True).status_code == 200
except requests.exceptions.RequestException:
logger.exception(f"Failed to check url exists: {url}")
return False


def resolve_url(url: str) -> str:
Expand Down

0 comments on commit 399d383

Please sign in to comment.