11import argparse
2+ import logging
23import os
34import os .path as op
45from collections import defaultdict
2526from .tiledb_storage import create_empty_scalar_matrix_array as tdb_create_empty
2627from .tiledb_storage import write_rows_in_column_stripes as tdb_write_stripes
2728
29+ logger = logging .getLogger (__name__ )
30+
2831
2932def _load_cohort_voxels (cohort_df , group_mask_matrix , relative_root , s3_workers ):
3033 """Load all voxel rows from the cohort, optionally in parallel.
@@ -137,7 +140,7 @@ def _decode_names(arr):
137140 s = s .rstrip ('\x00 ' ).strip ()
138141 out .append (s )
139142 return out
140- except Exception :
143+ except ( AttributeError , OSError , TypeError , ValueError ) :
141144 return None
142145
143146 results_names = None
@@ -146,7 +149,7 @@ def _decode_names(arr):
146149 names_attr = results_matrix .attrs .get ('colnames' , None )
147150 if names_attr is not None :
148151 results_names = _decode_names (names_attr )
149- except Exception :
152+ except ( OSError , RuntimeError , TypeError , ValueError ) :
150153 results_names = None
151154
152155 # 2) Fallback to dataset-based column names (new format)
@@ -162,13 +165,14 @@ def _decode_names(arr):
162165 results_names = _decode_names (names_ds )
163166 if results_names :
164167 break
165- except Exception :
168+ except (KeyError , OSError , RuntimeError , TypeError , ValueError ):
169+ logger .debug ('Could not read column names from %s' , p , exc_info = True )
166170 continue
167171
168172 # 3) Final fallback to generated names
169173 if not results_names :
170174 print ("Unable to read column names, using 'componentNNN' instead" )
171- results_names = ['component%03d' % ( n + 1 ) for n in range (results_matrix .shape [0 ])]
175+ results_names = [f 'component{ n + 1 :03d } ' for n in range (results_matrix .shape [0 ])]
172176
173177 # # Make output directory if it does not exist # has been done in h5_to_volumes_wrapper()
174178 # if op.isdir(volume_output_dir) == False:
0 commit comments