Skip to content

Commit 190737d

Browse files
committed
fix: cache dataset before dropping columns to prevent validation errors
1 parent bf9810b commit 190737d

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v2.0.3] - 2025-02-05
9+
### Fixed
10+
- Data sets are cached before dropping ignored columns so that analysis can complete as expected
11+
812
## [v2.0.2] - 2025-02-02
913
### Added
1014
- Support for tracking `softwareTitleId` from Jamf API Response

src/patcher/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__title__ = "patcher"
2-
__version__ = "2.0.2"
2+
__version__ = "2.0.3"

src/patcher/utils/data_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def export_to_excel(self, patch_titles: List[PatchTitle], output_dir: Union[str,
190190

191191
current_date = datetime.now().strftime("%m-%d-%y")
192192
df = self._create_dataframe(patch_titles)
193+
self._cache_data(df)
193194
df = df.drop(
194195
columns=[col.replace("_", " ").title() for col in DataManager._IGNORED], errors="ignore"
195196
) # Drop excluded columns
@@ -199,7 +200,6 @@ def export_to_excel(self, patch_titles: List[PatchTitle], output_dir: Union[str,
199200
excel_path = os.path.join(output_dir, f"patch-report-{current_date}.xlsx")
200201
df.to_excel(excel_path, index=False)
201202
self.log.info(f"Excel report created successfully to {excel_path}.")
202-
self._cache_data(df)
203203
self.latest_excel_file = excel_path
204204
return excel_path
205205
except (OSError, PermissionError) as e:

tests/test_data_manager.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def test_export_to_excel_success(sample_patch_reports, temp_output_dir):
3737
args, _ = mock_cache_data.call_args
3838
cached_df = args[0]
3939

40-
assert_frame_equal(df, cached_df)
40+
# Account for cached dataframe having all columns
41+
common_columns = df.columns.intersection(cached_df.columns)
42+
assert_frame_equal(df[common_columns], cached_df[common_columns], check_like=True)
4143

4244

4345
def test_export_to_excel_dataframe_creation_error(temp_output_dir):

0 commit comments

Comments
 (0)