Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with #206 #208

Closed
ArvidJB opened this issue Sep 30, 2021 · 2 comments
Closed

Bug with #206 #208

ArvidJB opened this issue Sep 30, 2021 · 2 comments

Comments

@ArvidJB
Copy link
Collaborator

ArvidJB commented Sep 30, 2021

There seems to be a problem with the changes introduced in #206:

In [8]: with h5py.File('/tmp/foo.h5', 'w') as f:
   ...:     vf = VersionedHDF5File(f)
   ...:     with vf.stage_version('0') as sv:
   ...:         sv.create_dataset('bar', data=np.arange(10))
   ...:

In [9]: with h5py.File('/tmp/foo.h5', 'r+') as f:
   ...:     vf = VersionedHDF5File(f)
   ...:     with vf.stage_version('1') as sv:
   ...:         sv['bar'].resize((12,))
   ...:         sv['bar'][8:12] = sv['bar'][6:10]
   ...:         sv['bar'][6:8] = [0, 0]
   ...:
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/opt/python/python-3.7/lib64/python3.7/_collections_abc.py in setdefault(self, key, default)
    853         try:
--> 854             return self[key]
    855         except KeyError:

/codemill/bessen/versioned_hdf5_env/lib64/python3.7/site-packages/versioned_hdf5/hashtable.py in __getitem__(self, key)
    103     def __getitem__(self, key):
--> 104         i = self._indices[key]
    105         shapes = self.hash_table['shape']

KeyError: b'w=\x14\x96<\xa5\xd2\xcc\xc1\xd7o/U\x0e\xc3j[*t\x8c"p\x05\xd2\xc0d\x9dt\xc1?\xdb\xe6'

During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
<ipython-input-9-2157bc8c6ae6> in <module>
      4         sv['bar'].resize((12,))
      5         sv['bar'][8:12] = sv['bar'][6:10]
----> 6         sv['bar'][6:8] = [0, 0]
      7

/opt/python/python-3.7/lib64/python3.7/contextlib.py in __exit__(self, type, value, traceback)
    117         if type is None:
    118             try:
--> 119                 next(self.gen)
    120             except StopIteration:
    121                 return False

/codemill/bessen/versioned_hdf5_env/lib64/python3.7/site-packages/versioned_hdf5/api.py in stage_version(self, version_name, prev_version, make_current, timestamp)
    201                            compression=group.compression,
    202                            compression_opts=group.compression_opts,
--> 203                            timestamp=timestamp)
    204         except:
    205             delete_version(self.f, version_name, old_current)

/codemill/bessen/versioned_hdf5_env/lib64/python3.7/site-packages/versioned_hdf5/versions.py in commit_version(version_group, datasets, make_current, chunks, compression, compression_opts, timestamp)
    121             if chunks[name] is not None:
    122                 raise NotImplementedError("Specifying chunk size with dict data")
--> 123             slices = write_dataset_chunks(f, name, data, shape=shape)
    124         elif isinstance(data, InMemorySparseDataset):
    125             write_dataset(f, name, np.empty((0,)*len(data.shape),

/codemill/bessen/versioned_hdf5_env/lib64/python3.7/site-packages/versioned_hdf5/backend.py in write_dataset_chunks(f, name, data_dict, shape)
    166                 raw_slice = Slice(idx*chunk_size, idx*chunk_size + data_s.shape[0])
    167                 data_hash = hashtable.hash(data_s)
--> 168                 raw_slice2 = hashtable.setdefault(data_hash, raw_slice)
    169                 if raw_slice2 == raw_slice:
    170                     data_to_write[raw_slice] = data_s

/opt/python/python-3.7/lib64/python3.7/_collections_abc.py in setdefault(self, key, default)
    854             return self[key]
    855         except KeyError:
--> 856             self[key] = default
    857         return default
    858

/codemill/bessen/versioned_hdf5_env/lib64/python3.7/site-packages/versioned_hdf5/hashtable.py in __setitem__(self, key, value)
    129             self.hash_table[self._indices[key]] = kv
    130         else:
--> 131             self.hash_table[self.largest_index] = kv
    132             self._indices[key] = self.largest_index
    133             self.largest_index += 1

IndexError: index 1 is out of bounds for axis 0 with size 1

Can you take a look?

@asmeurer
Copy link
Collaborator

Oops. This is one of those bugs that the test suite didn't catch because it only triggers when you close the file and reopen it. Fix at #209.

@ArvidJB
Copy link
Collaborator Author

ArvidJB commented Sep 30, 2021

Thanks @asmeurer this change seems to fix all issues we encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants