Пример #1
0
 def build_submit_batch(self):
     '''Build the webpage for handling a submitted batch
     
     Also do the batch submission
     '''
     batch_size = int(BATCHPROFILER_DEFAULTS[BATCH_SIZE])
     if self.has_groups:
         first_last = np.hstack(
             [[True], self.group_numbers[1:] != self.group_numbers[:-1],
              [True]])
         gn = self.group_numbers[first_last[:-1]]
         first = self.image_numbers[first_last[:-1]]
         last = self.image_numbers[first_last[1:]]
     else:
         first = self.image_numbers[::batch_size]
         last = self.image_numbers[(batch_size - 1)::batch_size]
         if len(last) < len(first):
             last = np.hstack([last, self.image_numbers[-1]])
     runs = [(f, l) for f, l in zip(first, last)]
     #
     # Put it in the database
     #
     write_data = 1 if BATCHPROFILER_VARIABLES[WRITE_DATA] is not None else 0
     with RunBatch.bpcursor() as cursor:
         batch = RunBatch.BPBatch.create(
             cursor,
             email=BATCHPROFILER_DEFAULTS[EMAIL],
             data_dir=BATCHPROFILER_DEFAULTS[DATA_DIR],
             queue=BATCHPROFILER_DEFAULTS[QUEUE],
             batch_size=BATCHPROFILER_DEFAULTS[BATCH_SIZE],
             write_data=write_data,
             timeout=60,
             cpcluster=self.cpcluster,
             project=BATCHPROFILER_DEFAULTS[PROJECT],
             memory_limit=BATCHPROFILER_DEFAULTS[MEMORY_LIMIT],
             priority=BATCHPROFILER_DEFAULTS[PRIORITY])
         bpruns = []
         for bstart, bend in runs:
             cmd = RunBatch.cellprofiler_command(batch, bstart, bend)
             run = RunBatch.BPRun.create(cursor, batch, bstart, bend, cmd)
             bpruns.append(run)
     RunBatch.run(batch, bpruns)
     vb_url = BATCHPROFILER_DEFAULTS[URL] + \
         "/ViewBatch.py?batch_id=%d" % batch.batch_id
     self.send_batch_submission_email(batch, vb_url)
     task_list = batch.select_tasks()
     with self.tag("head"):
         with self.tag("title"):
             self.text("Batch #%d" % batch.batch_id)
         with self.tag("style", type="text/css"):
             self.doc.asis("""
                 table {
                     border-spacing: 0px;
                     border-collapse: collapse;
                 }
                 td {
                     text-align: left;
                     vertical-align: baseline;
                     padding: 0.1em 0.5em;
                     border: 1px solid #666666;
                 }""")
     with self.tag("body"):
         with self.tag("h1"):
             self.text("Results for batch #")
             with self.tag("a", href=vb_url):
                 self.text(str(batch.batch_id))
         with self.tag("table"):
             with self.tag("thead"):
                 with self.tag("tr"):
                     with self.tag("th"):
                         self.text("First image set")
                     with self.tag("th"):
                         self.text("Last image set")
                     with self.tag("th"):
                         self.text("job #")
                     with self.tag("th"):
                         self.text("task #")
             for task_status in task_list:
                 assert isinstance(task_status, RunBatch.BPJobTaskStatus)
                 task = task_status.job_task
                 assert isinstance(task, RunBatch.BPJobTask)
                 job = task.job
                 assert isinstance(job, RunBatch.BPJob)
                 bat = task.batch_array_task
                 assert isinstance(bat, RunBatch.BPBatchArrayTask)
                 task_id = bat.task_id
                 run = bat.run
                 with self.tag("tr"):
                     with self.tag("td"):
                         self.text(str(run.bstart))
                     with self.tag("td"):
                         self.text(str(run.bend))
                     with self.tag("td"):
                         self.text(str(job.job_id))
                     with self.tag("td"):
                         self.text(str(task_id))
