mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
* test(batches): cover the batch cost poller gaps left after #47190 * fix(batches): keep unbillable batches from blocking file deletes and new-batch polling The file delete check now ignores batches past MANAGED_OBJECT_STALENESS_CUTOFF_DAYS, a provider 404 for the output object retires the batch, each poll page takes the arrival lane first, a batch expires only after the poller visits it past the cutoff, and the compare-and-swap matches batch_processed instead of updated_at * test(batches): cover the full arrival page and a failed expiry write in the batch cost poller Old batches still get polled every other cycle while new batches fill the page, old batches that fill a page never push a new batch out after boot, and a failed stale_expired write no longer stops the rest of the page from being polled * fix(batches): share the poll page between old and new batches and hold output files until billed Each lane now gets at least half of the poll page, a lane with nothing left gives its half to the other, and a lane read that resumed mid-lane wraps to the start, so neither old nor new batches can starve the other. The delete guard applies the 7 day cutoff to input files only. Output and error files stay locked until the batch is billed or retired, and stale_expired rows no longer lock anything. Only a lasting provider failure expires a batch past the cutoff, so a timeout or a 5xx no longer gives up on a batch that may still bill. Past the cutoff a lasting failure, a lasting cost-tracking failure, or an output file id that never appeared retires a finished row instead of polling it forever. * fix(batches): retry refused finished batches past 7 days, expire unfinished ones on a failed retrieve A finished batch the provider refuses after 7 days (rotated key, bucket 403, a 404 that does not name the batch) now keeps retrying so its spend is written once the config is fixed, instead of retiring unbilled. A batch the provider still reports running keeps polling. A batch that is not finished in the database becomes stale_expired once a retrieve fails after 7 days, so an unreachable provider is not polled forever. An S3 NoSuchKey for the output object now counts as gone. * fix(batches): expire an unfinished old batch only after 3 failed retrieves in a row * fix(batches): keep retrying an unfinished old batch through timeouts, 429 and 5xx * fix(batches): wait 3 polls before expiring an old batch whose output id lags * fix(batches): match a resource id in a 404 message followed by punctuation * fix(batches): keep refusal and pending-output expiry streaks apart, and void a pending-output retirement on a client write * fix(batches): give up on unsettled batches past twice the staleness cutoff Replace the per-reason refusal and pending-output streaks with one give-up age, and inject a clock into the poller and the delete check so tests pin exact age boundaries * fix(batches): keep polling finished batches past the give-up age so their spend stays recoverable * test(batches): expect a restarted poller's first page to split between old and new batches * test(batches): pin the delete-guard tests to a fixed clock and type a new journal list * test(batches): type the provider helper and the storage 404 cases --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| fixtures | ||
| golden | ||
| __init__.py | ||
| _background_responses.py | ||
| _daily_activity_fixtures.py | ||
| test_agent_spend.py | ||
| test_autorouter_session_rollup.py | ||
| test_background_interaction_settlement.py | ||
| test_background_response_billed_once.py | ||
| test_background_response_billing_proxies.py | ||
| test_background_response_poll_retirement.py | ||
| test_baggage_tag_mappings.py | ||
| test_baseline_accounting.py | ||
| test_batch_completion_accounting.py | ||
| test_batch_enqueued_tokens_redis_lua.py | ||
| test_batch_observability.py | ||
| test_batch_poll_starvation.py | ||
| test_budget_limit_envelopes.py | ||
| test_cache_activity.py | ||
| test_cache_and_quota.py | ||
| test_chaos_burst_spend_once.py | ||
| test_container_spend.py | ||
| test_daily_activity_aggregated_breakdowns.py | ||
| test_daily_activity_key_alias_probes.py | ||
| test_daily_activity_key_metadata_query_timeout.py | ||
| test_daily_activity_key_owner.py | ||
| test_daily_activity_key_owner_faults.py | ||
| test_daily_activity_key_owner_traffic.py | ||
| test_daily_activity_repository.py | ||
| test_daily_activity_routes.py | ||
| test_daily_rollup_retry.py | ||
| test_daily_tag_spend_retention.py | ||
| test_disable_end_user_cost_tracking.py | ||
| test_disconnected_bedrock_messages_stream_billing.py | ||
| test_end_user_budget_enforcement.py | ||
| test_end_user_spend_without_proxy_user.py | ||
| test_expired_ui_session_failure_rows.py | ||
| test_failed_dispatch_tokens.py | ||
| test_filtered_ledger.py | ||
| test_gemini_tts_speech_billing.py | ||
| test_global_proxy_spend_counter.py | ||
| test_global_spend_report.py | ||
| test_global_spend_reset.py | ||
| test_google_genai_native_spend.py | ||
| test_image_generation_key_spend.py | ||
| test_key_budget_lockout.py | ||
| test_key_metadata_recovery_dropped_connection.py | ||
| test_key_metadata_recovery_probe_bounds.py | ||
| test_legacy_spend_logs_row_cap.py | ||
| test_messages_stream_usage_cost.py | ||
| test_model_router_selected_model.py | ||
| test_normalized_error_long_message.py | ||
| test_org_budget_cli_session_token.py | ||
| test_passthrough_budget_reservation.py | ||
| test_passthrough_request_tags.py | ||
| test_passthrough_stream_pricing_paths_spend.py | ||
| test_passthrough_upstream_model.py | ||
| test_prompt_caching_requests_pagination.py | ||
| test_ptu_share_attribution.py | ||
| test_redis_ttl_preserving_token_increment.py | ||
| test_requester_ip_address_logging.py | ||
| test_reset_budget_leader_election.py | ||
| test_responses_bridge_spend_once.py | ||
| test_responses_cache_write_itemization.py | ||
| test_responses_websocket_turn_rows.py | ||
| test_roi_branch_spend.py | ||
| test_router_cooldown_failure_row.py | ||
| test_scoped_spend_reports.py | ||
| test_service_tier_stream_billing.py | ||
| test_session_total_spend.py | ||
| test_shutdown_flush.py | ||
| test_spend_attribution_contracts.py | ||
| test_spend_calculate.py | ||
| test_spend_capture_rate_captured_spend.py | ||
| test_spend_log_caller_session.py | ||
| test_spend_log_read_scope.py | ||
| test_spend_log_tool_payload_content.py | ||
| test_spend_log_write_batching.py | ||
| test_spend_logs_metadata_fields.py | ||
| test_spend_rollup_accuracy.py | ||
| test_stream_alias_billing.py | ||
| test_streamed_usage_estimate.py | ||
| test_tag_budget_enforcement.py | ||
| test_team_budget_enforcement.py | ||
| test_team_daily_activity_aggregated.py | ||
| test_team_member_budget_alerts.py | ||
| test_team_member_spend.py | ||
| test_team_member_spend_flush.py | ||
| test_team_member_total_spend_reconciliation.py | ||
| test_user_budget_on_team_keys.py | ||
| test_vertex_image_regional_uplift.py | ||
| test_vertex_passthrough_regional_uplift_spend.py | ||
| test_vertex_regional_uplift_spend.py | ||