1212
1313from openshift_metrics import utils , invoice
1414from openshift_metrics .metrics_processor import MetricsProcessor
15- from openshift_metrics .config import S3_INVOICE_BUCKET
15+ from openshift_metrics .config import (
16+ S3_INVOICE_BUCKET ,
17+ USE_NERC_RATES ,
18+ RATE_CPU_SU ,
19+ RATE_GPU_V100_SU ,
20+ RATE_GPU_A100SXM4_SU ,
21+ RATE_GPU_A100_SU ,
22+ RATE_GPU_H100_SU ,
23+ )
1624
1725logging .basicConfig (level = logging .INFO )
1826logger = logging .getLogger (__name__ )
@@ -89,16 +97,6 @@ def main():
8997 nargs = "*" ,
9098 help = "List of timestamp ranges in UTC to ignore in the format 'YYYY-MM-DDTHH:MM:SS,YYYY-MM-DDTHH:MM:SS'" ,
9199 )
92- parser .add_argument (
93- "--use-nerc-rates" ,
94- action = "store_true" ,
95- help = "Use rates from the nerc-rates repo" ,
96- )
97- parser .add_argument ("--rate-cpu-su" , type = Decimal )
98- parser .add_argument ("--rate-gpu-v100-su" , type = Decimal )
99- parser .add_argument ("--rate-gpu-a100sxm4-su" , type = Decimal )
100- parser .add_argument ("--rate-gpu-a100-su" , type = Decimal )
101- parser .add_argument ("--rate-gpu-h100-su" , type = Decimal )
102100
103101 args = parser .parse_args ()
104102 files = args .files
@@ -147,7 +145,12 @@ def main():
147145
148146 report_month = datetime .strftime (report_start_date , "%Y-%m" )
149147
150- if args .use_nerc_rates :
148+ if USE_NERC_RATES is None :
149+ raise ValueError (
150+ "USE_NERC_RATES environment variable must be set to 'true' or 'false'"
151+ )
152+
153+ if USE_NERC_RATES :
151154 logger .info ("Using nerc rates." )
152155 nerc_data = nerc_rates .load_from_url ()
153156 rates = invoice .Rates (
@@ -160,12 +163,23 @@ def main():
160163 gpu_h100 = nerc_data .get_value_at ("GPUH100 SU Rate" , report_month , Decimal ),
161164 )
162165 else :
166+ if RATE_CPU_SU is None :
167+ raise ValueError ("RATE_CPU_SU environment variable must be set" )
168+ if RATE_GPU_V100_SU is None :
169+ raise ValueError ("RATE_GPU_V100_SU environment variable must be set" )
170+ if RATE_GPU_A100SXM4_SU is None :
171+ raise ValueError ("RATE_GPU_A100SXM4_SU environment variable must be set" )
172+ if RATE_GPU_A100_SU is None :
173+ raise ValueError ("RATE_GPU_A100_SU environment variable must be set" )
174+ if RATE_GPU_H100_SU is None :
175+ raise ValueError ("RATE_GPU_H100_SU environment variable must be set" )
176+
163177 rates = invoice .Rates (
164- cpu = Decimal (args . rate_cpu_su ),
165- gpu_a100 = Decimal (args . rate_gpu_a100_su ),
166- gpu_a100sxm4 = Decimal (args . rate_gpu_a100sxm4_su ),
167- gpu_v100 = Decimal (args . rate_gpu_v100_su ),
168- gpu_h100 = Decimal (args . rate_gpu_h100_su ),
178+ cpu = Decimal (RATE_CPU_SU ),
179+ gpu_a100 = Decimal (RATE_GPU_A100_SU ),
180+ gpu_a100sxm4 = Decimal (RATE_GPU_A100SXM4_SU ),
181+ gpu_v100 = Decimal (RATE_GPU_V100_SU ),
182+ gpu_h100 = Decimal (RATE_GPU_H100_SU ),
169183 )
170184
171185 if args .invoice_file :
0 commit comments