From bf501b17d0cac61dcd37f15b9cdcb578f49a169b Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Wed, 4 Dec 2019 18:30:40 -0600
Subject: [PATCH] Add a check to make sure the sampling time exists before
 trying to update

For runs cancelled during the marginalized parameter reconstruction,
this can lead to cases where the start_time isn't defined causing an
attribute error. This ensures that doesn't occur.
---
 bilby/core/sampler/dynesty.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/bilby/core/sampler/dynesty.py b/bilby/core/sampler/dynesty.py
index cedc5aca6..23c6a7604 100644
--- a/bilby/core/sampler/dynesty.py
+++ b/bilby/core/sampler/dynesty.py
@@ -436,8 +436,9 @@ class Dynesty(NestedSampler):
         logger.info("Writing checkpoint file {}".format(self.resume_file))
 
         end_time = datetime.datetime.now()
-        self.sampling_time += end_time - self.start_time
-        self.start_time = end_time
+        if hasattr(self, 'start_time'):
+            self.sampling_time += end_time - self.start_time
+            self.start_time = end_time
 
         current_state = dict(
             unit_cube_samples=self.sampler.saved_u,
-- 
GitLab