From 16fc083fe793528540f17de92e234617103e99ba Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Mon, 3 Nov 2025 09:51:00 +0100 Subject: [PATCH 01/11] Attempt to fix OCP last of the month issue --- nise/__main__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nise/__main__.py b/nise/__main__.py index e628a650..c464f4a5 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -656,6 +656,7 @@ def _load_static_report_data(options): start_dates.append(generated_start_date) end_date = attributes.get("end_date", options.get("end_date")) + generated_end_date = today() if end_date and ( end_date != today().date() @@ -664,6 +665,7 @@ def _load_static_report_data(options): and (end_date.date() != today().date() or end_date.hour != 0) ) ): + generated_end_date = calculate_end_date(generated_start_date, end_date) if options.get("provider") == "azure": @@ -680,7 +682,13 @@ def _load_static_report_data(options): options["start_date"] = min(start_dates) latest_date = max(end_dates) last_day_of_month = calendar.monthrange(year=latest_date.year, month=latest_date.month)[1] - options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0) + if not ( + options.get("end_date") and + isinstance(options["end_date"], datetime.datetime) and + options["end_date"].day == last_day_of_month + ): + options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0) + options["static_report_data"] = static_report_data if options.get("provider") == "aws" and aws_tags: @@ -720,6 +728,7 @@ def calculate_start_date(start_date): def calculate_end_date(start_date, end_date): """Return a datetime for the end date.""" + try: if end_date == "last_month": generated_end_date = today().replace(day=1, hour=0, minute=0, second=0) + relativedelta(months=-1) @@ -727,6 +736,8 @@ def calculate_end_date(start_date, end_date): generated_end_date = today().replace(hour=0, minute=0, second=0) elif end_date and isinstance(end_date, datetime.datetime): generated_end_date = end_date + # elif end_date and isinstance(end_date, str) and "T" in end_date: + # generated_end_date = end_date elif end_date and isinstance(end_date, datetime.date): generated_end_date = datetime.datetime(end_date.year, end_date.month, end_date.day) else: @@ -762,6 +773,7 @@ def fix_dates(options, provider_type): def run(provider_type, options): """Run nise.""" static_data_bool = _load_static_report_data(options) + if not options.get("start_date"): raise NiseError("'start_date' is required in static files.") if not static_data_bool: From 5285c95dd6a45f3c3cc47053dcf61b41ff850535 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Fri, 31 Oct 2025 11:40:02 +0100 Subject: [PATCH 02/11] update --- nise/__main__.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/nise/__main__.py b/nise/__main__.py index c464f4a5..89c99f5c 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -654,9 +654,7 @@ def _load_static_report_data(options): start_date = get_start_date(attributes, options) generated_start_date = calculate_start_date(start_date) start_dates.append(generated_start_date) - end_date = attributes.get("end_date", options.get("end_date")) - generated_end_date = today() if end_date and ( end_date != today().date() @@ -665,7 +663,6 @@ def _load_static_report_data(options): and (end_date.date() != today().date() or end_date.hour != 0) ) ): - generated_end_date = calculate_end_date(generated_start_date, end_date) if options.get("provider") == "azure": @@ -682,18 +679,20 @@ def _load_static_report_data(options): options["start_date"] = min(start_dates) latest_date = max(end_dates) last_day_of_month = calendar.monthrange(year=latest_date.year, month=latest_date.month)[1] - if not ( - options.get("end_date") and - isinstance(options["end_date"], datetime.datetime) and - options["end_date"].day == last_day_of_month + if ( + options.get("end_date") + and isinstance(options["end_date"], datetime.datetime) + and options["end_date"].day == last_day_of_month ): + options["end_date"] = latest_date.replace(tzinfo=datetime.UTC) + # options["end_date"] = options["end_date"].replace(tzinfo=datetime.timezone.utc) + else: options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0) options["static_report_data"] = static_report_data if options.get("provider") == "aws" and aws_tags: options["aws_tags"] = aws_tags - return True @@ -728,7 +727,6 @@ def calculate_start_date(start_date): def calculate_end_date(start_date, end_date): """Return a datetime for the end date.""" - try: if end_date == "last_month": generated_end_date = today().replace(day=1, hour=0, minute=0, second=0) + relativedelta(months=-1) @@ -736,8 +734,6 @@ def calculate_end_date(start_date, end_date): generated_end_date = today().replace(hour=0, minute=0, second=0) elif end_date and isinstance(end_date, datetime.datetime): generated_end_date = end_date - # elif end_date and isinstance(end_date, str) and "T" in end_date: - # generated_end_date = end_date elif end_date and isinstance(end_date, datetime.date): generated_end_date = datetime.datetime(end_date.year, end_date.month, end_date.day) else: @@ -773,7 +769,6 @@ def fix_dates(options, provider_type): def run(provider_type, options): """Run nise.""" static_data_bool = _load_static_report_data(options) - if not options.get("start_date"): raise NiseError("'start_date' is required in static files.") if not static_data_bool: From 1e2456b3893c4f38629cebea3421ed1f47c023e2 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Tue, 4 Nov 2025 12:20:30 +0100 Subject: [PATCH 03/11] Update comment --- nise/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nise/__main__.py b/nise/__main__.py index 89c99f5c..f6043117 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -679,13 +679,16 @@ def _load_static_report_data(options): options["start_date"] = min(start_dates) latest_date = max(end_dates) last_day_of_month = calendar.monthrange(year=latest_date.year, month=latest_date.month)[1] + + # Allow partial data generation on the last day of the month (e.g., 8 a.m. - 2 p.m.). + # Otherwise, the start date could be > the month's end date, which would skip data generation + # (options["end_date"] is later used to set the month's end date). if ( options.get("end_date") and isinstance(options["end_date"], datetime.datetime) and options["end_date"].day == last_day_of_month ): options["end_date"] = latest_date.replace(tzinfo=datetime.UTC) - # options["end_date"] = options["end_date"].replace(tzinfo=datetime.timezone.utc) else: options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0) From e035b6d5328f05e8761f6d7e8d28605718887d47 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Tue, 4 Nov 2025 12:26:28 +0100 Subject: [PATCH 04/11] uptick nise --- nise/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nise/__init__.py b/nise/__init__.py index a6591a43..9ccf7541 100644 --- a/nise/__init__.py +++ b/nise/__init__.py @@ -1,5 +1,5 @@ from .helpers import gcp_calculate_persistent_disk_usage_amount from .helpers import gcp_calculate_usage_amount_in_pricing -__version__ = "5.4.1" -VERSION = __version__.split(".") +__version__ = "5.4.2" + From f44457a3083c7fb9f1b37916f8400a80a346a56b Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Tue, 4 Nov 2025 12:38:13 +0100 Subject: [PATCH 05/11] Updae --- nise/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nise/__main__.py b/nise/__main__.py index f6043117..d77abc40 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -686,6 +686,8 @@ def _load_static_report_data(options): if ( options.get("end_date") and isinstance(options["end_date"], datetime.datetime) + and options["end_date"].year == latest_date.year + and options["end_date"].month == latest_date.month and options["end_date"].day == last_day_of_month ): options["end_date"] = latest_date.replace(tzinfo=datetime.UTC) From 8399fccccaea590580818797c79c4e65d7ac480b Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Thu, 6 Nov 2025 09:18:10 +0100 Subject: [PATCH 06/11] omit timezone --- nise/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nise/__main__.py b/nise/__main__.py index d77abc40..4a28cf39 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -690,7 +690,7 @@ def _load_static_report_data(options): and options["end_date"].month == latest_date.month and options["end_date"].day == last_day_of_month ): - options["end_date"] = latest_date.replace(tzinfo=datetime.UTC) + options["end_date"] = latest_date else: options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0) From 1247d4b1c37389df89b90243fe3146f7491fb2f4 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Thu, 6 Nov 2025 09:25:46 +0100 Subject: [PATCH 07/11] improve readability --- nise/__main__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nise/__main__.py b/nise/__main__.py index 4a28cf39..6aab98d2 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -686,9 +686,8 @@ def _load_static_report_data(options): if ( options.get("end_date") and isinstance(options["end_date"], datetime.datetime) - and options["end_date"].year == latest_date.year - and options["end_date"].month == latest_date.month - and options["end_date"].day == last_day_of_month + and (options["end_date"].year, options["end_date"].month, options["end_date"].day) + == (latest_date.year, latest_date.month, last_day_of_month) ): options["end_date"] = latest_date else: From f40244aab69573319eed2d6d74f76b78b77ac197 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Thu, 6 Nov 2025 09:41:12 +0100 Subject: [PATCH 08/11] be extra careful --- nise/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nise/__main__.py b/nise/__main__.py index 6aab98d2..3fdc7b84 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -689,7 +689,7 @@ def _load_static_report_data(options): and (options["end_date"].year, options["end_date"].month, options["end_date"].day) == (latest_date.year, latest_date.month, last_day_of_month) ): - options["end_date"] = latest_date + options["end_date"] = options["end_date"].replace(tzinfo=datetime.UTC) else: options["end_date"] = latest_date.replace(day=last_day_of_month, hour=0, minute=0) From 15017988e5c25c51ec582901e0b9e3287373af9a Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Thu, 6 Nov 2025 09:45:08 +0100 Subject: [PATCH 09/11] let's make gemini finally happy? --- nise/__main__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nise/__main__.py b/nise/__main__.py index 3fdc7b84..62e3eb56 100644 --- a/nise/__main__.py +++ b/nise/__main__.py @@ -686,8 +686,7 @@ def _load_static_report_data(options): if ( options.get("end_date") and isinstance(options["end_date"], datetime.datetime) - and (options["end_date"].year, options["end_date"].month, options["end_date"].day) - == (latest_date.year, latest_date.month, last_day_of_month) + and options["end_date"].date() == datetime.date(latest_date.year, latest_date.month, last_day_of_month) ): options["end_date"] = options["end_date"].replace(tzinfo=datetime.UTC) else: From e65137ba34f82f2d2b9d0f4021d2987916dbeb56 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Tue, 31 Mar 2026 16:25:58 +0200 Subject: [PATCH 10/11] fix version --- nise/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nise/__init__.py b/nise/__init__.py index 9ccf7541..e84b61f3 100644 --- a/nise/__init__.py +++ b/nise/__init__.py @@ -3,3 +3,4 @@ __version__ = "5.4.2" + From c9c16a057a1117ffb863497f2ccd3356bbf2a706 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Thu, 30 Apr 2026 10:22:44 +0200 Subject: [PATCH 11/11] fix lint --- nise/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nise/__init__.py b/nise/__init__.py index e84b61f3..bf170021 100644 --- a/nise/__init__.py +++ b/nise/__init__.py @@ -2,5 +2,3 @@ from .helpers import gcp_calculate_usage_amount_in_pricing __version__ = "5.4.2" - -