Skip to content

KeyError: 0 using where()

As described in #9 (closed), we get a KeyError: 0 whenever we attempt to use where() with drop=True on a dataset created by the function load().

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
h5py/_objects.pyx in h5py._objects.ObjectID.__dealloc__()

KeyError: 0

Exception ignored in: 'h5py._objects.ObjectID.__dealloc__'
Traceback (most recent call last):
  File "h5py/_objects.pyx", line 200, in h5py._objects.ObjectID.__dealloc__
KeyError: 0

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-e1c6690e52c5> in <module>
----> 1 a = run.where(run.MCP3apd > 0, drop=True)
      2 a

This is sloved by deleting the 'run' attribute.

This is most likely linked to the fact that we save the DataCollection returned by extra-data open_run as the 'run' attribute in the dataset. There used to be no conflict with previous versions of xarray, netcdf, but now, for some unclear reason this error appears. The DAtaCollection contains a hdf5 file handler that may pose problems. For instance, I encountered this error when using multiprocessing on a list of runs.

We can:

  1. Try to dig and better understand why this error appears
  2. And/or remove the DataCollection as attribute. This has the following implications:
    • Store attribute 'proposal' and 'runNumber' instead of 'run'
    • Change code which uses the 'run' attribute and use extra_data open_run instead. Mostly in xgm.py, also some in bunch_pattern.py and maybe somewhere else?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information