From fbd88bedc35b6323d14885adda6d5ca556362281 Mon Sep 17 00:00:00 2001 From: Sidney Mau Date: Tue, 16 Jan 2024 09:59:53 -0800 Subject: [PATCH] BUG check if key exists before constructing path to delete --- eastlake/steps/delete_sources.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/eastlake/steps/delete_sources.py b/eastlake/steps/delete_sources.py index c210513..72efa15 100644 --- a/eastlake/steps/delete_sources.py +++ b/eastlake/steps/delete_sources.py @@ -201,11 +201,12 @@ def execute(self, stash, new_params=None): self.logger.error("deleting %s-band nullwt links for %s" % (band, tilename)) for sri in pyml["src_info"]: - nullwt_link = os.path.join( - base_dir, stash["desrun"], tilename, f"nullwt-{band}", - os.path.basename(sri["coadd_nwgint_path"]) - ) - safe_rm(nullwt_link) + if "coadd_nwgint_path" in sri: + nullwt_link = os.path.join( + base_dir, stash["desrun"], tilename, f"nullwt-{band}", + os.path.basename(sri["coadd_nwgint_path"]) + ) + safe_rm(nullwt_link) nullwt_path = os.path.join( base_dir, stash["desrun"], tilename, f"nullwt-{band}", @@ -221,11 +222,12 @@ def execute(self, stash, new_params=None): safe_rm(psf_link) for sri in pyml["src_info"]: - psf_link = os.path.join( - base_dir, stash["desrun"], tilename, "psfs", - os.path.basename(sri["psf_path"]) - ) - safe_rm(psf_link) + if "psf_path" in sri: + psf_link = os.path.join( + base_dir, stash["desrun"], tilename, "psfs", + os.path.basename(sri["psf_path"]) + ) + safe_rm(psf_link) self.logger.error("deleting %s-band psfmap for %s" % (band, tilename)) pmap_fn = os.path.join(