1. Sean Davis
  2. Snakemake


Johannes Köster  committed 76d1892

Added a --notemp flag, that can be used to tell snakemake to ignore any temp declarations. Useful for testing and essential for the cluster.

  • Participants
  • Parent commits 472a186
  • Branches master

Comments (0)

Files changed (6)

File bin/snakemake

View file
         "the job finished. This helps if your filesystem "
         "suffers from latency.")
+        "--notemp", "--nt", action="store_true",
+        help="Ignore temp() declarations. This is useful when running only "
+        "a part of the workflow, since temp() would lead to deletion of "
+        "probably needed files by other pars of the workflow."
+        )
+    parser.add_argument(
         "--print-compilation", action="store_true",
         help="Print the python representation of the workflow.")

File snakemake/__init__.py

View file
-    debug=False):
+    debug=False,
+    notemp=False):
     Run snakemake on a given snakefile.
     Note: at the moment, this function is not thread-safe!
                     nolock=not lock,
-                    resources=resources
+                    resources=resources,
+                    notemp=notemp
     except (Exception, BaseException) as ex:

File snakemake/dag.py

View file
-        ignore_incomplete=False):
+        ignore_incomplete=False,
+        notemp=False):
         self.dryrun = dryrun
         self.dependencies = defaultdict(partial(defaultdict, set))
         self.targetjobs = set()
         self.prioritytargetjobs = set()
         self._ready_jobs = set()
+        self.notemp = notemp
         self.forcerules = set()
         self.forcefiles = set()
             raise RuleException(include=chain(*exceptions.values()))
         for job in filter(
             lambda job: (job.dynamic_output
                 and not self.needrun(job)), self.jobs):
     def handle_temp(self, job):
         """ Remove temp files if they are no longer needed. """
+        if self.notemp:
+            return
         needed = lambda job_, f: any(f in files
             for j, files in self.depending[job_].items()
             if not self.finished(j) and self.needrun(j) and j != job)

File snakemake/executors.py

View file
         #output: {job.output}
         {self.workflow.snakemakepath} --snakefile {self.workflow.snakefile} \
         --force -j{self.cores} \
-        --directory {workdir} --nocolor --quiet --nolock {job.output} \
+        --directory {workdir} --nocolor --notemp --quiet --nolock {job.output} \
         > /dev/null && touch "{jobfinished}" || touch "{jobfailed}"
         exit 0

File snakemake/workflow.py

View file
         list_version_changes=False, list_code_changes=False,
         list_input_changes=False, list_params_changes=False,
         summary=False, output_wait=3, nolock=False, unlock=False,
-        resources=None):
+        resources=None, notemp=False):
         self.resources = resources
             forcerules=forcerules, priorityfiles=priorityfiles,
             priorityrules=priorityrules, ignore_ambiguity=ignore_ambiguity,
-            ignore_incomplete=ignore_incomplete)
+            ignore_incomplete=ignore_incomplete, notemp=notemp)
         self.persistence = Persistence(nolock=nolock, dag=dag)

File tests/test01/Snakefile

View file
 	output: "test.inter"
 	shell: "cp {input} {output}"
 # this should be ignored since test.in is present
 rule rule3:
 	input: "dir/{a}.out"
 	output: "{a}.in"
 	shell: "cp {input} {output}"