Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions vlmrun/client/predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations
import json
import warnings
from pathlib import Path
from typing import List, Optional, Union
from PIL import Image
Expand Down Expand Up @@ -497,6 +498,12 @@ def execute(
) -> PredictionResponse:
"""Generate a document prediction using a named model.

.. deprecated::
The /document/execute endpoint has been removed in v0.19.0.
Redaction domains are now served via /document/generate.
Use ``generate(domain="healthcare.phi-redaction", ...)``
instead of ``execute(name="healthcare/phi-redaction", ...)``.

Args:
name: Name of the model to execute
version: Version of the model to execute
Expand All @@ -511,32 +518,23 @@ def execute(
Returns:
PredictionResponse: Prediction response
"""
is_url, file_or_url = self._handle_file_or_url(file, url)

additional_kwargs = {}
if config:
additional_kwargs["config"] = config.model_dump()
if metadata:
additional_kwargs["metadata"] = metadata.model_dump()
response, status_code, headers = self._requestor.request(
method="POST",
url=f"{route}/execute",
data={
"name": name,
"version": version,
"url" if is_url else "file_id": file_or_url,
"batch": batch,
"callback_url": callback_url,
**additional_kwargs,
},
warnings.warn(
f"{route}.execute() is deprecated and will be removed in a future release. "
f"Use {route}.generate(domain='{name.replace('/', '.')}', ...) instead.",
DeprecationWarning,
stacklevel=2,
)
domain = name.replace("/", ".")
return self.generate(
file=file,
url=url,
domain=domain,
batch=batch,
config=config,
metadata=metadata,
callback_url=callback_url,
autocast=autocast,
)
if not isinstance(response, dict):
raise TypeError("Expected dict response")
prediction = PredictionResponse(**response)

if autocast:
self._cast_response_to_schema(prediction, name, config)
return prediction

def schema(
self,
Expand Down
Loading