Skip to content

Added try except clause for building the lookup table

Moritz Huebner requested to merge fix_load_lookup_table into master
Traceback (most recent call last):
  File "run.py", line 26, in <module>
    script(dir_path=dir_path, outdir=outdir, **kwargs)
  File "/home/mhuebner/.local/lib/python3.6/site-packages/memestr/routines/reweighting.py", line 70, in run_reweighting
    phase_marginalization=settings.other_settings.phase_marginalization)
  File "/home/mhuebner/.local/lib/python3.6/site-packages/bilby-0.5.3-py3.6.egg/bilby/gw/likelihood.py", line 143, in __init__
    distance_marginalization_lookup_table)
  File "/home/mhuebner/.local/lib/python3.6/site-packages/bilby-0.5.3-py3.6.egg/bilby/gw/likelihood.py", line 564, in _setup_distance_marginalization
    self.cached_lookup_table_filename)
  File "/home/mhuebner/.local/lib/python3.6/site-packages/bilby-0.5.3-py3.6.egg/bilby/gw/likelihood.py", line 593, in load_lookup_table
    loaded_file = dict(np.load(filename))
  File "/apps/skylake/software/mpi/gcc/7.3.0/openmpi/3.0.0/numpy/1.14.2-python-3.6.4/lib/python3.6/site-packages/numpy-1.14.2-py3.6-linux-x86_64.egg/numpy/lib/npyio.py", line 414, in load
    pickle_kwargs=pickle_kwargs)
  File "/apps/skylake/software/mpi/gcc/7.3.0/openmpi/3.0.0/numpy/1.14.2-python-3.6.4/lib/python3.6/site-packages/numpy-1.14.2-py3.6-linux-x86_64.egg/numpy/lib/npyio.py", line 173, in __init__
    _zip = zipfile_factory(fid)
  File "/apps/skylake/software/mpi/gcc/7.3.0/openmpi/3.0.0/numpy/1.14.2-python-3.6.4/lib/python3.6/site-packages/numpy-1.14.2-py3.6-linux-x86_64.egg/numpy/lib/npyio.py", line 103, in zipfile_factory
    return zipfile.ZipFile(file, *args, **kwargs)
  File "/apps/skylake/software/compiler/gcc/7.3.0/python/3.6.4/lib/python3.6/zipfile.py", line 1108, in __init__
    self._RealGetContents()
  File "/apps/skylake/software/compiler/gcc/7.3.0/python/3.6.4/lib/python3.6/zipfile.py", line 1175, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Exception ignored in: <bound method NpzFile.__del__ of <numpy.lib.npyio.NpzFile object at 0x2b5424b978d0>>
Traceback (most recent call last):
  File "/apps/skylake/software/mpi/gcc/7.3.0/openmpi/3.0.0/numpy/1.14.2-python-3.6.4/lib/python3.6/site-packages/numpy-1.14.2-py3.6-linux-x86_64.egg/numpy/lib/npyio.py", line 210, in __del__
    self.close()
  File "/apps/skylake/software/mpi/gcc/7.3.0/openmpi/3.0.0/numpy/1.14.2-python-3.6.4/lib/python3.6/site-packages/numpy-1.14.2-py3.6-linux-x86_64.egg/numpy/lib/npyio.py", line 201, in close
    if self.zip is not None:
AttributeError: 'NpzFile' object has no attribute 'zip'

This just seems to happen in some instances when we are trying to load the distance marginalization file. I added a try/except clause to prevent this.

Merge request reports

Loading