Skip to content

Conversation

@jimmysway
Copy link
Contributor

Part 2 of #144

@jimmysway jimmysway force-pushed the fix/144-consolidating-config branch from 39e759b to b1b589e Compare October 15, 2025 14:21
RATE_GPU_H100_SU = os.getenv("RATE_GPU_H100_SU", "6.04")

# Legacy rate (for backward compatibility)
GPU_A100_RATE = os.getenv("GPU_A100_RATE", "1.803")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this constant used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I couldn't find it. A text search across your PR doesn't show any reference to GPU_A100_RATE

Comment on lines +20 to +21
SU_NAMES = ["GPUV100", "GPUA100", "GPUA100SXM4", "GPUH100", "CPU"]
RESOURCE_NAMES = ["vCPUs", "RAM", "GPUs"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are not configurations for the script. I would suggest leave them where they were in get_su_definitions for now. As mentioned by @naved001, we could move this information to a file at some point in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, exactly. Let's not touch these now for now. The whole SU types and their names will require some more thought.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jimmysway This comment is not addressed. These constants are not accessed anywhere in your PR

Comment on lines 106 to 118
parser.add_argument("--rate-cpu-su", type=Decimal, default=Decimal(RATE_CPU_SU))
parser.add_argument(
"--rate-gpu-v100-su", type=Decimal, default=Decimal(RATE_GPU_V100_SU)
)
parser.add_argument(
"--rate-gpu-a100sxm4-su", type=Decimal, default=Decimal(RATE_GPU_A100SXM4_SU)
)
parser.add_argument(
"--rate-gpu-a100-su", type=Decimal, default=Decimal(RATE_GPU_A100_SU)
)
parser.add_argument(
"--rate-gpu-h100-su", type=Decimal, default=Decimal(RATE_GPU_H100_SU)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the point of this PR is to have configuration done through env vars, I would suggest removing these parser arguments since they are now redundant.

Comment on lines 27 to 31
RATE_CPU_SU = os.getenv("RATE_CPU_SU", "0.013")
RATE_GPU_V100_SU = os.getenv("RATE_GPU_V100_SU", "1.214")
RATE_GPU_A100SXM4_SU = os.getenv("RATE_GPU_A100SXM4_SU", "2.078")
RATE_GPU_A100_SU = os.getenv("RATE_GPU_A100_SU", "1.803")
RATE_GPU_H100_SU = os.getenv("RATE_GPU_H100_SU", "6.04")
Copy link
Collaborator

Choose a reason for hiding this comment

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

@naved001 Do we still want keep the old behavior of having the rates None if not provided?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, good point. If someone were to forget setting I'd rather the code fail than use some default values for rates.

@naved001
Copy link
Collaborator

@jimmysway have you had a chance to address the comments in this PR?

…and rewriting code references.

Removed CLI arguments for setting rates
@jimmysway jimmysway force-pushed the fix/144-consolidating-config branch from b1b589e to 2967310 Compare November 11, 2025 15:25
@jimmysway
Copy link
Contributor Author

jimmysway commented Nov 11, 2025

Sorry I had them sitting in my local branch. I just merged with upstream

@QuanMPhm
Copy link
Collaborator

@jimmysway There are merge conflicts in the PR

@jimmysway jimmysway requested a review from QuanMPhm December 15, 2025 19:26
Copy link
Collaborator

@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.

A few previous comments were not addressed. I've also added a few new ones

Comment on lines +20 to +21
SU_NAMES = ["GPUV100", "GPUA100", "GPUA100SXM4", "GPUH100", "CPU"]
RESOURCE_NAMES = ["vCPUs", "RAM", "GPUs"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jimmysway This comment is not addressed. These constants are not accessed anywhere in your PR

Comment on lines +24 to +25
USE_NERC_RATES_ENV = os.getenv("USE_NERC_RATES")
USE_NERC_RATES = USE_NERC_RATES_ENV.lower() == "true" if USE_NERC_RATES_ENV else None
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest just having USE_NERC_RATES and removing USE_NERC_RATES_ENV. If the user does not set USE_NERC_RATES, that should be equivalent to setting the env var to false:

Suggested change
USE_NERC_RATES_ENV = os.getenv("USE_NERC_RATES")
USE_NERC_RATES = USE_NERC_RATES_ENV.lower() == "true" if USE_NERC_RATES_ENV else None
USE_NERC_RATES = os.getenv("USE_NERC_RATES", "false").lower() == "true"

Do you have a specific reason for why these two env vars needs to be defined seperately?

RATE_GPU_H100_SU = os.getenv("RATE_GPU_H100_SU")

# Legacy rate (for backward compatibility)
GPU_A100_RATE = os.getenv("GPU_A100_RATE")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't see where this constant is used

Comment on lines +167 to +170
if USE_NERC_RATES is None:
raise ValueError(
"USE_NERC_RATES environment variable must be set to 'true' or 'false'"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Following from my comment above, this if clause should also be removed. I think USE_NERC_RATES not being set should be interpreted as False

Comment on lines +185 to +188
report_start_date_dt = datetime.strptime(report_start_date, "%Y-%m-%d")
report_end_date_dt = datetime.strptime(report_end_date, "%Y-%m-%d")
ignore_hours = outage_data.get_outages_during(
report_start_date, report_end_date, cluster_name
report_start_date_dt, report_end_date_dt, cluster_name
Copy link
Collaborator

Choose a reason for hiding this comment

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

The current upstream code runs fine with report_start_date and report_end_date. Is there a reason you're converting them to datetime objects here?

Comment on lines +191 to +201
if RATE_CPU_SU is None:
raise ValueError("RATE_CPU_SU environment variable must be set")
if RATE_GPU_V100_SU is None:
raise ValueError("RATE_GPU_V100_SU environment variable must be set")
if RATE_GPU_A100SXM4_SU is None:
raise ValueError("RATE_GPU_A100SXM4_SU environment variable must be set")
if RATE_GPU_A100_SU is None:
raise ValueError("RATE_GPU_A100_SU environment variable must be set")
if RATE_GPU_H100_SU is None:
raise ValueError("RATE_GPU_H100_SU environment variable must be set")

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the upstream version of the code, an error is already raised by the Rates dataclass if the SU rates are None. I suppose these a bit more informative, but I would argue they are not entirely necessary and leads to more maintenance burden down the line.

Comment on lines +230 to +233
report_start_date_dt = datetime.strptime(report_start_date, "%Y-%m-%d").replace(
tzinfo=UTC
)
report_end_date_dt = datetime.strptime(report_end_date, "%Y-%m-%d").replace(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want to indicate that report_start_date and report_end_date are datetime objects, I would suggest using type annotation instead, which I think would be simpler to interpret than having to rename references and assignements.

Suggested change
report_start_date_dt = datetime.strptime(report_start_date, "%Y-%m-%d").replace(
tzinfo=UTC
)
report_end_date_dt = datetime.strptime(report_end_date, "%Y-%m-%d").replace(
report_start_date : datetime = datetime.strptime(report_start_date, "%Y-%m-%d").replace(
tzinfo=UTC
)
report_end_date : datetime = datetime.strptime(report_end_date, "%Y-%m-%d").replace(
tzinfo=UTC
)

Is there another reason why you renamed these variables?

Comment on lines +237 to +239
if report_start_date_dt.month != report_end_date_dt.month:
logger.warning("The report spans multiple months")
report_month += " to " + datetime.strftime(report_end_date_dt, "%Y-%m")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This if clause is no longer needed. It will cause an error with the call to nerc-rates in get_su_definitions

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.

3 participants