Skip to content

Catch incomplete JSON files being read.

Colm Talbot requested to merge fix-json-decoder-error into master

This MR will fix errors like the following that happen if a job is interrupted while writing a result file leading to a bad json file being read in on the restart. The error is passed as a more general IOError so that it can be caught downstream along with other result file reading errors.

  File "/ENV/lib/python3.8/site-packages/bilby/core/result.py", line 88, in read_in_result
    result = Result.from_json(filename=filename)
  File "/ENV/lib/python3.8/site-packages/bilby/core/result.py", line 538, in from_json
    dictionary = load_json(filename, gzip)
  File "/ENV/lib/python3.8/site-packages/bilby/core/utils/io.py", line 120, in load_json
    dictionary = json.load(file, object_hook=decode_bilby_json)
  File "/ENV/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/ENV/lib/python3.8/json/__init__.py", line 370, in loads
    return cls(**kw).decode(s)
  File "/ENV/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/ENV/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1124 column 35 (char 32856)

Merge request reports

Loading