fix(batches): refine bedrock cancel_batch type hints and validation error handling

This commit is contained in:
Arjun Pakhan 2026-07-21 06:24:17 +00:00
parent fc36825dfd
commit 163ab6e34b
4 changed files with 13 additions and 10 deletions

View file

@ -944,7 +944,7 @@ async def acancel_batch(
def cancel_batch(
batch_id: str,
model: Optional[str] = None,
custom_llm_provider: Union[Literal["openai", "azure", "vertex_ai"], str] = "openai",
custom_llm_provider: Union[Literal["openai", "azure", "vertex_ai", "bedrock"], str] = "openai",
metadata: Optional[Dict[str, str]] = None,
extra_headers: Optional[Dict[str, str]] = None,
extra_body: Optional[Dict[str, str]] = None,

View file

@ -113,8 +113,13 @@ class BedrockBatchesHandler:
try:
client.stop_model_invocation_job(jobIdentifier=batch_id)
except ClientError as e:
# Idempotency: if job is already Stopping/Stopped/Completed, swallow ValidationException
if e.response.get("Error", {}).get("Code") != "ValidationException":
error_code = e.response.get("Error", {}).get("Code")
error_msg = e.response.get("Error", {}).get("Message", "").lower()
if error_code == "ValidationException" and any(
term in error_msg for term in ["stop", "terminal", "completed", "already"]
):
pass
else:
raise e
return BedrockBatchesHandler._handle_model_invocation_job_status(

View file

@ -97,7 +97,7 @@ def load_rust_ocr() -> RustOcr | None:
import litellm_python_bridge
except ImportError:
return None
return cast(RustOcr, getattr(litellm_python_bridge, "ocr", None))
return cast(RustOcr, litellm_python_bridge.ocr)
def load_rust_aocr() -> RustAocr | None:

10
uv.lock generated
View file

@ -9,7 +9,7 @@ resolution-markers = [
]
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer = "2026-06-20T23:16:25.061268Z"
exclude-newer-span = "P3D"
[manifest]
@ -3160,15 +3160,15 @@ wheels = [
[[package]]
name = "langgraph-checkpoint"
version = "4.1.1"
version = "4.1.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "langchain-core" },
{ name = "ormsgpack" },
]
sdist = { url = "https://files.pythonhosted.org/packages/83/47/886af6f886f0bff2273164a45f008694e48a96ff3cd25ff0228f2aa9480e/langgraph_checkpoint-4.1.1.tar.gz", hash = "sha256:6c2bdb530c91f91d7d9c1bd100925d0fc4f498d418c17f3587d1526279482a25", size = 184020, upload-time = "2026-05-22T16:57:38.503Z" }
sdist = { url = "https://files.pythonhosted.org/packages/02/b4/6005c5dd88ad484fe6235d4c43a0d2cee7e91b08ad85a180985c2662df87/langgraph_checkpoint-4.1.0.tar.gz", hash = "sha256:e5bb304e30fc1363ac8fcb5f7dee5ca2185d77fe475b0d01de2c5f91324c2c21", size = 181942, upload-time = "2026-05-12T03:33:49.888Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/bd/b4/71425e3e38be92611300b9cc5e46a5bf98ab23f5ea8a75b73d02a2f1413c/langgraph_checkpoint-4.1.1-py3-none-any.whl", hash = "sha256:25d29144b082827218e7bc3f1e9b0566a4bb007895cd6cc26f66a8428739f56e", size = 56212, upload-time = "2026-05-22T16:57:37.203Z" },
{ url = "https://files.pythonhosted.org/packages/93/74/d3be2b41955e20ccd624dba5f6fe9d38dcee385ba470a6e13ed86732fc86/langgraph_checkpoint-4.1.0-py3-none-any.whl", hash = "sha256:8bc2a0466a20c38b865ce6671b42093fd5c041133f32351cae4222e0eeaf7fb5", size = 56047, upload-time = "2026-05-12T03:33:48.548Z" },
]
[[package]]
@ -3281,7 +3281,6 @@ dependencies = [
{ name = "importlib-metadata" },
{ name = "jinja2" },
{ name = "jsonschema" },
{ name = "langgraph-checkpoint" },
{ name = "openai" },
{ name = "pydantic" },
{ name = "python-dotenv" },
@ -3506,7 +3505,6 @@ requires-dist = [
{ name = "jinja2", specifier = ">=3.1.6,<4.0" },
{ name = "jsonschema", specifier = ">=4.0.0,<5.0" },
{ name = "langfuse", marker = "extra == 'proxy-runtime'", specifier = ">=2.59.7,<3.0" },
{ name = "langgraph-checkpoint", specifier = "==4.1.1" },
{ name = "litellm-enterprise", marker = "extra == 'proxy'", editable = "enterprise" },
{ name = "litellm-proxy-extras", marker = "extra == 'proxy'", editable = "litellm-proxy-extras" },
{ name = "llm-sandbox", marker = "extra == 'proxy-runtime'", specifier = ">=0.3.39,<1.0" },