Skip to content

Integrate nerc-rates for dynamic outage information loading#261

Merged
knikolla merged 1 commit intonerc-project:mainfrom
jimmysway:fix/256-pulling-outages
Nov 6, 2025
Merged

Integrate nerc-rates for dynamic outage information loading#261
knikolla merged 1 commit intonerc-project:mainfrom
jimmysway:fix/256-pulling-outages

Conversation

@jimmysway
Copy link
Contributor

  • Add load_outages_from_nerc_rates() to fetch outages from nerc-rates repository
  • Update calculate_storage_gb_hours to auto-load outages for "stack" and "ocp-prod" services
  • Maintain backwards compatibility with --excluded-time-ranges flag
  • Add test coverage for nerc-rates integration

Closes #256

@jimmysway jimmysway force-pushed the fix/256-pulling-outages branch from e19501e to ef716a1 Compare October 31, 2025 19:16
@jimmysway
Copy link
Contributor Author

Based on previous discussions I think the service mapping was something like

OpenStack resources → stack
OpenShift resources → ocp-prod (or should it be both ocp-prod and ocp-test?)

Is there also other services that need to be included?

@knikolla
Copy link
Collaborator

Based on previous discussions I think the service mapping was something like

OpenStack resources → stack OpenShift resources → ocp-prod (or should it be both ocp-prod and ocp-test?)

Is there also other services that need to be included?

stack only applies to the OpenStack ColdFront Resource with name NERC
ocp-prod only applies to the OpenShift ColdFront Resource with name NERC-OCP
academic only applies to the OpenShift ColdFront Resource with name NERC-OCP-EDU

The rest aren't in ColdFront at the moment.

Please create a map as a global variable in the calculate_storage_gb_hours.py file to do the translation so you can make the appropriate call to nerc-rates.

@knikolla
Copy link
Collaborator

Created a related issue as a second step, after this PR is merged, to remove the PR and have the mapping be stored as attributes in the Resources themselves. For now, a dict map in calculate_storage_hours is fine.

#262

Copy link
Collaborator

@knikolla knikolla left a comment

Choose a reason for hiding this comment

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

Review in prior comments. Please implement a dictionary map to fetch the appropriate outage based on cluster name map.

@jimmysway jimmysway force-pushed the fix/256-pulling-outages branch 2 times, most recently from cf42501 to f687493 Compare October 31, 2025 20:28
@jimmysway jimmysway requested a review from knikolla October 31, 2025 20:29
@knikolla
Copy link
Collaborator

knikolla commented Nov 3, 2025

@jimmysway actually, seeing the asymmetry between providing CLI args (apply to all resources) and loaded from nerc-rates (apply to the specific resources as listed in the specific outage,) I'm okay with dropping the possibility to provide excluded intervals from the CLI.

@jimmysway
Copy link
Contributor Author

@jimmysway actually, seeing the asymmetry between providing CLI args (apply to all resources) and loaded from nerc-rates (apply to the specific resources as listed in the specific outage,) I'm okay with dropping the possibility to provide excluded intervals from the CLI.

@knikolla Are there any downstream consequences for something like this that I should be aware of?

@knikolla
Copy link
Collaborator

knikolla commented Nov 3, 2025

@jimmysway actually, seeing the asymmetry between providing CLI args (apply to all resources) and loaded from nerc-rates (apply to the specific resources as listed in the specific outage,) I'm okay with dropping the possibility to provide excluded intervals from the CLI.

@knikolla Are there any downstream consequences for something like this that I should be aware of?

No, the command is either executed manually through a terminal, or through a cronjob that doesn't provide any excluded intervals when executing the command.

EDIT TO ADD: Furthermore the command is very specific to how we bill, so I'm not worried about potentially breaking someone who might be using it.

@jimmysway jimmysway force-pushed the fix/256-pulling-outages branch from 2bc9771 to 634e3f2 Compare November 3, 2025 19:58
Copy link
Collaborator

@knikolla knikolla left a comment

Choose a reason for hiding this comment

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

I don't think the current testing is sufficient. You haven't added any new test while adding functionality.

Please add a test that mocks nerc-rates and verifies that get_outages_during is called with the appropriate parameters. You can patch the mapping dictionary to make things easier for resources that don't exist.

You can also test that the mocked output of get_outages_during is correctly used.

@jimmysway jimmysway force-pushed the fix/256-pulling-outages branch from d307f6b to 01d2815 Compare November 4, 2025 20:30
Copy link
Collaborator

@knikolla knikolla left a comment

Choose a reason for hiding this comment

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

One final comment, otherwise looks ready to go. Good work.

@knikolla knikolla requested a review from QuanMPhm November 5, 2025 19:50
@knikolla
Copy link
Collaborator

knikolla commented Nov 5, 2025

@QuanMPhm were your comments resolved?

@QuanMPhm
Copy link
Contributor

QuanMPhm commented Nov 6, 2025

@knikolla I've resolved my comments and approved

- Add load_outages_from_nerc_rates() to fetch outages from nerc-rates repository
- Update calculate_storage_gb_hours to use mapping dict that matches the ColdFront Resource name to the nerc-rates service name
- Added functools cache so outages load once per run
- Added testing for nerc-rates integration.Mocks cached nerc-rates data directly

Closes nerc-project#256
@jimmysway jimmysway force-pushed the fix/256-pulling-outages branch from 85d324b to 17754fa Compare November 6, 2025 15:37
@jimmysway
Copy link
Contributor Author

@knikolla @QuanMPhm I've just rebased

@knikolla knikolla merged commit 198ebe3 into nerc-project:main Nov 6, 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.

Implement support for pulling outages from nerc-rates

3 participants