Skip to content

Attribute can not access a dataset without a parent group

H5fileAttribute requires that a dataset must have a parent group. This is not required by h5py:

import h5py


with h5py.File('/tmp/foo.h5', 'w') as f:
    f.create_dataset('bar', data=1.23)

with h5py.File('/tmp/foo.h5', 'r') as f:
    print(f['bar'][()])

import taurus
myattr = taurus.Attribute('h5file:/tmp/foo.h5::baz')
print(myattr.read().rvalue)

This produces:

1.23
MainThread     WARNING  2021-04-16 17:17:58,462 TaurusRootLogger: epics scheme not available: ModuleNotFoundError("No module named 'epics'")
Traceback (most recent call last):
  File "/homelocal/zreszela/.config/JetBrains/PyCharm2020.3/scratches/scratch_11.py", line 12, in <module>
    myattr = taurus.Attribute('h5file:/tmp/foo.h5::baz')
  File "/homelocal/zreszela/workspace/taurus/lib/taurus/core/taurushelper.py", line 316, in Attribute
    return Factory(scheme=getSchemeFromName(dev_or_attr_name)).getAttribute(dev_or_attr_name)
  File "/homelocal/zreszela/workspace/taurus/lib/taurus/core/taurusfactory.py", line 212, in getAttribute
    fullname, _, _ = v.getNames(name)
  File "/homelocal/zreszela/workspace/h5file-scheme/h5file/h5filevalidator.py", line 103, in getNames
    lastelem = groups.get('attrname').rsplit('/', 1)[1]
IndexError: list index out of range

Process finished with exit code 1