Skip to content

Conversation

@knikolla
Copy link
Collaborator

@knikolla knikolla commented Dec 5, 2025

This PR introduces a new management command
coldfront fetch_daily_billable_usage --date <YYYY-MM>.

This management command fetches the daily billable usage reports stored in BackBlaze S3 under the following location /Invoices//Service Invoices/ .csv

For each allocation in either Active or Active (Needs Renewal) state of the 3 production clusters (NERC, NERC-OCP and NERC-EDU), the attribute named "Cumulative Daily Charges for Month" is updated with the latest total billable cost for that allocation for that given month.

The attribute stores the total in the following format: <YYYY-MM-DD>: <TOTAL> USD

If an allocation has the attribute Monthly Allocation Alert set to a value different than zero, an email is going to be sent to the PI ONCE after the total billable cost for that allocation has been exceeded.

Closes #274

This PR introduces a new management command
`coldfront fetch_daily_billable_usage --date <YYYY-MM>`.

This management command fetches the daily billable usage reports
stored in BackBlaze S3 under the following location
/Invoices/<YYYY-MM>/Service Invoices/<CLUSTER> <YYYY-MM-DD>.csv

For each allocation in either Active or Active (Needs Renewal)
state of the 3 production clusters (NERC, NERC-OCP and NERC-EDU),
the attribute named "Cumulative Daily Charges for Month" is updated
with the latest total billable cost for that allocation for that given
month.

The attribute stores the total in the following format:
<YYYY-MM-DD>: <TOTAL> USD

If an allocation has the attribute Monthly Allocation Alert set to a
value different than zero, an email is going to be sent to the PI ONCE
after the total billable cost for that allocation has been exceeded.
@knikolla knikolla requested review from QuanMPhm and naved001 December 5, 2025 21:24
Copy link
Contributor

@naved001 naved001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me

Copy link
Contributor

@QuanMPhm QuanMPhm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments

- Rename service_usage variable to storage_usage
- Changed comparison of class type via type(a) is type(b)
- Added a test for class type comparison
- Added try, except for parsing attribute value. Return none as
  fallback.
@knikolla
Copy link
Collaborator Author

knikolla commented Dec 9, 2025

I'm keeping the commits separate for now. Before this should be merged I'll squash.

@knikolla knikolla requested review from QuanMPhm and naved001 December 9, 2025 20:40
@knikolla knikolla merged commit 806916d into nerc-project:main Dec 15, 2025
4 checks passed
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.

Import daily invoices from B2

4 participants