Skip to content

feat(predictions): add warnings for callback_url and batch usage in image predictions#193

Open
shahrear33 wants to merge 1 commit into
mainfrom
sh/callback-warning
Open

feat(predictions): add warnings for callback_url and batch usage in image predictions#193
shahrear33 wants to merge 1 commit into
mainfrom
sh/callback-warning

Conversation

@shahrear33

@shahrear33 shahrear33 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

…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.

Open in Devin Review

…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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review



def _warn_callback_requires_batch(
callback_url: Optional[str], batch: bool, is_image: bool = False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
callback_url: Optional[str], batch: bool, is_image: bool = False
callback_url: str | None, batch: bool, is_image: bool = False
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines 324 to 326
# Input validation
if not images and not urls:
raise ValueError("Either `images` or `urls` must be provided")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 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)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant