Fixed bug in HDF5DataOpsManager.append_dataset() and added 'creation_date' metadata attribute when instrument (groups) are created.

This commit is contained in:
2024-10-09 16:06:44 +02:00
parent 7c683f96a1
commit fe96134383
2 changed files with 9 additions and 5 deletions

View File

@ -64,6 +64,7 @@ def __transfer_file_dict_to_hdf5(h5file, group_name, file_dict):
# Add dataset's attributes
attributes = dataset.get('attributes', {})
dataset_obj.attrs.update(attributes)
group.attrs['last_update_date'] = utils.created_at().encode('utf-8')
except Exception as inst:
print(inst)
logging.error('Failed to transfer data into HDF5: %s', inst)
@ -178,6 +179,7 @@ def create_hdf5_file_from_filesystem_path(path_to_input_directory: str,
# Group hierarchy is implicitly defined by the forward slashes
if not group_name in h5file.keys():
h5file.create_group(group_name)
h5file[group_name].attrs['creation_date'] = utils.created_at().encode('utf-8')
#h5file[group_name].attrs.create(name='filtered_file_list',data=convert_string_to_bytes(filtered_filename_list))
#h5file[group_name].attrs.create(name='file_list',data=convert_string_to_bytes(filenames_list))
else:

View File

@ -97,14 +97,16 @@ class HDF5DataOpsManager():
# Parse value into HDF5 admissible type
for key in dataset_dict['attributes'].keys():
value = dataset_dict['attributes'][key]
dataset_dict['attributes'][key] = utils.convert_attrdict_to_np_structured_array(value)
#name = dataset_dict['name']
#data = dataset_dict['data']
#dtype = dataset_dict['dtype']
if isinstance(key, dict):
dataset_dict['attributes'][key] = utils.convert_attrdict_to_np_structured_array(value)
if not group_name in self.file_obj:
self.file_obj.create_group(group_name, track_order=True)
self.file_obj[group_name].attrs['creation_date'] = utils.created_at().encode("utf-8")
self.file_obj[group_name].create_dataset(dataset_dict['name'], data=dataset_dict['data'])
self.file_obj[group_name][dataset_dict['name']].attrs.update(dataset_dict['attributes'])
self.file_obj[group_name].attrs['last_update_date'] = utils.created_at().encode("utf-8")
def append_metadata(self, obj_name, annotation_dict):
"""