mirror of https://github.com/m-labs/artiq.git
master: Print offending key on HDF5 dataset type error
This helps debugging the cause of TypeErrors arising from types not handled by the HDF5 serializer, as the backtrace doesn't otherwise include any useful information.
This commit is contained in:
parent
56b2e0c262
commit
01c3000ef3
|
@ -173,8 +173,18 @@ class DatasetManager:
|
|||
def write_hdf5(self, f):
|
||||
datasets_group = f.create_group("datasets")
|
||||
for k, v in self.local.items():
|
||||
datasets_group[k] = v
|
||||
_write(datasets_group, k, v)
|
||||
|
||||
archive_group = f.create_group("archive")
|
||||
for k, v in self.archive.items():
|
||||
archive_group[k] = v
|
||||
_write(archive_group, k, v)
|
||||
|
||||
|
||||
def _write(group, k, v):
|
||||
# Add context to exception message when the user writes a dataset that is
|
||||
# not representable in HDF5.
|
||||
try:
|
||||
group[k] = v
|
||||
except TypeError as e:
|
||||
raise TypeError("Error writing dataset '{}' of type '{}': {}".format(
|
||||
k, type(v), e))
|
||||
|
|
Loading…
Reference in New Issue