Progress towards a Stanford runner bot.
authorBrandon King <kingb@caltech.edu>
Wed, 6 Aug 2008 22:05:44 +0000 (22:05 +0000)
committerBrandon King <kingb@caltech.edu>
Wed, 6 Aug 2008 22:05:44 +0000 (22:05 +0000)
htswdataprod/htswdataprod/automation/runner_s.py
htswdataprod/scripts/runner_s

index b408d8ee4bb11411b5777b94e6f1a03a51e6890d..441003afa63bb228bf5b83367020a3b4b8415f21 100644 (file)
@@ -6,6 +6,7 @@ import re
 import sys
 import time
 import threading
+import subprocess
 
 from benderjab import rpc
 
@@ -93,7 +94,7 @@ class Runner(rpc.XmlRpcBot):
         return 'StatusReport: Not implemented'
     
             
-    def sequencingFinished(self, run_dir):
+    def sequencingFinished(self, flowcell):
         """
         Sequenceing (and copying) is finished, time to start pipeline
         
@@ -101,7 +102,7 @@ class Runner(rpc.XmlRpcBot):
         """
         logging.debug("received sequencing finished message")
 
-        self.launchJob(run_dir, flowcell, ci)
+        self.launchJob(flowcell)
         return "started"
         
         
@@ -125,48 +126,44 @@ class Runner(rpc.XmlRpcBot):
                 self.send(u, msg)
 
 
-    def _runner(self, run_dir, flowcell, conf_info):
+    def _runner(self, flowcell):
 
         # retrieve config step
         # example error message
         #self.reportMsg("Retrieve config (%s): FAILED" % (run_dir))
 
+        #stdout_filepath = os.path.join(conf_info.analysis_dir,
+        #                         "pipeline_configure_stdout.txt")
+        #stderr_filepath = os.path.join(conf_info.analysis_dir,
+        #                               "pipeline_configure_stderr.txt")
+      
+        stdout_filepath = '/tmp/main_pipeline_script_stdout.txt'
+        stderr_filepath = '/tmp/main_pipeline_script_stderr.txt'
+      
+        fout = open(stdout_filepath, 'w')
+        ferr = open(stderr_filepath, 'w')
         
-        # configure step
-        if status_retrieve_cfg:
-            status = configure(conf_info)
-            if status:
-                logging.info("Runner: Configure: success")
-                self.reportMsg("Configure (%s): success" % (run_dir))
-                self.reportMsg(
-                    os.linesep.join(glob(os.path.join(run_dir,'Data','C*')))
-                )
-            else:
-                logging.error("Runner: Configure: failed")
-                self.reportMsg("Configure (%s): FAILED" % (run_dir))
+        pipe = subprocess.Popen(['./MainPipelineScript',
+                                '%s' % (flowcell)],
+                                stdout=fout,
+                                stderr=ferr)
+      
+        print "Attempting run at: %s" % (time.ctime())
+        error_code = pipe.wait()
+        
+        self.reportMsg("Return code is: %s" % (error_code))
+      
+        # Clean up
+        fout.close()
+        ferr.close()
 
-            #if successful, continue
-            if status:
-                # Setup status cmdline status monitor
-                #startCmdLineStatusMonitor(ci)
-                
-                # running step
-                print 'Running pipeline now!'
-                run_status = run_pipeline(conf_info)
-                if run_status is True:
-                    logging.info('Runner: Pipeline: success')
-                    self.reportMsg("Pipeline run (%s): Finished" % (run_dir,))
-                else:
-                    logging.info('Runner: Pipeline: failed')
-                    self.reportMsg("Pipeline run (%s): FAILED" % (run_dir))
-
-
-    def launchJob(self, run_dir, flowcell, conf_info):
+
+    def launchJob(self, flowcell):
         """
         Starts up a thread for running the pipeline
         """
         t = threading.Thread(target=self._runner,
-                        args=[run_dir, flowcell, conf_info])
+                        args=[flowcell])
         t.setDaemon(True)
         t.start()
         
index 56f7786a670954ef4843aee2a334211cdf1d29c7..f9aa0cab5c987e59dacc86e6df0bf8fe278e5a9d 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 import sys
-from htswdataprod.automation.runner import main
+from htswdataprod.automation.runner_s import main
 
 if __name__ == "__main__":
   sys.exit(main(sys.argv[1:]))