Commits

Johannes Köster committed 84a0c9a

Changed job property listing in jobscript to json format.

  • Participants
  • Parent commits 2910f69

Comments (0)

Files changed (5)

File snakemake/executors.py

         self.printjob(job)
 
     def rule_prefix(self, job):
-        return "local " if self.workflow.is_local(job) else ""
+        return "local " if self.workflow.is_local(job.rule) else ""
 
     def printjob(self, job):
         # skip dynamic jobs that will be "executed" only in dryrun mode
         super()._run(job)
         workdir = os.getcwd()
         jobid = self.dag.jobid(job)
+        properties = job.json()
 
         jobscript = self.get_jobscript(job)
         jobfinished = os.path.join(self.tmpdir, "{}.jobfinished".format(jobid))

File snakemake/jobs.py

 import os
 import sys
 import base64
+import json
 
 from collections import defaultdict
 from itertools import chain
             self.log, self.ruleio) = rule.expand_wildcards(
             self.wildcards_dict)
 
-        self.resources = dict()
-        for name, res in rule.resources.items():
-            self.resources[name] = min(self.rule.workflow.global_resources.get(name, 0), res)
+        self.resources = {
+            name: min(self.rule.workflow.global_resources.get(name, 0), res)
+            for name, res in rule.resources.items()}
         self.threads = self.resources["_cores"]
         self.resources = Resources(fromdict=self.resources)
         self._inputsize = None
         except NameError as ex:
             raise RuleException("NameError: " + str(ex), rule=self.rule)
 
+    def json(self):
+        resources = {name: res for name, res in self.resources.items() if name != "_cores"}
+        properties = {
+            "rule": self.rule.name,
+            "local": self.dag.workflow.is_local(self.rule),
+            "input": self.input,    
+            "output": self.output,
+            "threads": self.threads,
+            "resources": resources
+        }
+        return json.dumps(properties)
+
     def __repr__(self):
         return self.rule.name
 

File snakemake/jobscript.sh

 #!/bin/sh
-#rule: {job}
-#input: {job.input}
-#output: {job.output}
-#jobid: {jobid}
+# {properties}
 {workflow.snakemakepath} --snakefile {workflow.snakefile} \
 --force -j{cores} \
 --directory {workdir} --nocolor --notemp --quiet --nolock {job.output} \

File snakemake/scheduler.py

             error_callback=self._error)
 
     def run_cluster_or_local(self, job):
-        executor = self._local_executor if self.workflow.is_local(job) else self._executor
+        executor = self._local_executor if self.workflow.is_local(job.rule) else self._executor
         executor.run(
             job, callback=self._finish_callback,
             submit_callback=self._submit_callback,

File snakemake/workflow.py

                     for line in rule.docstring.split("\n"):
                         log("\t" + line)
 
-    def is_local(self, job):
-        return job.rule.name in self._localrules
+    def is_local(self, rule):
+        return rule.name in self._localrules
 
     def execute(
         self, targets=None, dryrun=False,  touch=False, cores=1,