mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(batch-jobs): serialize datetime objects in batch job logging response
This commit is contained in:
parent
a645d464e6
commit
8d5c43b766
2 changed files with 12 additions and 2 deletions
|
|
@ -267,10 +267,16 @@ class BedrockBatchesHandler:
|
|||
response = client.get_model_invocation_job(jobIdentifier=batch_id)
|
||||
|
||||
if logging_obj is not None:
|
||||
# boto3 returns native datetime objects for time fields
|
||||
# (submitTime, endTime, …) and in ResponseMetadata. The
|
||||
# logging post_call path calls json.dumps() on dict responses,
|
||||
# which chokes on datetime — so we serialize with default=str.
|
||||
import json as _json
|
||||
|
||||
logging_obj.post_call(
|
||||
input=batch_id,
|
||||
api_key="",
|
||||
original_response=response,
|
||||
original_response=_json.dumps(response, default=str),
|
||||
additional_args={"complete_input_dict": {"jobIdentifier": batch_id}},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -300,7 +300,11 @@ def test_logging_obj_pre_and_post_call_invoked(patched_boto3):
|
|||
|
||||
post_kwargs = logging_obj.post_call.call_args.kwargs
|
||||
assert post_kwargs["input"] == JOB_ARN
|
||||
assert post_kwargs["original_response"]["jobArn"] == JOB_ARN
|
||||
# original_response is JSON-serialized (str) because boto3 returns
|
||||
# datetime objects that json.dumps() cannot handle natively.
|
||||
import json
|
||||
parsed = json.loads(post_kwargs["original_response"])
|
||||
assert parsed["jobArn"] == JOB_ARN
|
||||
|
||||
|
||||
def test_missing_boto3_raises_helpful_import_error():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue