diff --git a/extra_data/keydata.py b/extra_data/keydata.py index 53fd8ab5..f37c58cf 100644 --- a/extra_data/keydata.py +++ b/extra_data/keydata.py @@ -1,4 +1,5 @@ from typing import List, Optional, Tuple +from warnings import warn import h5py import numpy as np @@ -301,7 +302,7 @@ def attributes(self): if (not attrs) and dset.is_virtual: # Virtual datasets were initially created without these attributes. # Find a source file. Not using source_file_paths as it can give []. - _, filename, _, _ = dset.virtual_sources()[0] + filename = dset.id.get_create_plist().get_virtual_filename(0) # Not using FileAccess: no need for train or source lists. with h5py.File(filename, 'r') as f: attrs = self._find_attributes(f[self.hdf5_data_path]) @@ -610,8 +611,11 @@ def _dim_name(idx): # xarray attributes attrs = {} - if (units := self.units): - attrs['units'] = units + try: + if (units := self.units): + attrs['units'] = units + except Exception as e: + warn(f"Exception fetching units: {e}") if ndarr.dtype.names is not None: # Structured dtype.