|
12 | 12 |
|
13 | 13 | from openshift_metrics import utils, invoice |
14 | 14 | from 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 | + SU_NAMES, |
| 18 | + RESOURCE_NAMES, |
| 19 | + USE_NERC_RATES, |
| 20 | + RATE_CPU_SU, |
| 21 | + RATE_GPU_V100_SU, |
| 22 | + RATE_GPU_A100SXM4_SU, |
| 23 | + RATE_GPU_A100_SU, |
| 24 | + RATE_GPU_H100_SU, |
| 25 | +) |
16 | 26 |
|
17 | 27 | logging.basicConfig(level=logging.INFO) |
18 | 28 | logger = logging.getLogger(__name__) |
@@ -45,11 +55,9 @@ def parse_timestamp_range(timestamp_range: str) -> Tuple[datetime, datetime]: |
45 | 55 | def get_su_definitions(report_month) -> dict: |
46 | 56 | su_definitions = {} |
47 | 57 | nerc_data = nerc_rates.load_from_url() |
48 | | - su_names = ["GPUV100", "GPUA100", "GPUA100SXM4", "GPUH100", "CPU"] |
49 | | - resource_names = ["vCPUs", "RAM", "GPUs"] |
50 | | - for su_name in su_names: |
| 58 | + for su_name in SU_NAMES: |
51 | 59 | su_definitions.setdefault(f"OpenShift {su_name}", {}) |
52 | | - for resource_name in resource_names: |
| 60 | + for resource_name in RESOURCE_NAMES: |
53 | 61 | su_definitions[f"OpenShift {su_name}"][resource_name] = ( |
54 | 62 | nerc_data.get_value_at( |
55 | 63 | f"{resource_name} in {su_name} SU", report_month, Decimal |
@@ -92,13 +100,14 @@ def main(): |
92 | 100 | parser.add_argument( |
93 | 101 | "--use-nerc-rates", |
94 | 102 | action="store_true", |
| 103 | + default=USE_NERC_RATES, |
95 | 104 | help="Use rates from the nerc-rates repo", |
96 | 105 | ) |
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) |
| 106 | + parser.add_argument("--rate-cpu-su", type=Decimal, default=Decimal(RATE_CPU_SU)) |
| 107 | + parser.add_argument("--rate-gpu-v100-su", type=Decimal, default=Decimal(RATE_GPU_V100_SU)) |
| 108 | + parser.add_argument("--rate-gpu-a100sxm4-su", type=Decimal, default=Decimal(RATE_GPU_A100SXM4_SU)) |
| 109 | + parser.add_argument("--rate-gpu-a100-su", type=Decimal, default=Decimal(RATE_GPU_A100_SU)) |
| 110 | + parser.add_argument("--rate-gpu-h100-su", type=Decimal, default=Decimal(RATE_GPU_H100_SU)) |
102 | 111 |
|
103 | 112 | args = parser.parse_args() |
104 | 113 | files = args.files |
|
0 commit comments