Пример #2
0
 def build_submit_batch(self):
     '''Build the webpage for handling a submitted batch
     
     Also do the batch submission
     '''
     batch_size = int(BATCHPROFILER_DEFAULTS[BATCH_SIZE])
     if self.has_groups:
         first_last = np.hstack(
             [[True], 
             self.group_numbers[1:] != self.group_numbers[:-1], 
             [True]])
         gn = self.group_numbers[first_last[:-1]]
         first = self.image_numbers[first_last[:-1]]
         last = self.image_numbers[first_last[1:]]
     else:
         first = self.image_numbers[::batch_size]
         last = self.image_numbers[(batch_size-1)::batch_size]
         if len(last) < len(first):
             last = np.hstack([last, self.image_numbers[-1]])
     runs = [(f, l) for f, l in zip(first, last)]
     #
     # Put it in the database
     #
     write_data = 1 if BATCHPROFILER_VARIABLES[WRITE_DATA] is not None else 0
     with RunBatch.bpcursor() as cursor:
         batch = RunBatch.BPBatch.create(
             cursor,
             email = BATCHPROFILER_DEFAULTS[EMAIL],
             data_dir = BATCHPROFILER_DEFAULTS[DATA_DIR],
             queue = BATCHPROFILER_DEFAULTS[QUEUE],
             batch_size = BATCHPROFILER_DEFAULTS[BATCH_SIZE],
             write_data = write_data,
             timeout = 60,
             cpcluster = self.cpcluster,
             project = BATCHPROFILER_DEFAULTS[PROJECT],
             memory_limit = BATCHPROFILER_DEFAULTS[MEMORY_LIMIT],
             priority = BATCHPROFILER_DEFAULTS[PRIORITY])
         bpruns = []
         for bstart, bend in runs:
             cmd = RunBatch.cellprofiler_command(batch, bstart, bend)
             run = RunBatch.BPRun.create(cursor, batch, bstart, bend, cmd)
             bpruns.append(run)
     RunBatch.run(batch, bpruns)
     vb_url = BATCHPROFILER_DEFAULTS[URL] + \
         "/ViewBatch.py?batch_id=%d" % batch.batch_id
     self.send_batch_submission_email(batch, vb_url)
     task_list = batch.select_tasks()
     with self.tag("head"):
         with self.tag("title"):
             self.text("Batch #%d" % batch.batch_id)
         with self.tag("style", type="text/css"):
             self.doc.asis("""
                 table {
                     border-spacing: 0px;
                     border-collapse: collapse;
                 }
                 td {
                     text-align: left;
                     vertical-align: baseline;
                     padding: 0.1em 0.5em;
                     border: 1px solid #666666;
                 }""")
     with self.tag("body"):
         with self.tag("h1"):
             self.text("Results for batch #")
             with self.tag("a", href=vb_url):
                 self.text(str(batch.batch_id))
         with self.tag("table"):
             with self.tag("thead"):
                 with self.tag("tr"):
                     with self.tag("th"):
                         self.text("First image set")
                     with self.tag("th"):
                         self.text("Last image set")
                     with self.tag("th"):
                         self.text("job #")
                     with self.tag("th"):
                         self.text("task #")
             for task_status in task_list:
                 assert isinstance(task_status, RunBatch.BPJobTaskStatus)
                 task = task_status.job_task
                 assert isinstance(task, RunBatch.BPJobTask)
                 job = task.job
                 assert isinstance(job, RunBatch.BPJob)
                 bat = task.batch_array_task
                 assert isinstance(bat, RunBatch.BPBatchArrayTask)
                 task_id = bat.task_id
                 run = bat.run
                 with self.tag("tr"):
                     with self.tag("td"):
                         self.text(str(run.bstart))
                     with self.tag("td"):
                         self.text(str(run.bend))
                     with self.tag("td"):
                         self.text(str(job.job_id))
                     with self.tag("td"):
                         self.text(str(task_id))