From f777927f74ec0fb6d38fac56789f940b29b04fc3 Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Sun, 26 Jul 2020 14:19:02 +1000
Subject: [PATCH] Add a check that the directory exists to prevent failure

---
 bilby/core/sampler/ptemcee.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bilby/core/sampler/ptemcee.py b/bilby/core/sampler/ptemcee.py
index da13250a4..1ee756c40 100644
--- a/bilby/core/sampler/ptemcee.py
+++ b/bilby/core/sampler/ptemcee.py
@@ -13,7 +13,7 @@ import numpy as np
 import pandas as pd
 import matplotlib.pyplot as plt
 
-from ..utils import logger
+from ..utils import logger, check_directory_exists_and_if_not_mkdir
 from .base_sampler import SamplerError, MCMCSampler
 
 
@@ -517,6 +517,7 @@ class Ptemcee(MCMCSampler):
         sys.exit(self.exit_code)
 
     def write_current_state(self, plot=True):
+        check_directory_exists_and_if_not_mkdir(self.outdir)
         checkpoint(
             self.iteration,
             self.outdir,
-- 
GitLab