@@ -65,21 +65,9 @@ def _build_summary_expressions(
6565 else :
6666 exprs .append (pl .lit (None , dtype = pl .Int64 ).alias ('unique_donors' ))
6767
68- # Collection info (first non-null values)
69- if 'collection_id' in schema :
70- exprs .append (pl .col ('collection_id' ).filter (pl .col ('collection_id' ).is_not_null ()).first ().alias ('collection_id' ))
71- else :
72- exprs .append (pl .lit (None , dtype = pl .String ).alias ('collection_id' ))
73-
74- if 'publication_title' in schema :
75- exprs .append (pl .col ('publication_title' ).filter (pl .col ('publication_title' ).is_not_null ()).first ().alias ('publication_title' ))
76- else :
77- exprs .append (pl .lit (None , dtype = pl .String ).alias ('publication_title' ))
78-
79- if 'publication_doi' in schema :
80- exprs .append (pl .col ('publication_doi' ).filter (pl .col ('publication_doi' ).is_not_null ()).first ().alias ('publication_doi' ))
81- else :
82- exprs .append (pl .lit (None , dtype = pl .String ).alias ('publication_doi' ))
68+ # Note: Collection info (collection_id, publication_title, publication_doi, etc.)
69+ # will be added via left-join with collections cache in batch mode
70+ # No need to extract them from individual meta files here
8371
8472 # Age statistics
8573 if 'age_years' in schema :
@@ -1193,6 +1181,22 @@ def batch(
11931181 del all_summaries_list
11941182 gc .collect ()
11951183
1184+ # Left-join with collections cache to add publication metadata
1185+ if 'dataset_id' in combined .columns :
1186+ from cell2sentence4longevity .preprocessing .publication_lookup import join_with_collections
1187+ try :
1188+ combined = join_with_collections (combined )
1189+ summary_action .log (
1190+ message_type = "joined_with_collections" ,
1191+ note = "Added publication metadata via left-join with collections cache"
1192+ )
1193+ except Exception as e :
1194+ summary_action .log (
1195+ message_type = "collection_join_warning" ,
1196+ error = str (e ),
1197+ note = "Failed to join with collections, continuing without publication metadata"
1198+ )
1199+
11961200 # Sort by cells_with_age_years (descending), putting datasets with more age data first
11971201 # Fill null values with 0 for sorting
11981202 if 'cells_with_age_years' in combined .columns :
0 commit comments