Skip to content

Update enduser spend and budget reset date based on budget duration - #8460

Merged
16 commits merged into
BerriAI:mainfrom
laurien16:fix/reset-end-user-budget-by-duration
Jun 8, 2025
Merged

Update enduser spend and budget reset date based on budget duration#8460
16 commits merged into
BerriAI:mainfrom
laurien16:fix/reset-end-user-budget-by-duration

Conversation

@laurien16

@laurien16 laurien16 commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Title

Reset enduser spend based on budget duration

Relevant issues

Fixes #7129

Type

🐛 Bug Fix
✅ Test

Changes

  1. On budget creation, set the budget_reset_at if it's None, but a budget_duration is given (litellm/proxy/management_endpoints/budget_management_endpoints.py).
  2. Expand get_data-function in litellm/proxy/utils.py to also get data from budget table based on a passed reset_at date and from enduser table based on a passed list of budget ids.
  3. Expand update_data-function to also update budget table and enduser table accordingly.
  4. The reset_budget-function contains a new logic that ensures that the budgets whose reset period has expired are updated and that the corresponding end-user spend values are properly reset.

Testing

image
image

@vercel

vercel Bot commented Feb 11, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 5:10am

@ghost

ghost commented Feb 12, 2025

Copy link
Copy Markdown

Thank you for this PR @laurien16

Can you share a screenshot of this passing your testing?

@laurien16

Copy link
Copy Markdown
Contributor Author

Hi @krrishdholakia, I added a screenshot of the two created and passing tests. Do you need anything else?

@laurien16

Copy link
Copy Markdown
Contributor Author

Hi @krrishdholakia, I updated the PR according to the new code structure. Are there any plans about merging this fix? Do you need anything else?

All relevant tests are running successfully:

image
image

@CLAassistant

CLAassistant commented Apr 22, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Simon-Stone

Copy link
Copy Markdown
Contributor

Is this under consideration to be merged soon? Budget reset for end users is currently not working at all and this would be immensely helpful.

@Simon-Stone

Copy link
Copy Markdown
Contributor

@krrishdholakia Does anyone have this on their radar? Without this PR, the budgets for end users won't reset, which is a major bug. Or was this fixed somewhere else?

I merged the PR in my personal fork and works very well.

@ghost

ghost commented May 22, 2025

Copy link
Copy Markdown

Thanks for the bump @Simon-Stone - looking into this now

@ghost

ghost commented May 22, 2025

Copy link
Copy Markdown

@laurien16 this looks like it's failing linting + tests, can you please look into this?

@Simon-Stone

Copy link
Copy Markdown
Contributor

If @laurien16 can't deal with this soon, I would be happy to open another PR from my fork.

@ghost

ghost commented May 23, 2025

Copy link
Copy Markdown

that'd be great! @Simon-Stone

@laurien16

Copy link
Copy Markdown
Contributor Author

Hi @krrishdholakia, hi @Simon-Stone, I can have a look at this early next week and adapt it to the new codebase if that is sufficient.

@laurien16

Copy link
Copy Markdown
Contributor Author

Hi @krrishdholakia, conflicts are resolved now, all checks have passed.

@Simon-Stone

Copy link
Copy Markdown
Contributor

@krrishdholakia any plans to consider this? It's a crucial fix. Last I checked, end user budgets otherwise don't reset, which makes them unusable for any recurring budgets.

@ghost
ghost merged commit 0c50f8b into BerriAI:main Jun 8, 2025
@ghost

ghost commented Jun 8, 2025

Copy link
Copy Markdown

Thanks @laurien16 for the work and @Simon-Stone for the bump on this!

Fix will be live on tomorrow's nightly.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: end-user budget_duration stills not seem to reset

3 participants