Commits

Johannes Köster  committed 1d1e372

Remove metadata if job failed and output files were deleted.

  • Participants
  • Parent commits a969a5b

Comments (0)

Files changed (2)

File snakemake/executors.py

         except (Exception, BaseException) as ex:
             print_exception(ex, self.workflow.linemaps)
             job.cleanup()
+            self.workflow.persistence.cleanup(job)
             error_callback()
 
 

File snakemake/persistence.py

 import os
 import signal
 import marshal
-import time
 from base64 import urlsafe_b64encode
 from functools import lru_cache, partial
 from itertools import filterfalse
             self._record(self._version, version, f)
             self._record(self._code, code, f, bin=True)
 
+    def cleanup(self, job):
+        for f in job.output:
+            self._delete_record(self._incomplete, f)
+            self._delete_record(self._version, f)
+            self._delete_record(self._code, f)
+
     def incomplete(self, job):
         return any(
             map(partial(self._exists_record, self._incomplete), job.output))
         try:
             os.remove(os.path.join(subject, self.b64id(id)))
         except OSError as e:
-            if e.errno != 2: # not missing
+            if e.errno != 2:  # not missing
                 raise e
 
     def _read_record(self, subject, id, bin=False):