Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tests/e2e/batches/COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ reporting failures as test errors. Already deleted files and batches that are
terminal are safe to clean up again. Managed batch cancellation polls for up to two minutes
before input deletion. A managed batch still `cancelling` after that is left for the provider to
finish, and its input file is left in place because LiteLLM refuses to delete a file a non-terminal
batch references. Both are reported as `BatchCleanupLeftover` warnings naming their ids rather than
batch references. Both are reported as `UserWarning`s naming their ids rather than
failing the test. Any other status or error still fails
Accepted cancellation may still report validating or in_progress while the provider
updates its state. Raw and model-encoded batches are polled until cancelling or
Expand Down
8 changes: 2 additions & 6 deletions tests/e2e/batches/batch_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def retrieve_batch(self, batch_id: str, *, key: str, provider: str | None = None
def cancel_batch(self, batch_id: str, *, key: str, provider: str | None = None) -> Result[BatchObject]: ...


class BatchCleanupLeftover(UserWarning):
pass


def cleanup_result[R: BaseModel](
action: Callable[[], Result[R]], *, wait: Callable[[float], None] = sleep
) -> Result[R]:
Expand Down Expand Up @@ -68,7 +64,7 @@ def cleanup_file(client: BatchCleanupClient, file_id: str, *, key: str, provider
if isinstance(result, UnknownApiError) and result.status_code == 400 and FILE_IN_USE_REFUSAL in result.body:
warnings.warn(
f"Left file {file_id} in place: LiteLLM refused to delete it while a batch still references it",
BatchCleanupLeftover,
UserWarning,
stacklevel=2,
)
return
Expand Down Expand Up @@ -140,7 +136,7 @@ def cleanup_batch(
)
warnings.warn(
f"Left batch {batch_id} cancelling after {BATCH_CANCEL_TIMEOUT_SECONDS}s for the provider to finish",
BatchCleanupLeftover,
UserWarning,
stacklevel=2,
)
return
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/batches/test_batch_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from batch_cleanup import (
BATCH_CANCEL_TIMEOUT_SECONDS,
CLEANUP_DELAYS,
BatchCleanupLeftover,
cleanup_batch,
cleanup_file,
cleanup_result,
Expand Down Expand Up @@ -141,7 +140,7 @@ def test_delete_refused_because_a_batch_still_references_the_file_is_left_and_re
calls=ExpectedCalls((f"delete None {MANAGED_FILE_ID}",)),
files=(UnknownApiError(status_code=400, body=IN_USE_REFUSAL),),
)
with pytest.warns(BatchCleanupLeftover, match=MANAGED_FILE_ID):
with pytest.warns(UserWarning, match=MANAGED_FILE_ID):
cleanup_file(client, MANAGED_FILE_ID, key="test-key")
client.calls.assert_done()

Expand Down Expand Up @@ -241,7 +240,7 @@ def test_batch_still_cancelling_at_the_deadline_and_its_input_file_are_left_and_
key: Final = manager.key()
manager.defer(lambda: cleanup_file(client, MANAGED_FILE_ID, key=key))
manager.defer(lambda: cleanup_batch(client, MANAGED_BATCH_ID, key=key, clock=ticks))
with pytest.warns(BatchCleanupLeftover) as leftovers:
with pytest.warns(UserWarning, match="^Left ") as leftovers:
manager.teardown()
client.calls.assert_done()
messages: Final = tuple(str(warning.message) for warning in leftovers)
Expand Down
Loading