Skip to content

Commit 72fe2b9

Browse files
committed
Fix python 3.14 incompatibility and pandas deprecation warnings
- Adjust to more portable fieldnames selection after deprecation of `__annotations__` in python 3.14 courtesy of @nathanweeks - Update pandas report generation to prevent future deprecation issues Should resolve #106 and #107
1 parent ed59585 commit 72fe2b9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hAMRonization/Interfaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def write(
123123
# to get first result to build csvwriter
124124
try:
125125
first_result = next(self)
126-
fieldnames = first_result.__annotations__.keys()
126+
fieldnames = [f.name for f in dataclasses.fields(type(first_result))]
127127
writer = csv.DictWriter(
128128
out_fh,
129129
delimiter="\t",

hAMRonization/summarize.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def format_interactive_json(combined_records):
4848

4949
grouped_data = combined_records.groupby(
5050
["input_file_name", "config_display_name"]
51-
).apply(lambda x: x.to_json(orient="records"))
51+
).apply(lambda x: x.to_json(orient="records"), include_groups=False)
5252
for (input_file, config), hits in grouped_data.items():
5353
json_hits = json.loads(hits)
5454
if input_file not in data_for_summary:
@@ -733,7 +733,11 @@ def summarize_reports(report_paths, summary_type, output_path=None):
733733

734734
# remove any duplicate entries in the parsed_report
735735
# set can't hash dictionaries unfortunately
736-
combined_reports = pd.concat(combined_report_data, ignore_index=True)
736+
non_empty_reports = [report for report in combined_report_data if not report.empty]
737+
if len(non_empty_reports) > 0:
738+
combined_reports = pd.concat(non_empty_reports, ignore_index=True)
739+
else:
740+
combined_reports = pd.DataFrame(columns=combined_report_data[0].columns)
737741
total_records = len(combined_reports)
738742
combined_reports = combined_reports.drop_duplicates()
739743

0 commit comments

Comments
 (0)