Cashe file in generate_posterior_samples_from_marginalized_likelihood can become corrupted
While reconstructing samples from marginalized likelihood, the process can be interrupted (by for example running out of allocated memory). It can lead to improperly dumping the samples into the .cashe
file, leaving it empty. Current implementation assumes that if the .cashe
file exists, it is not empty and therefore can be read. So when the program resumes, it breaks, leading to the following error:
21:53 bilby INFO : Reconstructing marginalised parameters.
Traceback (most recent call last):
File "launchBilby.py", line 164, in <module>
result = bilby.run_sampler(
File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py38/lib/python3.8/site-packages/bilby/core/sampler/__init__.py", line 271, in run_sampler
result.samples_to_posterior(likelihood=likelihood, priors=result.priors,
File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py38/lib/python3.8/site-packages/bilby/core/result.py", line 1454, in samples_to_posterior
data_frame = conversion_function(data_frame, likelihood, priors, npool=npool)
File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py38/lib/python3.8/site-packages/bilby/gw/conversion.py", line 864, in generate_all_bbh_parameters
output_sample = _generate_all_cbc_parameters(
File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py38/lib/python3.8/site-packages/bilby/gw/conversion.py", line 803, in _generate_all_cbc_parameters
generate_posterior_samples_from_marginalized_likelihood(
File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py38/lib/python3.8/site-packages/bilby/gw/conversion.py", line 1253, in generate_posterior_samples_from_marginalized_likelihood
cached_samples_dict = pickle.load(f)
EOFError: Ran out of input
Proposed solution:
While reading .cashe
file, account for the case it is empty.