Convert formatting to use ruff instead of yapf + isort (#26247)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-05 07:06:22 -07:00
committed by GitHub
parent 17edd8a807
commit d6953beb91
1508 changed files with 115205 additions and 94107 deletions
+2 -4
View File
@@ -32,13 +32,11 @@ class AudioAsset:
@property
def audio_and_sample_rate(self) -> tuple[npt.NDArray, float]:
audio_path = get_vllm_public_assets(filename=self.filename,
s3_prefix=ASSET_DIR)
audio_path = get_vllm_public_assets(filename=self.filename, s3_prefix=ASSET_DIR)
return librosa.load(audio_path, sr=None)
def get_local_path(self) -> Path:
return get_vllm_public_assets(filename=self.filename,
s3_prefix=ASSET_DIR)
return get_vllm_public_assets(filename=self.filename, s3_prefix=ASSET_DIR)
@property
def url(self) -> str:
+3 -3
View File
@@ -20,8 +20,7 @@ def get_cache_dir() -> Path:
@lru_cache
def get_vllm_public_assets(filename: str,
s3_prefix: Optional[str] = None) -> Path:
def get_vllm_public_assets(filename: str, s3_prefix: Optional[str] = None) -> Path:
"""
Download an asset file from ``s3://vllm-public-assets``
and return the path to the downloaded file.
@@ -36,6 +35,7 @@ def get_vllm_public_assets(filename: str,
global_http_connection.download_file(
f"{VLLM_S3_BUCKET_URL}/{filename}",
asset_path,
timeout=envs.VLLM_IMAGE_FETCH_TIMEOUT)
timeout=envs.VLLM_IMAGE_FETCH_TIMEOUT,
)
return asset_path
+19 -10
View File
@@ -12,12 +12,21 @@ from .base import get_vllm_public_assets
VLM_IMAGES_DIR = "vision_model_images"
ImageAssetName = Literal["stop_sign", "cherry_blossom", "hato",
"2560px-Gfp-wisconsin-madison-the-nature-boardwalk",
"Grayscale_8bits_palette_sample_image",
"1280px-Venn_diagram_rgb", "RGBA_comp", "237-400x300",
"231-200x300", "27-500x500", "17-150x600",
"handelsblatt-preview", "paper-11"]
ImageAssetName = Literal[
"stop_sign",
"cherry_blossom",
"hato",
"2560px-Gfp-wisconsin-madison-the-nature-boardwalk",
"Grayscale_8bits_palette_sample_image",
"1280px-Venn_diagram_rgb",
"RGBA_comp",
"237-400x300",
"231-200x300",
"27-500x500",
"17-150x600",
"handelsblatt-preview",
"paper-11",
]
@dataclass(frozen=True)
@@ -28,12 +37,12 @@ class ImageAsset:
"""
Return s3 path for given image.
"""
return get_vllm_public_assets(filename=f"{self.name}.{ext}",
s3_prefix=VLM_IMAGES_DIR)
return get_vllm_public_assets(
filename=f"{self.name}.{ext}", s3_prefix=VLM_IMAGES_DIR
)
@property
def pil_image(self, ext="jpg") -> Image.Image:
image_path = self.get_path(ext)
return Image.open(image_path)
@@ -42,7 +51,7 @@ class ImageAsset:
"""
Image embeddings, only used for testing purposes with llava 1.5.
"""
image_path = self.get_path('pt')
image_path = self.get_path("pt")
return torch.load(image_path, map_location="cpu", weights_only=True)
def read_bytes(self, ext: str) -> bytes:
+6 -5
View File
@@ -65,13 +65,14 @@ def video_to_ndarrays(path: str, num_frames: int = -1) -> npt.NDArray:
frames = np.stack(frames)
if len(frames) < num_frames:
raise ValueError(f"Could not read enough frames from video file {path}"
f" (expected {num_frames} frames, got {len(frames)})")
raise ValueError(
f"Could not read enough frames from video file {path}"
f" (expected {num_frames} frames, got {len(frames)})"
)
return frames
def video_to_pil_images_list(path: str,
num_frames: int = -1) -> list[Image.Image]:
def video_to_pil_images_list(path: str, num_frames: int = -1) -> list[Image.Image]:
frames = video_to_ndarrays(path, num_frames)
return [Image.fromarray(frame) for frame in frames]
@@ -139,7 +140,7 @@ class VideoAsset:
def get_audio(self, sampling_rate: Optional[float] = None) -> npt.NDArray:
"""
Read audio data from the video asset, used in Qwen2.5-Omni examples.
See also: examples/offline_inference/qwen2_5_omni/only_thinker.py
"""
return librosa.load(self.video_path, sr=sampling_rate)[0]