def _connect(self): self._check_host_url() success = False msg = 'Error on connecting to cluster control service on %s' % self._host_url try: client = RemotingService(self._host_url) self.dlg = waitingProgressDialog('Please wait for the cluster...', self) self.dlg.setTarget(client.getService, 'clustercontrol') self.dlg.exec_() self._service = self.dlg.getTargetResult() except: exception(self, msg) else: try: self.dlg.setTarget(self._service.get_cecog_versions) self.dlg.exec_() cluster_versions = self.dlg.getTargetResult() except: exception(self, msg) else: if not VERSION in set(cluster_versions): warning(self, 'Cecog version %s not supported by the cluster' % VERSION, 'Valid versions are: %s' \ % ', '.join(cluster_versions)) else: success = True return success
def _abort_processing(self): self.setCursor(Qt.BusyCursor) self._is_abort = True self.dlg = waitingProgressDialog('Please wait until the processing has been terminated...', self) self.dlg.setTarget(self._analyzer.abort, wait=True) self.dlg.exec_() self.setCursor(Qt.ArrowCursor)
def _abort_processing(self): self.setCursor(Qt.BusyCursor) self._is_abort = True self.dlg = waitingProgressDialog( 'Please wait until the processing has been terminated...', self) self.dlg.setTarget(self._analyzer.abort, wait=True) self.dlg.exec_() self.setCursor(Qt.ArrowCursor)
def _update_job_status(self): try: self.dlg = waitingProgressDialog('Please wait for the cluster update...', self) self.dlg.setTarget(self._service.get_job_status, self._jobid) self.dlg.exec_() txt = self.dlg.getTargetResult() except: exception(self, 'Error on retrieve job status') else: self._label_jobstatus.setText(txt) return txt
def _on_terminate_job(self): try: self.dlg = waitingProgressDialog("Please wait until the job has been terminated...", self) self.dlg.setTarget(self._service.control_job, self._jobid, JOB_CONTROL_TERMINATE) self.dlg.exec_() except: exception(self, 'Error on job termination') else: self._btn_toogle.setChecked(False) self._toggle_state = JOB_CONTROL_SUSPEND self._btn_toogle.setText(self._toggle_state) self._update_job_status()
def _update_job_status(self): try: self.dlg = waitingProgressDialog( 'Please wait for the cluster update...', self) self.dlg.setTarget(self._service.get_job_status, self._jobid) self.dlg.exec_() txt = self.dlg.getTargetResult() except: exception(self, 'Error on retrieve job status') else: self._label_jobstatus.setText(txt) return txt
def _on_terminate_job(self): try: self.dlg = waitingProgressDialog( "Please wait until the job has been terminated...", self) self.dlg.setTarget(self._service.control_job, self._jobid, JOB_CONTROL_TERMINATE) self.dlg.exec_() except: exception(self, 'Error on job termination') else: self._btn_toogle.setChecked(False) self._toggle_state = JOB_CONTROL_SUSPEND self._btn_toogle.setText(self._toggle_state) self._update_job_status()
def _on_toggle_job(self): try: self.dlg = waitingProgressDialog("Please wait until the job has been suspended/resumed...", self) self.dlg.setTarget(self._service.control_job, self._jobid, self._toggle_state) self.dlg.exec_() except: self._toggle_state = JOB_CONTROL_SUSPEND self._btn_toogle.setChecked(False) exception(self, 'Error on toggle job status') else: if self._toggle_state == JOB_CONTROL_SUSPEND: self._toggle_state = JOB_CONTROL_RESUME else: self._toggle_state = JOB_CONTROL_SUSPEND self._update_job_status() self._btn_toogle.setText(self._toggle_state)
def _on_submit_job(self): self._submit_settings.set_section(SECTION_NAME_GENERAL) if not self._submit_settings.get2('constrain_positions'): positions = [] for plate_id in self.imagecontainer.plates: self.imagecontainer.set_plate(plate_id) meta_data = self.imagecontainer.get_meta_data() positions += [ '%s___%s' % (plate_id, p) for p in meta_data.positions ] self._submit_settings.set2('positions', ','.join(positions)) nr_items = len(positions) else: positions = self._submit_settings.get2('positions') nr_items = len(positions.split(',')) # FIXME: we need to get the current value for 'position_granularity' settings_dummy = ProcessingFrame.get_special_settings(self._settings) position_granularity = settings_dummy.get(SECTION_NAME_CLUSTER, 'position_granularity') path_out = self._submit_settings.get2('pathout') emails = str(self._txt_mail.text()).split(',') try: self.dlg = waitingProgressDialog( 'Please wait until the job has been submitted...', self) self.dlg.setTarget(self._service.submit_job, 'cecog_batch', self._submit_settings.to_string(), path_out, emails, nr_items, position_granularity, VERSION) self.dlg.exec_() jobid = self.dlg.getTargetResult() except: exception(self, 'Error on job submission') else: # FIXME: no idea how DRMAA 1.0 compatible this is if type(jobid) == types.ListType: self._jobid = ','.join(jobid) main_jobid = jobid[0].split('.')[0] else: self._jobid = str(jobid) main_jobid = jobid self._txt_jobid.setText(self._jobid) self._update_job_status() information( self, 'Job submitted successfully', "Job successfully submitted to the cluster.\nJob ID: %s, items: %d" % (main_jobid, nr_items))
def _on_submit_job(self): self._submit_settings.set_section(SECTION_NAME_GENERAL) if not self._submit_settings.get2('constrain_positions'): # FIXME: imagecontainer = qApp._main_window._imagecontainer positions = [] for plate_id in imagecontainer.plates: imagecontainer.set_plate(plate_id) meta_data = imagecontainer.get_meta_data() positions += ['%s___%s' % (plate_id, p) for p in meta_data.positions] self._submit_settings.set2('positions', ','.join(positions)) nr_items = len(positions) else: positions = self._submit_settings.get2('positions') nr_items = len(positions.split(',')) # FIXME: we need to get the current value for 'position_granularity' settings_dummy = ProcessingFrame.get_special_settings(self._settings) position_granularity = settings_dummy.get(SECTION_NAME_CLUSTER, 'position_granularity') path_out = self._submit_settings.get2('pathout') emails = str(self._txt_mail.text()).split(',') try: self.dlg = waitingProgressDialog('Please wait until the job has been submitted...', self) self.dlg.setTarget(self._service.submit_job, 'cecog_batch', self._submit_settings.to_string(), path_out, emails, nr_items, position_granularity, VERSION) self.dlg.exec_() jobid = self.dlg.getTargetResult() except: exception(self, 'Error on job submission') else: # FIXME: no idea how DRMAA 1.0 compatible this is if type(jobid) == types.ListType: self._jobid = ','.join(jobid) main_jobid = jobid[0].split('.')[0] else: self._jobid = str(jobid) main_jobid = jobid self._txt_jobid.setText(self._jobid) self._update_job_status() information(self, 'Job submitted successfully', "Job successfully submitted to the cluster.\nJob ID: %s, items: %d" % (main_jobid, nr_items))
def _on_toggle_job(self): try: self.dlg = waitingProgressDialog( "Please wait until the job has been suspended/resumed...", self) self.dlg.setTarget(self._service.control_job, self._jobid, self._toggle_state) self.dlg.exec_() except: self._toggle_state = JOB_CONTROL_SUSPEND self._btn_toogle.setChecked(False) exception(self, 'Error on toggle job status') else: if self._toggle_state == JOB_CONTROL_SUSPEND: self._toggle_state = JOB_CONTROL_RESUME else: self._toggle_state = JOB_CONTROL_SUSPEND self._update_job_status() self._btn_toogle.setText(self._toggle_state)
def _set_plate(self, coordinate_new, set_current=False): coordinate_old = self.browser.get_coordinate() plate = coordinate_new.plate self.dlg = waitingProgressDialog(\ "Please wait until the plate has been loaded...", self) self.dlg.setTarget(self._imagecontainer.set_plate, plate) self.dlg.exec_() meta_data = self._imagecontainer.get_meta_data() if set_current: self._set_current_plate(plate) self._update_position_table(meta_data) self._get_closeby_position(coordinate_old, coordinate_new) self._set_current_position(coordinate_new.position) if self._imagecontainer.has_timelapse: self._update_time_table(meta_data, coordinate_new) self._get_closeby_time(coordinate_old, coordinate_new) self._set_current_time(coordinate_new.time) self._update_info_frame(meta_data) self.coordinate_changed.emit(coordinate_new)
def _load_image_container(self, plate_infos, scan_plates=None, show_dlg=True): self._clear_browser() imagecontainer = ImageContainer() self._imagecontainer = imagecontainer if scan_plates is None: scan_plates = dict((info[0], False) for info in plate_infos) def load(dlg): iter = imagecontainer.iter_import_from_settings(self._settings, scan_plates) for idx, info in enumerate(iter): dlg.targetSetValue.emit(idx + 1) if len(imagecontainer.plates) > 0: plate = imagecontainer.plates[0] imagecontainer.set_plate(plate) self.dlg = waitingProgressDialog('Please wait until the input structure is scanned\n' 'or the structure data loaded...', self, load, (0, len(scan_plates))) self.dlg.exec_(passDialog=True) if len(imagecontainer.plates) > 0: imagecontainer.check_dimensions() channels = imagecontainer.channels # do not report value changes to the main window self._settings.set_notify_change(False) self.set_image_crop_size() problems = [] for prefix in ['primary', 'secondary', 'tertiary']: trait = self._settings.get_trait(SECTION_NAME_OBJECTDETECTION, '%s_channelid' % prefix) if trait.set_list_data(channels) is None: problems.append(prefix) self._tabs[1].get_widget('%s_channelid' % prefix).update() # report problems about a mismatch between channel IDs found in the data and specified by the user if len(problems) > 0: critical(self, "Selected channel IDs not valid", "The selected channel IDs for %s are not valid.\nValid IDs are %s." % (", ".join(["'%s Channel'" % s.capitalize() for s in problems]), ", ".join(["'%s'" % s for s in channels]))) # a mismatch between settings and data will cause changed settings self.settings_changed(True) trait = self._settings.get_trait(SECTION_NAME_TRACKING, 'tracking_duration_unit') # allow time-base tracking durations only if time-stamp # information is present meta_data = imagecontainer.get_meta_data() if meta_data.has_timestamp_info: result = trait.set_list_data(TRACKING_DURATION_UNITS_TIMELAPSE) else: result = trait.set_list_data(TRACKING_DURATION_UNITS_DEFAULT) if result is None: critical(self, "Could not set tracking duration units", "The tracking duration units selected to match the load data. Please check your settings.") # a mismatch between settings and data will cause changed settings self.settings_changed(True) # activate change notification again self._settings.set_notify_change(True) self.set_modules_active(state=True) if show_dlg: information(self, "Plate(s) successfully loaded", "%d plates loaded successfully." % len(imagecontainer.plates)) else: critical(self, "No valid image data found", "The naming schema provided might not fit your image data" "or the coordinate file is not correct.\n\nPlease modify " "the values and scan the structure again.")