11
11
from decimal import Decimal
12
12
import nerc_rates
13
13
14
- from openshift_metrics import utils , invoice
14
+ from openshift_metrics import utils , invoice , config , constants
15
15
from openshift_metrics .metrics_processor import MetricsProcessor
16
16
17
17
logging .basicConfig (level = logging .INFO )
@@ -56,13 +56,13 @@ def get_su_definitions(report_month) -> dict:
56
56
)
57
57
)
58
58
# Some internal SUs that I like to map to when there's insufficient data
59
- su_definitions [invoice .SU_UNKNOWN_GPU ] = {"GPUs" : 1 , "vCPUs" : 8 , "RAM" : 64 * 1024 }
60
- su_definitions [invoice .SU_UNKNOWN_MIG_GPU ] = {
59
+ su_definitions [constants .SU_UNKNOWN_GPU ] = {"GPUs" : 1 , "vCPUs" : 8 , "RAM" : 64 * 1024 }
60
+ su_definitions [constants .SU_UNKNOWN_MIG_GPU ] = {
61
61
"GPUs" : 1 ,
62
62
"vCPUs" : 8 ,
63
63
"RAM" : 64 * 1024 ,
64
64
}
65
- su_definitions [invoice .SU_UNKNOWN ] = {"GPUs" : 0 , "vCPUs" : 1 , "RAM" : 1024 }
65
+ su_definitions [constants .SU_UNKNOWN ] = {"GPUs" : 0 , "vCPUs" : 1 , "RAM" : 1024 }
66
66
return su_definitions
67
67
68
68
@@ -73,16 +73,23 @@ def main():
73
73
parser .add_argument (
74
74
"--invoice-file" ,
75
75
help = "Name of the invoice file. Defaults to NERC OpenShift <report_month>.csv" ,
76
+ default = config .INVOICE_FILE ,
76
77
)
77
78
parser .add_argument (
78
79
"--pod-report-file" ,
79
80
help = "Name of the pod report file. Defaults to Pod NERC OpenShift <report_month>.csv" ,
81
+ default = config .POD_REPORT_FILE ,
80
82
)
81
83
parser .add_argument (
82
84
"--class-invoice-file" ,
83
85
help = "Name of the class report file. Defaults to NERC OpenShift Class <report_month>.csv" ,
86
+ default = config .CLASS_INVOICE_FILE ,
87
+ )
88
+ parser .add_argument (
89
+ "--upload-to-s3" ,
90
+ action = "store_true" ,
91
+ default = config .UPLOAD_TO_S3 ,
84
92
)
85
- parser .add_argument ("--upload-to-s3" , action = "store_true" )
86
93
parser .add_argument (
87
94
"--ignore-hours" ,
88
95
type = parse_timestamp_range ,
@@ -93,12 +100,13 @@ def main():
93
100
"--use-nerc-rates" ,
94
101
action = "store_true" ,
95
102
help = "Use rates from the nerc-rates repo" ,
103
+ default = config .USE_NERC_RATES ,
96
104
)
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 )
105
+ parser .add_argument ("--rate-cpu-su" , type = Decimal , default = config . RATE_CPU_SU )
106
+ parser .add_argument ("--rate-gpu-v100-su" , type = Decimal , default = config . RATE_GPU_V100_SU )
107
+ parser .add_argument ("--rate-gpu-a100sxm4-su" , type = Decimal , default = config . RATE_GPU_A100SXM4_SU )
108
+ parser .add_argument ("--rate-gpu-a100-su" , type = Decimal , default = config . RATE_GPU_A100_SU )
109
+ parser .add_argument ("--rate-gpu-h100-su" , type = Decimal , default = config . RATE_GPU_H100_SU )
102
110
103
111
args = parser .parse_args ()
104
112
files = args .files
@@ -208,7 +216,7 @@ def main():
208
216
rates = rates ,
209
217
su_definitions = su_definitions ,
210
218
cluster_name = cluster_name ,
211
- namespaces_with_classes = [ "rhods-notebooks" ] ,
219
+ namespaces_with_classes = config . NAMESPACES_WITH_CLASSES ,
212
220
ignore_hours = ignore_hours ,
213
221
)
214
222
utils .write_metrics_by_pod (
@@ -219,7 +227,7 @@ def main():
219
227
)
220
228
221
229
if args .upload_to_s3 :
222
- bucket_name = os . environ . get ( " S3_INVOICE_BUCKET" , "nerc-invoicing" )
230
+ bucket_name = config . S3_INVOICE_BUCKET
223
231
primary_location = (
224
232
f"Invoices/{ report_month } /"
225
233
f"Service Invoices/{ cluster_name } { report_month } .csv"
0 commit comments