mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix(e2e): accept managed file deletion responses
This commit is contained in:
parent
a56c60e892
commit
6bdf206cc5
4 changed files with 22 additions and 2 deletions
|
|
@ -139,6 +139,9 @@ fallback for interrupted runs: immediate deletion remains the normal cleanup.
|
|||
Azure's minimum supported native expiry is 14 days, so a three-day expiry cannot
|
||||
be requested through its Files API
|
||||
|
||||
The Azure entry in `files_settings` must use `api_version: 2025-04-01-preview`
|
||||
for raw uploads to honor expiry, matching the batch deployment's API version
|
||||
|
||||
## Terminal state + cost write-back (cross-run marker baton)
|
||||
|
||||
The 24h completion window rules out submit-and-wait inside one run, so
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ def cleanup_file(client: BatchCleanupClient, file_id: str, *, key: str, provider
|
|||
if isinstance(result, UnknownApiError) and result.status_code == 404:
|
||||
return
|
||||
deleted: Final = _require_cleanup_success(result, f"Delete file {file_id}")
|
||||
assert deleted.deleted, f"Delete file {file_id} did not confirm deletion"
|
||||
assert deleted.deleted is True or (
|
||||
deleted.deleted is None and is_managed_id(file_id) and deleted.id == file_id and deleted.object == "file"
|
||||
), f"Delete file {file_id} did not confirm deletion"
|
||||
|
||||
|
||||
def cleanup_batch(
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class BatchList(BaseModel):
|
|||
class FileDeleteResponse(BaseModel):
|
||||
id: str
|
||||
object: str | None = None
|
||||
deleted: bool
|
||||
deleted: bool | None = None
|
||||
|
||||
|
||||
class BatchCreateBody(BaseModel):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from e2e_http import NetworkError, RateLimitedError, Result, Success, UnknownApi
|
|||
from lifecycle import ResourceManager
|
||||
from models import KeyGenerateBody
|
||||
|
||||
MANAGED_FILE_ID: Final = "bGl0ZWxsbV9wcm94eTtmaWxlLTE="
|
||||
MANAGED_BATCH_ID: Final = "bGl0ZWxsbV9wcm94eTtiYXRjaC0x"
|
||||
|
||||
|
||||
|
|
@ -53,6 +54,20 @@ def deleted_file(*, deleted: bool = True) -> Success[FileDeleteResponse]:
|
|||
|
||||
|
||||
class TestFileCleanup:
|
||||
def test_managed_delete_accepts_the_deleted_file_object(self) -> None:
|
||||
response: Final = Success(
|
||||
status_code=200, data=FileDeleteResponse.model_validate({"id": MANAGED_FILE_ID, "object": "file"})
|
||||
)
|
||||
client: Final = CleanupClient(files=iter((response,)))
|
||||
cleanup_file(client, MANAGED_FILE_ID, key="test-key")
|
||||
assert client.calls == [f"delete None {MANAGED_FILE_ID}"]
|
||||
|
||||
@pytest.mark.parametrize("file_id", ["file-1", MANAGED_FILE_ID])
|
||||
def test_a_success_status_without_a_deletion_confirmation_is_rejected(self, file_id: str) -> None:
|
||||
client: Final = CleanupClient(files=iter((Success(status_code=200, data=FileDeleteResponse(id=file_id)),)))
|
||||
with pytest.raises(AssertionError, match="did not confirm deletion"):
|
||||
cleanup_file(client, file_id, key="test-key")
|
||||
|
||||
@pytest.mark.parametrize("cap", CAPABILITIES, ids=[cap.id for cap in CAPABILITIES])
|
||||
def test_deletes_raw_files_through_the_upload_provider(self, cap: Capability) -> None:
|
||||
client: Final = CleanupClient(files=iter((deleted_file(),)))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue