feat(predictions): add warnings for callback_url and batch usage in image predictions#193
feat(predictions): add warnings for callback_url and batch usage in image predictions#193shahrear33 wants to merge 1 commit into
Conversation
…mage predictions This update introduces a new private function `_warn_callback_requires_batch` to issue warnings when the `callback_url` and `batch` parameters are used incorrectly in image predictions. The function checks if `batch` is set to `True` for image predictions, which is unsupported, and warns the user accordingly. It also warns if `callback_url` is provided, as it is not applicable for synchronous image predictions. The warnings are integrated into the `ImagePredictions` and `FilePredictions` classes to enhance user experience and prevent confusion. ### Changes - Added `_warn_callback_requires_batch` function to handle warning logic. - Integrated warning calls in `ImagePredictions` and `FilePredictions` methods.
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function _warn_callback_requires_batch in vlmrun/client/predictions.py to issue user warnings when incompatible parameters are provided. Specifically, it warns if batch=True or a callback_url is specified for synchronous image predictions, or if a callback_url is provided without enabling batching (batch=False) for standard predictions. This helper is integrated into the relevant execute and generate methods. There are no review comments, and we have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
|
|
||
| def _warn_callback_requires_batch( | ||
| callback_url: Optional[str], batch: bool, is_image: bool = False |
There was a problem hiding this comment.
🟡 New code uses Optional[str] instead of str | None violating AGENTS.md modern Python style rule
The AGENTS.md explicitly mandates: "Use X | None instead of Optional[X] for type hints (PEP 604)" and "Use | for union types in all new code." The newly added _warn_callback_requires_batch function uses Optional[str] for its callback_url parameter type hint, which violates this rule. Since the file already has from __future__ import annotations (line 3), using str | None is fully supported.
| callback_url: Optional[str], batch: bool, is_image: bool = False | |
| callback_url: str | None, batch: bool, is_image: bool = False | |
Was this helpful? React with 👍 or 👎 to provide feedback.
| # Input validation | ||
| if not images and not urls: | ||
| raise ValueError("Either `images` or `urls` must be provided") |
There was a problem hiding this comment.
🚩 Duplicate image processing in ImagePredictions.generate persists
The ImagePredictions.generate method (lines 325-354) has a pre-existing issue where images are processed inline (opened from disk at line 336, encoded at line 341) and then self._handle_images_or_urls(images, urls) is called again at line 354, which re-encodes the already-opened PIL images. The result from the inline processing (line 341's images_data) is overwritten. This means images get encoded to JPEG twice — wasteful but functionally correct since the second encoding produces the same result. This PR doesn't introduce or worsen this issue, but it's worth noting as technical debt.
(Refers to lines 324-354)
Was this helpful? React with 👍 or 👎 to provide feedback.
…mage predictions
This update introduces a new private function
_warn_callback_requires_batchto issue warnings when thecallback_urlandbatchparameters are used incorrectly in image predictions. The function checks ifbatchis set toTruefor image predictions, which is unsupported, and warns the user accordingly. It also warns ifcallback_urlis provided, as it is not applicable for synchronous image predictions. The warnings are integrated into theImagePredictionsandFilePredictionsclasses to enhance user experience and prevent confusion.Changes
_warn_callback_requires_batchfunction to handle warning logic.ImagePredictionsandFilePredictionsmethods.