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]]) batch = RunBatch.BPBatch() 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 batch.create( 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], runs = runs) RunBatch.run_all(batch.batch_id) vb_url = "ViewBatch.py?batch_id=%d" % batch.batch_id self.send_batch_submission_email(batch, vb_url) job_list = batch.select_jobs() 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 #") for run, job, status in job_list: assert isinstance(run, RunBatch.BPRun) assert isinstance(job, RunBatch.BPJob) 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))