@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / bbfb55c29e
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 12, 03:30 UTC

[Misc] Allow `fetch_*` utils to access local files by default (#29932)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed Dec 3, 2025 at 15:49 UTC bbfb55c29e7febb91e90f261dd9adb4200ee3a09
2 files changed +31 -9
vllm/multimodal/utils.py
+30 -8
@@ -67,8 +67,9 @@ class MediaConnector:
67 to set num_frames for video, set
68 `--media-io-kwargs '{"video":{"num_frames":40}}'`
69 connection: HTTP connection client to download media contents.
70 - allowed_local_media_path: A local directory to load media files
71 - from.
70 + allowed_local_media_path: A local directory to load media files from.
71 + allowed_media_domains: If set, only media URLs that belong to this
72 + domain can be used for multi-modal inputs.
73 """
74 super().__init__()
75
@@ -123,16 +124,16 @@ class MediaConnector:
124 "Cannot load local files without `--allowed-local-media-path`."
125 )
126
126 - filepath = Path(url2pathname(url_spec.path))
127 + filepath = Path(url2pathname(url_spec.netloc + url_spec.path))
128 if allowed_local_media_path not in filepath.resolve().parents:
129 raise ValueError(
130 f"The file path {filepath} must be a subpath "
130 - f"of `--allowed-local-media-path` {allowed_local_media_path}."
131 + f"of `--allowed-local-media-path {allowed_local_media_path}`."
132 )
133
134 return media_io.load_file(filepath)
135
135 - def _assert_url_in_allowed_media_domains(self, url_spec) -> None:
136 + def _assert_url_in_allowed_media_domains(self, url_spec: ParseResult) -> None:
137 if (
138 self.allowed_media_domains
139 and url_spec.hostname not in self.allowed_media_domains
@@ -489,9 +490,16 @@ def fetch_audio(
490 Args:
491 audio_url: URL of the audio file to fetch.
492 audio_io_kwargs: Additional kwargs passed to handle audio IO.
493 +
494 + Warning:
495 + This method has direct access to local files and is only intended
496 + to be called by user code. Never call this from the online server!
497 """
498 media_io_kwargs = None if not audio_io_kwargs else {"audio": audio_io_kwargs}
494 - media_connector = MediaConnector(media_io_kwargs=media_io_kwargs)
499 + media_connector = MediaConnector(
500 + media_io_kwargs=media_io_kwargs,
501 + allowed_local_media_path="/",
502 + )
503 return media_connector.fetch_audio(audio_url)
504
505
@@ -503,9 +511,16 @@ def fetch_image(
511 Args:
512 image_url: URL of the image file to fetch.
513 image_io_kwargs: Additional kwargs passed to handle image IO.
514 +
515 + Warning:
516 + This method has direct access to local files and is only intended
517 + to be called by user code. Never call this from the online server!
518 """
519 media_io_kwargs = None if not image_io_kwargs else {"image": image_io_kwargs}
508 - media_connector = MediaConnector(media_io_kwargs=media_io_kwargs)
520 + media_connector = MediaConnector(
521 + media_io_kwargs=media_io_kwargs,
522 + allowed_local_media_path="/",
523 + )
524 return media_connector.fetch_image(image_url)
525
526
@@ -517,7 +532,14 @@ def fetch_video(
532 Args:
533 video_url: URL of the video file to fetch.
534 video_io_kwargs: Additional kwargs passed to handle video IO.
535 +
536 + Warning:
537 + This method has direct access to local files and is only intended
538 + to be called by user code. Never call this from the online server!
539 """
540 media_io_kwargs = None if not video_io_kwargs else {"video": video_io_kwargs}
522 - media_connector = MediaConnector(media_io_kwargs=media_io_kwargs)
541 + media_connector = MediaConnector(
542 + media_io_kwargs=media_io_kwargs,
543 + allowed_local_media_path="/",
544 + )
545 return media_connector.fetch_video(video_url)
vllm/multimodal/video.py
+1 -1
@@ -267,7 +267,7 @@ class OpenCVDynamicVideoBackend(OpenCVVideoBackend):
267 return frames, metadata
268
269
270 -class VideoMediaIO(MediaIO[npt.NDArray]):
270 +class VideoMediaIO(MediaIO[tuple[npt.NDArray, dict[str, Any]]]):
271 def __init__(
272 self,
273 image_io: ImageMediaIO,