HDFGroup / HDFGroup/hdf5

issue with VDS and self referencing VirtualSource

Open
#4,080 2 comments 0 reactions 1 assignee Claimed by @fortnern View on GitHub
Component - C Library
Dominant language
C
Stars
988
Forks
355
Avg merge
4d 2h
Merged PRs (30d)
12

Description

**Describe the bug**
It looks like there is some consistency or bug regarding 'self-referencing' VirtualSource (so if the source dataset is contained in the file containing also the virtual dataset - VDS)

**Expected behavior**
If a "file_name" contains a dataset referenced in VDS contained in the same file then if the virtual source path is "." or ".{file_name}" should have the same behavior

**Platform (please complete the following information)**
tested (only) with:
- HDF5version: 1.14.3
- OS and version: Ubuntu 20.04.6 LTS
- default HDF5 version provided by h5py wheel

**Additional context**
Here is some code to reproduce (using h5py):
first assertion works as expected, second one failed (using '.{file_path}' instead of '.')
```python
import numpy
import h5py

print("** Write test datasets")
data = numpy.linspace(1, 10, 100, dtype=numpy.float32).reshape((10, 10))

with h5py.File("test.h5", mode="w") as h5f:
h5f["/data"] = data
vsource_1 = h5py.VirtualSource(".", "/data", shape=(10, 10))
layout = h5py.VirtualLayout(shape=(10, 10), dtype="f4")
layout[:] = vsource_1
h5f.create_virtual_dataset("/vds_ok", layout, fillvalue=-5)

vsource_1 = h5py.VirtualSource("./test.h5", "/data", shape=(10, 10))
layout = h5py.VirtualLayout(shape=(10, 10), dtype="f4")
layout[:] = vsource_1
h5f.create_virtual_dataset("/vds_failed", layout, fillvalue=-5)

print("** Read with locking")
with h5py.File("test.h5", mode="r", locking=True) as h5f:
vds_data = h5f["/vds_ok"][()]
assert numpy.array_equal(data, vds_data)
vds_data = h5f["/vds_failed"][()]
assert numpy.array_equal(data, vds_data)

print("** Read without locking")
with h5py.File("test.h5", mode="r", locking=False) as h5f:
print(" - VDS OK")
vds_data = h5f["/vds_ok"][()]
assert numpy.array_equal(data, vds_data)
print(" - vds_failed")
vds_data = h5f["/vds_failed"][()]
assert numpy.array_equal(data, vds_data)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.