Skip to content

Created price.py to incorporate OpenEI API integration. #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

vishwa-11
Copy link

The OpenEI API provides electricity pricing, similar to carbon.py for carbon intensity. I query it once because these rates change only once a year.

@vishwa-11 vishwa-11 marked this pull request as ready for review March 24, 2025 19:40
@vishwa-11
Copy link
Author

When I run lint.sh locally, I see that 89 files are unchanged but 1 file failed to reformat, zeus/monitor/test_carbon.py. I have fully updated black, ruff, and pyright with no changes.

@jaywonchung
Copy link
Member

I fresh-reinstalled Zeus on an empty virtual environment and I see zero reformats or linting issues.

I use miniconda:

conda deactivate && conda remove -n zeus --all -y && conda create -n zeus python=3.9 -y && conda activate zeus && pip install -e '.[dev]'

So I think your setup is broken. The PR shows 32 changed files (mostly formatting) and the CI also says it'll end up reformatting 32 files, which are probably reverting your changes.

@vishwa-11
Copy link
Author

I incorporated your changes and it appears to have worked.

Copy link
Member

@jaywonchung jaywonchung left a comment

Choose a reason for hiding this comment

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

I took a high-level look and it's in good shape! Have you ran this locally and does it work?

If so, please add automated tests using pytest. After tests are added, I'll look at everything again in more detail. Ref: https://github.com/ml-energy/zeus/tree/master/tests/monitor

In general, I would select multiple electricity providers from OpenEI (optimize for coverage of different characteristics of electricity providers), query OpenEI, and put the resulting API response inside the test directory (ilke carbon_history_files/). With those, tests can be run multiple times without having to query the API every time.

raise


def get_time_info():
Copy link
Member

@jaywonchung jaywonchung Mar 28, 2025

Choose a reason for hiding this comment

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

Please make sure all functions (arguments and return values) are typed correctly.

logger = get_logger(__name__)


def get_ip_lat_long() -> tuple[float, float]:
Copy link
Member

Choose a reason for hiding this comment

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

Don't duplicate existing functions. Move it into utils and share.

"""Abstract class for implementing ways to fetch electricity price."""

@abc.abstractmethod
def get_current_electricity_price(self) -> dict:
Copy link
Member

Choose a reason for hiding this comment

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

dict is an insufficient type. What is the type of the key and value?

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.

2 participants