Johannes Köster avatar 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.

Comments (0)

Files changed (6)

         "the job finished. This helps if your filesystem "
         "suffers from latency.")
     parser.add_argument(
+        "--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.")
     parser.add_argument(

snakemake/__init__.py

     summary=False,
     output_wait=3,
     print_compilation=False,
-    debug=False):
+    debug=False,
+    notemp=False):
     """
     Run snakemake on a given snakefile.
     Note: at the moment, this function is not thread-safe!
                     output_wait=output_wait,
                     nolock=not lock,
                     unlock=unlock,
-                    resources=resources
+                    resources=resources,
+                    notemp=notemp
                     )
 
     except (Exception, BaseException) as ex:
         priorityrules=None,
         ignore_ambiguity=False,
         force_incomplete=False,
-        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()))
         self.update_needrun()
 
-
-
         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)

snakemake/executors.py

         #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
         """)

snakemake/workflow.py

         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,
             force_incomplete=force_incomplete,
-            ignore_incomplete=ignore_incomplete)
+            ignore_incomplete=ignore_incomplete, notemp=notemp)
 
         self.persistence = Persistence(nolock=nolock, dag=dag)
 

tests/test01/Snakefile

 	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}"
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.