Skip to content

Commit 18ba975

Browse files
committedFeb 26, 2025
Merge branch 'main' into uv
2 parents c88149f + 5aea935 commit 18ba975

File tree

8 files changed

+240
-142
lines changed

8 files changed

+240
-142
lines changed
 

‎nise/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "4.7.0"
1+
__version__ = "4.7.2"
22

33

44
VERSION = __version__.split(".")

‎nise/__main__.py

+8
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ def add_gcp_parser_args(parser):
242242
dest="daily_report",
243243
help="GCP daily report activation",
244244
)
245+
246+
parser.add_argument(
247+
"--gcp-daily-flow",
248+
action="store_true",
249+
required=False,
250+
dest="gcp_daily_flow",
251+
help="additional GCP day to day ingest",
252+
)
245253
parser.add_argument(
246254
"-etag", "--gcp-etag", metavar="GCP_ETAG", dest="gcp_etag", required=False, help="The etag in the filename"
247255
)

‎nise/generators/aws/ec2_generator.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ class EC2Generator(AWSGenerator):
2626

2727
INSTANCE_TYPES = (
2828
# NOTE: Each tuple represents
29-
# (instance type, physical_cores, vCPUs, memory, storage, family, cost, rate, savings, description)
29+
# (instance type,
30+
# physical_cores,
31+
# vCPUs,
32+
# memory,
33+
# storage,
34+
# family,
35+
# cost,
36+
# rate,
37+
# Reserved_instances,
38+
# savings,
39+
# description)
3040
(
3141
"m5.large",
3242
"1",
@@ -39,6 +49,7 @@ class EC2Generator(AWSGenerator):
3949
"0.045",
4050
1,
4151
False,
52+
False,
4253
"${cost} per On Demand Linux {inst_type} Instance Hour",
4354
),
4455
(
@@ -53,6 +64,7 @@ class EC2Generator(AWSGenerator):
5364
"0.17",
5465
1,
5566
False,
67+
False,
5668
"${cost} per On Demand Linux {inst_type} Instance Hour",
5769
),
5870
(
@@ -67,6 +79,7 @@ class EC2Generator(AWSGenerator):
6779
"0.099",
6880
1,
6981
False,
82+
False,
7083
"${cost} per On Demand Linux {inst_type} Instance Hour",
7184
),
7285
(
@@ -81,6 +94,7 @@ class EC2Generator(AWSGenerator):
8194
"0.067",
8295
1,
8396
False,
97+
False,
8498
"${cost} per On Demand Linux {inst_type} Instance Hour",
8599
),
86100
)
@@ -125,6 +139,7 @@ def __init__(self, start_date, end_date, currency, payer_account, usage_accounts
125139
instance_type.get("rate"),
126140
instance_type.get("saving"),
127141
instance_type.get("amount", "1"),
142+
instance_type.get("reserved_instance", False),
128143
instance_type.get("negation", False),
129144
"${cost} per On Demand Linux {inst_type} Instance Hour",
130145
)
@@ -142,6 +157,7 @@ def _update_data(self, row, start, end, **kwargs):
142157
rate,
143158
saving,
144159
amount,
160+
reserved_instance,
145161
negation,
146162
description,
147163
) = self._instance_type
@@ -204,6 +220,18 @@ def _update_data(self, row, start, end, **kwargs):
204220
# Overwrite lineItem/LineItemType for items with applied Savings plan
205221
if saving is not None:
206222
row["lineItem/LineItemType"] = "SavingsPlanCoveredUsage"
223+
# Overwrite lineitem/LineItemType for RI's discount usage
224+
if reserved_instance:
225+
row["lineItem/LineItemType"] = "DiscountedUsage"
226+
row["lineItem/UnblendedCost"] = 0
227+
row["lineItem/UnblendedRate"] = 0
228+
row["lineItem/BlendedCost"] = 0
229+
row["lineItem/BlendedRate"] = 0
230+
row["lineItem/LineItemDescription"] = f"{inst_type} reserved instance applied"
231+
row["pricing/publicOnDemandCost"] = "convertible"
232+
row["pricing/publicOnDemandRate"] = "No Upfront"
233+
row["savingsPlan/SavingsPlanEffectiveCost"] = None
234+
row["savingsPlan/SavingsPlanRate"] = None
207235

208236
if negation:
209237
row["lineItem/LineItemType"] = "SavingsPlanNegation"

‎nise/report.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ def _gcp_bigquery_process(
12071207
start_date, end_date, currency, projects, generators, options, gcp_bucket_name, gcp_dataset_name, gcp_table_name
12081208
):
12091209
resource_level = options.get("gcp_resource_level", False)
1210+
gcp_daily_flow = options.get("gcp_daily_flow", False)
12101211
data = []
12111212
for project in projects:
12121213
num_gens = len(generators)
@@ -1240,7 +1241,14 @@ def _gcp_bigquery_process(
12401241
gcp_table_name = f"gcp_billing_export_resource_{etag}"
12411242
else:
12421243
gcp_table_name = f"gcp_billing_export_{etag}"
1243-
gcp_bucket_to_dataset(gcp_bucket_name, output_file_name, gcp_dataset_name, gcp_table_name, resource_level)
1244+
gcp_bucket_to_dataset(
1245+
gcp_bucket_name,
1246+
output_file_name,
1247+
gcp_dataset_name,
1248+
gcp_table_name,
1249+
resource_level,
1250+
gcp_daily_flow=gcp_daily_flow,
1251+
)
12441252

12451253
return monthly_files
12461254

0 commit comments

Comments
 (0)