[CI fix] Fix image download failures in VLM CI tests (#13613)

This commit is contained in:
Xiaoyu Zhang
2025-11-20 11:18:06 +08:00
committed by GitHub
parent 48ca9f7518
commit dc69462456
4 changed files with 24 additions and 14 deletions

View File

@@ -16,6 +16,7 @@ import unittest
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from functools import partial, wraps
from io import BytesIO
from pathlib import Path
from types import SimpleNamespace
from typing import Any, Awaitable, Callable, List, Optional, Tuple
@@ -25,6 +26,7 @@ import numpy as np
import requests
import torch
import torch.nn.functional as F
from PIL import Image
from sglang.bench_serving import run_benchmark
from sglang.global_config import global_config
@@ -129,6 +131,22 @@ DEFAULT_VIDEO_URL = "https://raw.githubusercontent.com/EvolvingLMMs-Lab/sglang/d
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH = 600
def download_image_with_retry(image_url: str, max_retries: int = 3) -> Image.Image:
for i in range(max_retries):
try:
response = requests.get(image_url, timeout=30)
response.raise_for_status()
image = Image.open(BytesIO(response.content))
image.load()
return image
except Exception as e:
if i == max_retries - 1:
raise RuntimeError(
f"Failed to download image after {max_retries} retries: {image_url}"
) from e
time.sleep(2**i)
def is_in_ci():
"""Return whether it is in CI runner."""
return get_bool_env_var("SGLANG_IS_IN_CI")