def createEditor(self, parent, option, index): editor = QLineEdit(parent) rx = "[\-_A-Za-z0-9]{1," + str(LABEL_LENGTH_MAX) + "}" self.regExp = QRegExp(rx) v = RegExpValidator(editor, self.regExp) editor.setValidator(v) return editor
def createEditor(self, parent, option, index): editor = QLineEdit(parent) validator = RegExpValidator(editor, QRegExp("[ -~]*")) editor.setValidator(validator) # Autocompletion for selection criteria! comp_list = ['all[]'] comp_list += [ 'plane[a, b, c, d, epsilon]', 'plane[a, b, c, d, inside]', 'plane[a, b, c, d, outside]', 'plane[n_x, n_y, n_z, x0, y0, z0, epsilon]', 'plane[n_x, n_y, n_z, x0, y0, z0, inside]', 'plane[n_x, n_y, n_z, x0, y0, z0, outside]', 'box[xmin, ymin, zmin, xmax, ymax, zmax]', 'box[x0, y0, z0, dx1, dy1, dz1, dx2, dy2, dz2, dx3, dy3, dz3]', 'cylinder[x0, y0, z0, x1, y1, z1, radius]', 'sphere[x_c, y_c, z_c, radius]' ] completer = QCompleter() editor.setCompleter(completer) model = QStringListModel() completer.setModel(model) model.setStringList(comp_list) return editor
def createEditor(self, parent, option, index): editor = QLineEdit(parent) self.old_pname = "" #editor.installEventFilter(self) rx = "[_a-zA-Z][_A-Za-z0-9]{1," + str(LABEL_LENGTH_MAX - 1) + "}" self.regExp = QRegExp(rx) v = RegExpValidator(editor, self.regExp) editor.setValidator(v) return editor
def createEditor(self, parent, option, index): editor = QLineEdit(parent) self.old_pname = "" rx = "[chonslCHONSL()][CHONSLchonsl()0-9]{0," + str(LABEL_LENGTH_MAX - 1) + "}" self.regExp = QRegExp(rx) v = RegExpValidator(editor, self.regExp) editor.setValidator(v) return editor
def createEditor(self, parent, option, index): editor = QLineEdit(parent) validator = RegExpValidator(editor, QRegExp("[ -~]*")) editor.setValidator(validator) # Autocompletion for selection criteria! comp_list = GuiLabelManager().getCompleter('mesh_selection') completer = QCompleter() editor.setCompleter(completer) model = QStringListModel() completer.setModel(model) model.setStringList(comp_list) return editor
def __init__(self, parent, default): """ Constructor """ QDialog.__init__(self, parent) Ui_VerifyExistenceLabelDialogForm.__init__(self) self.setupUi(self) self.setWindowTitle(self.tr("New label")) self.default = default self.default['list'].remove(self.default['label']) self.result = self.default.copy() v = RegExpValidator(self.lineEdit, self.default['regexp']) self.lineEdit.setValidator(v) self.lineEdit.textChanged[str].connect(self.slotLabel)
def createEditor(self, parent, option, index): editor = QLineEdit(parent) validator = RegExpValidator(editor, QRegExp("[ -~]*")) editor.setValidator(validator) return editor
def createEditor(self, parent, option, index): editor = QLineEdit(parent) vd = RegExpValidator(editor, QRegExp("[0-9- ]*")) editor.setValidator(vd) editor.installEventFilter(self) return editor
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_PerformanceTuningForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = PerformanceTuningModel(self.case) # Combo models and items self.modelPartType = ComboModel(self.comboBox_PartType, 4, 1) self.modelPartOut = ComboModel(self.comboBox_PartOutput, 3, 1) self.modelPartType.addItem(self.tr("Default"), 'default') self.modelPartType.addItem(self.tr("PT-SCOTCH / SCOTCH"), 'scotch') self.modelPartType.addItem(self.tr("ParMETIS / METIS"), 'metis') self.modelPartType.addItem(self.tr("Morton curve (bounding box)"), 'morton sfc') self.modelPartType.addItem(self.tr("Morton curve (bounding cube)"), 'morton sfc cube') self.modelPartType.addItem(self.tr("Hilbert curve (bounding box)"), 'hilbert sfc') self.modelPartType.addItem(self.tr("Hilbert curve (bounding cube)"), 'hilbert sfc cube') self.modelPartType.addItem(self.tr("Block (unoptimized)"), 'block') import cs_config cfg = cs_config.config() if cfg.libs['scotch'].have == "no": self.comboBox_PartType.setItemData(1, QColor(Qt.red), Qt.TextColorRole) if cfg.libs['metis'].have == "no": self.comboBox_PartType.setItemData(2, QColor(Qt.red), Qt.TextColorRole) self.modelPartOut.addItem(self.tr("No"), 'no') self.modelPartOut.addItem(self.tr("For graph-based partitioning"), 'default') self.modelPartOut.addItem(self.tr("Yes"), 'yes') self.modelBlockIORead = ComboModel(self.comboBox_IORead, 6, 1) self.modelBlockIOWrite = ComboModel(self.comboBox_IOWrite, 4, 1) self.modelBlockIORead.addItem(self.tr("Default"), 'default') self.modelBlockIORead.addItem(self.tr("Standard I/O, serial"), 'stdio serial') self.modelBlockIORead.addItem(self.tr("Standard I/O, parallel"), 'stdio parallel') self.modelBlockIORead.addItem(self.tr("MPI I/O, independent"), 'mpi independent') self.modelBlockIORead.addItem(self.tr("MPI I/O, non-collective"), 'mpi noncollective') self.modelBlockIORead.addItem(self.tr("MPI I/O, collective"), 'mpi collective') self.modelBlockIOWrite.addItem(self.tr("Default"), 'default') self.modelBlockIOWrite.addItem(self.tr("Standard I/O, serial"), 'stdio serial') self.modelBlockIOWrite.addItem(self.tr("MPI I/O, non-collective"), 'mpi noncollective') self.modelBlockIOWrite.addItem(self.tr("MPI I/O, collective"), 'mpi collective') # Validators partListVd = RegExpValidator(self.lineEdit_PartList, QRegExp("[0-9- ]*")) self.lineEdit_PartList.setValidator(partListVd) # Connections self.radioButtonYes.clicked.connect(self.slotPartition) self.radioButtonNo.clicked.connect(self.slotPartition) self.toolButton_PartInputDir.pressed.connect( self.slotSearchPartInputDirectory) self.comboBox_PartOutput.activated[str].connect(self.slotPartOut) self.comboBox_PartType.activated[str].connect(self.slotPartType) self.lineEdit_PartList.textChanged[str].connect(self.slotPartitionList) self.spinBoxRankStep.valueChanged[int].connect(self.slotRankStep) self.checkBox_IgnorePerio.clicked[bool].connect(self.slotIgnorePerio) self.comboBox_IORead.activated[str].connect(self.slotBlockIOReadMethod) self.comboBox_IOWrite.activated[str].connect( self.slotBlockIOWriteMethod) self.spinBoxIORankStep.valueChanged[int].connect( self.slotBlockIORankStep) self.spinBoxIOMinBlockSize.valueChanged[int].connect( self.slotBlockIOMinSize) self.tabWidget.currentChanged[int].connect(self.slotchanged) # Widget initialization self.partinput_path = self.mdl.getPartitionInputPath() if self.partinput_path: if not os.path.isdir( os.path.join(self.case['case_path'], self.partinput_path)): title = self.tr("WARNING") msg = self.tr("Invalid path in %s!" % self.partinput_path) QMessageBox.warning(self, title, msg) self.radioButtonYes.setChecked(True) self.radioButtonNo.setChecked(False)
class TimeAveragesView(QWidget, Ui_TimeAveragesForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_TimeAveragesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = TimeAveragesModel(self.case) self.entriesNumber = 0 self.label_select = None # Create the Page layout. # Models self.modelAverage = StandardItemModelAverage(self) self.treeViewAverage.setModel(self.modelAverage) self.treeViewAverage.resizeColumnToContents(0) self.treeViewAverage.resizeColumnToContents(1) self.treeViewAverage.resizeColumnToContents(2) self.treeViewAverage.resizeColumnToContents(3) self.treeViewAverage.resizeColumnToContents(4) self.modelDrag = QStringListModel() self.modelDrop = QStringListModel() self.listViewDrag.setModel(self.modelDrag) self.listViewDrop.setModel(self.modelDrop) self.listViewDrag.setAlternatingRowColors(True) self.listViewDrag.setEditTriggers(QAbstractItemView.NoEditTriggers) self.listViewDrop.setAlternatingRowColors(True) self.listViewDrop.setEditTriggers(QAbstractItemView.NoEditTriggers) self.modelIMOOLD = ComboModel(self.comboBoxIMOOLD, 3, 1) self.modelIMOOLD.addItem(self.tr('automatic'), 'automatic') self.modelIMOOLD.addItem(self.tr('reset'), 'reset') self.modelIMOOLD.addItem(self.tr('specified'), 'specified') self.modelStartType = ComboModel(self.comboBoxStartType, 2, 1) self.modelStartType.addItem(self.tr('time'), 'time') self.modelStartType.addItem(self.tr('iteration'), 'iteration') # Connections self.pushButtonAdd.clicked.connect(self.slotAddAverage) self.pushButtonDelete.clicked.connect(self.slotdeleteTimeAverage) self.pushButtonAddVar.clicked.connect(self.slotAddVarAverage) self.pushButtonSuppressVar.clicked.connect(self.slotDeleteVarAverage) self.treeViewAverage.pressed[QModelIndex].connect(self.slotSelectAverage) self.lineEditStart.textChanged[str].connect(self.slotStart) self.lineEditStartTime.textChanged[str].connect(self.slotStartTime) self.comboBoxIMOOLD.activated[str].connect(self.slotRestartChoice) self.comboBoxStartType.activated[str].connect(self.slotTimeChoice) self.lineEditRestart.textChanged[str].connect(self.slotRestart) self.lineEditAverage.textChanged[str].connect(self.slotBaseName) # Validators validatorStart = IntValidator(self.lineEditStart, min=-1) self.lineEditStart.setValidator(validatorStart) validatorStartTime = DoubleValidator(self.lineEditStartTime, min=-1.) self.lineEditStartTime.setValidator(validatorStartTime) validatorRestart = IntValidator(self.lineEditRestart, min=-2, max=50) validatorRestart.setExclusiveValues([0]) self.lineEditRestart.setValidator(validatorRestart) rx = "[\-_A-Za-z0-9]{1," + str(LABEL_LENGTH_MAX) + "}" validatorLabel = RegExpValidator(self.lineEditAverage, QRegExp(rx)) self.lineEditAverage.setValidator(validatorLabel) # Initialize # Update list of variables, properties, scalars ... lst_label = [str(label) for label in list(self.mdl.dicoLabel2Name.keys())] self.modelDrag.setStringList(sorted(lst_label, key=str.lower)) # Is it a following calculation ? if not StartRestartModel(self.case).getRestartPath(): self.labelRestart.setDisabled(True) self.comboBoxIMOOLD.setDisabled(True) self.lineEditRestart.setDisabled(True) self.treeViewAverage.hideColumn(4)
class ProfilesView(QWidget, Ui_ProfilesForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_ProfilesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = ProfilesModel(self.case) self.notebook = NotebookModel(self.case) # Initialize variables concerning the display of the Hlist self.entriesNumber = 0 # Models self.modelProfile = StandardItemModelProfile() self.treeViewProfile.setModel(self.modelProfile) self.treeViewProfile.resizeColumnToContents(0) # QListView layout self.gridlayout1 = QGridLayout(self.widgetDrag) self.gridlayout1.setContentsMargins(0, 0, 0, 0) self.DragList = QListView(self.widgetDrag) self.gridlayout1.addWidget(self.DragList, 0, 0, 1, 1) self.gridlayout2 = QGridLayout(self.widgetDrop) self.gridlayout2.setContentsMargins(0, 0, 0, 0) self.DropList = QListView(self.widgetDrop) self.gridlayout2.addWidget(self.DropList, 0, 0, 1, 1) self.modelDrag = QStringListModel() self.modelDrop = QStringListModel() self.DragList.setModel(self.modelDrag) self.DropList.setModel(self.modelDrop) self.DragList.setAlternatingRowColors(True) self.DragList.setEditTriggers(QAbstractItemView.NoEditTriggers) self.DropList.setAlternatingRowColors(True) self.DropList.setEditTriggers(QAbstractItemView.NoEditTriggers) # Combo items self.modelFreq = ComboModel(self.comboBoxFreq, 3, 1) self.modelFreq.addItem(self.tr("at the end of the calculation"), "end") self.modelFreq.addItem(self.tr("at each 'n' time steps"), "frequency") self.modelFreq.addItem(self.tr("Output every 'x' seconds"), 'time_value') self.modelFormat = ComboModel(self.comboBoxFormat, 2, 1) self.modelFormat.addItem(self.tr(".dat"), "DAT") self.modelFormat.addItem(self.tr(".csv"), "CSV") # Connections self.treeViewProfile.pressed[QModelIndex].connect( self.slotSelectProfile) self.pushButtonAdd.clicked.connect(self.slotAddProfile) self.pushButtonDelete.clicked.connect(self.slotDeleteProfile) self.pushButtonAddVar.clicked.connect(self.slotAddVarProfile) self.pushButtonSuppressVar.clicked.connect(self.slotDeleteVarProfile) self.comboBoxFreq.activated[str].connect(self.slotFrequencyType) self.comboBoxFormat.activated[str].connect(self.slotFormatType) self.pushButtonFormula.clicked.connect(self.slotFormula) self.lineEditBaseName.textChanged[str].connect(self.slotBaseName) self.lineEditFreq.textChanged[str].connect(self.slotFrequence) self.lineEditFreqTime.textChanged[str].connect(self.slotFrequenceTime) self.lineEditNbPoint.textChanged[str].connect(self.slotNbPoint) # Validators validatorFreq = IntValidator(self.lineEditFreq, min=0) validatorFreq.setExclusiveMin(True) self.lineEditFreq.setValidator(validatorFreq) validatorFreqT = DoubleValidator(self.lineEditFreqTime, min=0.) validatorFreqT.setExclusiveMin(True) self.lineEditFreqTime.setValidator(validatorFreqT) validatorNbPoint = IntValidator(self.lineEditNbPoint, min=0) self.lineEditNbPoint.setValidator(validatorNbPoint) rx = "[\-_A-Za-z0-9]{1," + str(LABEL_LENGTH_MAX) + "}" validatorBaseName = RegExpValidator(self.lineEditBaseName, QRegExp(rx)) self.lineEditBaseName.setValidator(validatorBaseName) #update list of variables, properties, scalars ... liste_label = [] for label in self.mdl.getVariablesAndVolumeProperties(): liste_label.append(label) self.modelDrag.setStringList(sorted(liste_label, key=str.lower)) #update list of profiles for view from xml file for lab in self.mdl.getProfilesLabelsList(): self.entriesNumber = self.entriesNumber + 1 label, fmt, lst, choice, freq, formula, nb_point = self.mdl.getProfileData( lab) self.__insertProfile(label, lst) self.__eraseEntries() self.case.undoStartGlobal()
class BatchRunningDialogView(QDialog, Ui_BatchRunningDialogForm): """ This class is devoted to the queue selection. If the batch script file name is known, informations are displayed in the appropiate widget. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningDialogForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent case_is_saved = not self.case.isModified() title = self.tr("Run computation") self.setWindowTitle(title) self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) # Check if the script file name is already defined if self.case['scripts_path']: if not self.case['runcase']: if self.case['package'].runcase in os.listdir(self.case['scripts_path']): runcase_path = os.path.join(self.case['scripts_path'], self.case['package'].runcase) self.case['runcase'] = cs_runcase.runcase(runcase_path, package=self.case['package']) self.jmdl = BatchRunningModel(parent, self.case) # Get MPI and OpenMP features self.have_mpi = False self.have_openmp = False config_features = self.case['package'].config.features config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) compute_build_id = -1 self.compute_versions = None if config.has_option('install', 'compute_versions'): self.compute_versions = config.get('install', 'compute_versions').split(':') compute_build_id = 0 if len(self.compute_versions) > 1: run_build = self.jmdl.dictValues['run_build'] if self.compute_versions.count(run_build) > 0: compute_build_id = self.compute_versions.index(run_build) elif run_build: compute_build_id = -1 self.jmdl.dictValues['run_build'] = None if compute_build_id >= 0: pkg_compute = self.case['package'].get_alternate_version(self.compute_versions[compute_build_id]) config_features = pkg_compute.config.features if config_features['mpi'] == 'yes': self.have_mpi = True if config_features['openmp'] == 'yes': self.have_openmp = True # Batch info self.hideBatchInfo() self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() if compute_build_id < 0: self.labelBuildType.hide() self.comboBoxBuildType.hide() else: self.comboBoxBuildType.currentIndexChanged[int].connect(self.slotBuildType) for b in self.compute_versions: build_type_label = os.path.basename(b) if not build_type_label: build_type_label = "[default]" self.comboBoxBuildType.addItem(self.tr(build_type_label), build_type_label) self.comboBoxBuildType.setCurrentIndex(compute_build_id) self.class_list = None self.__updateRunButton__(case_is_saved) if self.jmdl.batch.rm_type != None: validatorSimpleName = RegExpValidator(self.lineEditJobName, QRegExp("[_A-Za-z0-9]*")) validatorAccountName = RegExpValidator(self.lineEditJobAccount, QRegExp("\\S+")) self.lineEditJobName.setValidator(validatorSimpleName) self.lineEditJobAccount.setValidator(validatorAccountName) self.lineEditJobWCKey.setValidator(validatorAccountName) else: if self.jmdl.dictValues['run_nprocs'] == None: try: # For backwards compatibility # (this is a specific case, as we move information from # the XML model to the batch script) self.jmdl.dictValues['run_nprocs'] = self.mdl.getString('n_procs') self.mdl.setString('n_procs', None) except Exception: pass validatorRunId = RegExpValidator(self.lineEditRunId, QRegExp("[_A-Za-z0-9]*")) self.lineEditRunId.setValidator(validatorRunId) # Connections if self.jmdl.batch.rm_type != None: self.lineEditJobName.textChanged[str].connect(self.slotJobName) self.spinBoxNodes.valueChanged[int].connect(self.slotJobNodes) self.spinBoxPpn.valueChanged[int].connect(self.slotJobPpn) self.spinBoxProcs.valueChanged[int].connect(self.slotJobProcs) self.spinBoxThreads.valueChanged[int].connect(self.slotJobThreads) self.spinBoxDays.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxHours.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxMinutes.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxSeconds.valueChanged[int].connect(self.slotJobWallTime) self.comboBoxClass.activated[str].connect(self.slotClass) self.lineEditJobAccount.textChanged[str].connect(self.slotJobAccount) self.lineEditJobWCKey.textChanged[str].connect(self.slotJobWCKey) else: self.spinBoxNProcs.valueChanged[int].connect(self.slotNProcs) self.spinBoxNThreads.valueChanged[int].connect(self.slotNThreads) self.pushButtonCancel.clicked.connect(self.slotCancel) self.pushButtonApply.clicked.connect(self.slotApply) self.pushButtonRunSubmit.clicked.connect(self.slotBatchRunning) self.lineEditRunId.textChanged[str].connect(self.slotJobRunId) self.lineEdit_tool.textChanged[str].connect(self.slotDebug) self.toolButton_2.clicked.connect(self.slotDebugHelp) self.checkBoxInitOnly.stateChanged.connect(self.slotInitOnly) self.checkBoxTrace.stateChanged.connect(self.slotTrace) self.checkBoxLogParallel.stateChanged.connect(self.slotLogParallel) if not self.case['scripts_path']: self.pushButtonRunSubmit.setEnabled(False) # initialize Widgets if self.jmdl.batch.rm_type != None and self.case['runcase']: self.displayBatchInfo() #rm_type = self.jmdl.batch.rm_type run_id = str(self.jmdl.dictValues['run_id']) if run_id != 'None': self.lineEditRunId.setText(run_id) else: self.lineEditRunId.setText("") # Advanced options self.debug = self.mdl.getString('debug') if self.debug is not None: self.lineEdit_tool.setText(str(self.debug)) self.trace_iter = self.mdl.getTrace() self.log_parallel = self.mdl.getLogParallel() if self.trace_iter: self.checkBoxTrace.setChecked(True) if self.log_parallel: self.checkBoxLogParallel.setChecked(True) self.checkBoxInitOnly.setChecked(self.jmdl.dictValues['run_stage_init']) # Script info is based on the XML model self.displayScriptInfo() self.case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningDialogForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent case_is_saved = not self.case.isModified() title = self.tr("Run computation") self.setWindowTitle(title) self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) self.jmdl = self.case['job_model'] if self.jmdl == None: if self.case['data_path']: run_conf_path = os.path.join(self.case['data_path'], 'run.cfg') else: run_conf_path = None self.jmdl = BatchRunningModel(path=run_conf_path, pkg=self.case['package']) self.jmdl.load() self.run_dict = {} for k in self.jmdl.run_dict: self.run_dict[k] = self.jmdl.run_dict[k] self.job_dict = {} for k in self.jmdl.job_dict: self.job_dict[k] = self.jmdl.job_dict[k] self.have_mpi = self.jmdl.have_mpi self.have_openmp = self.jmdl.have_openmp self.job_name = self.jmdl.batch.params['job_nodes'] self.job_nodes = self.jmdl.batch.params['job_nodes'] self.job_ppn = self.jmdl.batch.params['job_ppn'] self.job_procs = self.jmdl.batch.params['job_procs'] self.job_threads = self.jmdl.batch.params['job_threads'] self.job_walltime = self.jmdl.batch.params['job_walltime'] self.job_class = self.jmdl.batch.params['job_class'] self.job_account = self.jmdl.batch.params['job_account'] self.job_wckey = self.jmdl.batch.params['job_wckey'] # Batch info self.hideBatchInfo() self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() compute_build_id = -1 if self.jmdl.compute_builds: compute_build = self.run_dict['compute_build'] if compute_build in self.jmdl.compute_builds: compute_build_id = self.jmdl.compute_builds.index( compute_build) else: compute_build_id = 0 self.run_dict['compute_build'] = self.jmdl.compute_builds[0] if compute_build_id < 0: self.labelBuildType.hide() self.comboBoxBuildType.hide() else: self.comboBoxBuildType.currentIndexChanged[int].connect( self.slotBuildType) for b in self.jmdl.compute_builds: build_type_label = os.path.basename(b) if not build_type_label: build_type_label = "[default]" self.comboBoxBuildType.addItem(self.tr(build_type_label), build_type_label) self.comboBoxBuildType.setCurrentIndex(compute_build_id) self.class_list = None self.__updateRunButton__(case_is_saved) if self.jmdl.batch.rm_type != None: validatorSimpleName = RegExpValidator(self.lineEditJobName, QRegExp("[_A-Za-z0-9]*")) validatorAccountName = RegExpValidator(self.lineEditJobAccount, QRegExp("\\S+")) self.lineEditJobName.setValidator(validatorSimpleName) self.lineEditJobAccount.setValidator(validatorAccountName) self.lineEditJobWCKey.setValidator(validatorAccountName) validatorRunId = RegExpValidator(self.lineEditRunId, QRegExp("[_A-Za-z0-9]*")) self.lineEditRunId.setValidator(validatorRunId) # Connections if self.jmdl.batch.rm_type != None: self.lineEditJobName.textChanged[str].connect(self.slotJobName) self.spinBoxNodes.valueChanged[int].connect(self.slotJobNodes) self.spinBoxPpn.valueChanged[int].connect(self.slotJobPpn) self.spinBoxProcs.valueChanged[int].connect(self.slotJobProcs) self.spinBoxThreads.valueChanged[int].connect(self.slotJobThreads) self.spinBoxDays.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxHours.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxMinutes.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxSeconds.valueChanged[int].connect(self.slotJobWallTime) self.comboBoxClass.activated[str].connect(self.slotClass) self.lineEditJobAccount.textChanged[str].connect( self.slotJobAccount) self.lineEditJobWCKey.textChanged[str].connect(self.slotJobWCKey) else: self.spinBoxNProcs.valueChanged[int].connect(self.slotNProcs) self.spinBoxNThreads.valueChanged[int].connect(self.slotNThreads) self.pushButtonCancel.clicked.connect(self.slotCancel) self.pushButtonApply.clicked.connect(self.slotApply) self.pushButtonRunSubmit.clicked.connect(self.slotBatchRunning) self.lineEditRunId.textChanged[str].connect(self.slotJobRunId) self.lineEdit_tool.textChanged[str].connect(self.slotDebug) self.toolButton_2.clicked.connect(self.slotDebugHelp) self.checkBoxInitOnly.stateChanged.connect(self.slotInitOnly) self.checkBoxTrace.stateChanged.connect(self.slotTrace) self.checkBoxLogParallel.stateChanged.connect(self.slotLogParallel) if not self.case['data_path']: self.pushButtonRunSubmit.setEnabled(False) # initialize Widgets if self.jmdl.batch.rm_type != None: self.displayBatchInfo() run_id = str(self.run_dict['id']) if run_id != 'None': self.lineEditRunId.setText(run_id) else: self.lineEditRunId.setText("") # Advanced options self.debug = self.mdl.getString('debug') if self.debug is not None: self.lineEdit_tool.setText(str(self.debug)) self.trace_iter = self.mdl.getTrace() self.log_parallel = self.mdl.getLogParallel() if self.trace_iter: self.checkBoxTrace.setChecked(True) if self.log_parallel: self.checkBoxLogParallel.setChecked(True) self.checkBoxInitOnly.setChecked(self.run_dict['initialize'] == True) # Script info is based on the XML model self.displayScriptInfo() # self.resize(self.minimumSizeHint()) self.case.undoStartGlobal()
class BatchRunningView(QWidget, Ui_BatchRunningForm): """ This class is devoted to the Computer selection. When a new computer is selected, The old data frame is deleted and a new apropriate frame is open. If the batch script file name is known, informations are display in the apropiate widget. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) # Check if the script file name is already defined if self.case['scripts_path']: if not self.case['runcase']: if self.case['package'].runcase in os.listdir( self.case['scripts_path']): runcase_path = os.path.join(self.case['scripts_path'], self.case['package'].runcase) self.case['runcase'] = cs_runcase.runcase( runcase_path, package=self.case['package']) # Get MPI and OpenMP features self.have_mpi = False self.have_openmp = False config_features = self.case['package'].config.features config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) if config.has_option('install', 'compute_versions'): compute_versions = config.get('install', 'compute_versions').split(':') if compute_versions[0]: pkg_compute = self.case['package'].get_alternate_version( compute_versions[0]) config_features = pkg_compute.config.features if config_features['mpi'] == 'yes': self.have_mpi = True if config_features['openmp'] == 'yes': self.have_openmp = True self.jmdl = BatchRunningModel(parent, self.case) # Batch info self.hideBatchInfo() self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() self.class_list = None if self.jmdl.batch.rm_type != None: self.groupBoxArchi.setTitle("Job and script files") self.labelBatch.show() self.toolButtonSearchBatch.show() validatorSimpleName = RegExpValidator(self.lineEditJobName, QRegExp("[_A-Za-z0-9]*")) validatorAccountName = RegExpValidator(self.lineEditJobAccount, QRegExp("\\S+")) self.lineEditJobName.setValidator(validatorSimpleName) self.lineEditJobAccount.setValidator(validatorAccountName) self.lineEditJobWCKey.setValidator(validatorAccountName) self.pushButtonRunSubmit.setText("Submit job") else: if self.jmdl.dictValues['run_nprocs'] == None: try: # For backwards compatibility # (this is a specific case, as we move information from # the XML model to the batch script) self.jmdl.dictValues['run_nprocs'] = self.mdl.getString( 'n_procs') self.mdl.setString('n_procs', None) except Exception: pass # Connections if self.jmdl.batch.rm_type != None: self.lineEditJobName.textChanged[str].connect(self.slotJobName) self.spinBoxNodes.valueChanged[int].connect(self.slotJobNodes) self.spinBoxPpn.valueChanged[int].connect(self.slotJobPpn) self.spinBoxProcs.valueChanged[int].connect(self.slotJobProcs) self.spinBoxThreads.valueChanged[int].connect(self.slotJobThreads) self.spinBoxDays.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxHours.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxMinutes.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxSeconds.valueChanged[int].connect(self.slotJobWallTime) self.comboBoxClass.activated[str].connect(self.slotClass) self.lineEditJobAccount.textChanged[str].connect( self.slotJobAccount) self.lineEditJobWCKey.textChanged[str].connect(self.slotJobWCKey) else: self.spinBoxNProcs.valueChanged[int].connect(self.slotNProcs) self.spinBoxNThreads.valueChanged[int].connect(self.slotNThreads) self.toolButtonSearchBatch.clicked.connect(self.slotSearchBatchFile) self.comboBoxRunType.activated[str].connect(self.slotArgRunType) self.toolButtonAdvanced.clicked.connect(self.slotAdvancedOptions) self.pushButtonRunSubmit.clicked.connect(self.slotBatchRunning) # Combomodels self.modelArg_cs_verif = ComboModel(self.comboBoxRunType, 2, 1) self.modelArg_cs_verif.addItem(self.tr("Import mesh only"), 'none') self.modelArg_cs_verif.addItem(self.tr("Mesh preprocessing"), 'mesh preprocess') self.modelArg_cs_verif.addItem(self.tr("Mesh quality criteria"), 'mesh quality') self.modelArg_cs_verif.addItem(self.tr("Standard"), 'standard') if self.case['prepro'] == False: self.modelArg_cs_verif.enableItem(3) else: self.modelArg_cs_verif.disableItem(3) self.modelArg_cs_verif.setItem( str_model=self.mdl.getRunType(self.case['prepro'])) # initialize Widgets # Check if the script file name is already defined if self.case['runcase']: name = os.path.basename(self.case['runcase'].path) self.labelBatchName.setText(str(name)) self.toolButtonSearchBatch.setStyleSheet("background-color: green") else: self.toolButtonSearchBatch.setStyleSheet("background-color: red") if self.jmdl.batch.rm_type != None and self.case['runcase']: self.displayBatchInfo() # Script info is based on the XML model self.displayScriptInfo() self.case.undoStartGlobal()
class BatchRunningView(QWidget, Ui_BatchRunningForm): """ This class is devoted to the queue selection. If the batch script file name is known, informations are displayed in the appropiate widget. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) # Check if the script file name is already defined if self.case['scripts_path']: if not self.case['runcase']: if self.case['package'].runcase in os.listdir( self.case['scripts_path']): runcase_path = os.path.join(self.case['scripts_path'], self.case['package'].runcase) self.case['runcase'] = cs_runcase.runcase( runcase_path, package=self.case['package']) self.jmdl = BatchRunningModel(parent, self.case) # Get MPI and OpenMP features self.have_mpi = False self.have_openmp = False config_features = self.case['package'].config.features config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) compute_build_id = -1 self.compute_versions = None if config.has_option('install', 'compute_versions'): self.compute_versions = config.get('install', 'compute_versions').split(':') compute_build_id = 0 if len(self.compute_versions) > 1: run_build = self.jmdl.dictValues['run_build'] if self.compute_versions.count(run_build) > 0: compute_build_id = self.compute_versions.index(run_build) elif run_build: compute_build_id = -1 self.jmdl.dictValues['run_build'] = None self.jmdl.updateBatchFile('run_build') if compute_build_id >= 0: pkg_compute = self.case['package'].get_alternate_version( self.compute_versions[compute_build_id]) config_features = pkg_compute.config.features if config_features['mpi'] == 'yes': self.have_mpi = True if config_features['openmp'] == 'yes': self.have_openmp = True # Batch info self.hideBatchInfo() self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() if compute_build_id < 0: self.labelBuildType.hide() self.comboBoxBuildType.hide() else: self.comboBoxBuildType.currentIndexChanged[int].connect( self.slotBuildType) for b in self.compute_versions: build_type_label = os.path.basename(b) if not build_type_label: build_type_label = "[default]" self.comboBoxBuildType.addItem(self.tr(build_type_label), to_qvariant(build_type_label)) self.comboBoxBuildType.setCurrentIndex(compute_build_id) self.class_list = None if self.jmdl.batch.rm_type != None: validatorSimpleName = RegExpValidator(self.lineEditJobName, QRegExp("[_A-Za-z0-9]*")) validatorAccountName = RegExpValidator(self.lineEditJobAccount, QRegExp("\\S+")) self.lineEditJobName.setValidator(validatorSimpleName) self.lineEditJobAccount.setValidator(validatorAccountName) self.lineEditJobWCKey.setValidator(validatorAccountName) self.pushButtonRunSubmit.setText("Submit job") else: if self.jmdl.dictValues['run_nprocs'] == None: try: # For backwards compatibility # (this is a specific case, as we move information from # the XML model to the batch script) self.jmdl.dictValues['run_nprocs'] = self.mdl.getString( 'n_procs') self.mdl.setString('n_procs', None) except Exception: pass validatorRunId = RegExpValidator(self.lineEditRunId, QRegExp("[_A-Za-z0-9]*")) self.lineEditRunId.setValidator(validatorRunId) # Connections if self.jmdl.batch.rm_type != None: self.lineEditJobName.textChanged[str].connect(self.slotJobName) self.spinBoxNodes.valueChanged[int].connect(self.slotJobNodes) self.spinBoxPpn.valueChanged[int].connect(self.slotJobPpn) self.spinBoxProcs.valueChanged[int].connect(self.slotJobProcs) self.spinBoxThreads.valueChanged[int].connect(self.slotJobThreads) self.spinBoxDays.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxHours.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxMinutes.valueChanged[int].connect(self.slotJobWallTime) self.spinBoxSeconds.valueChanged[int].connect(self.slotJobWallTime) self.comboBoxClass.activated[str].connect(self.slotClass) self.lineEditJobAccount.textChanged[str].connect( self.slotJobAccount) self.lineEditJobWCKey.textChanged[str].connect(self.slotJobWCKey) else: self.spinBoxNProcs.valueChanged[int].connect(self.slotNProcs) self.spinBoxNThreads.valueChanged[int].connect(self.slotNThreads) self.comboBoxRunType.activated[str].connect(self.slotArgRunType) self.toolButtonAdvanced.clicked.connect(self.slotAdvancedOptions) self.pushButtonRunSubmit.clicked.connect(self.slotBatchRunning) self.lineEditRunId.textChanged[str].connect(self.slotJobRunId) # Combomodels self.modelArg_cs_verif = ComboModel(self.comboBoxRunType, 2, 1) self.modelArg_cs_verif.addItem(self.tr("Import mesh only"), 'none') self.modelArg_cs_verif.addItem(self.tr("Mesh preprocessing"), 'mesh preprocess') self.modelArg_cs_verif.addItem(self.tr("Mesh quality criteria"), 'mesh quality') if self.case['prepro'] == True: self.modelArg_cs_verif.setItem( str_model=self.mdl.getRunType(self.case['prepro'])) self.labelRunType.show() self.comboBoxRunType.show() else: self.labelRunType.hide() self.comboBoxRunType.hide() # initialize Widgets if self.jmdl.batch.rm_type != None and self.case['runcase']: self.displayBatchInfo() #rm_type = self.jmdl.batch.rm_type run_id = str(self.jmdl.dictValues['run_id']) #if run_id == 'None' and self.case['scripts_path']: # run_id, run_title = self.__suggest_run_id() # self.__updateRuncase(run_id) if run_id != 'None': self.lineEditRunId.setText(run_id) else: self.lineEditRunId.setText("") # Script info is based on the XML model self.displayScriptInfo() self.case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_GasCombustionForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = GasCombustionModel(self.case) self.thermodata = ThermochemistryData(self.case) # Model for table View self.modelSpecies = StandardItemModelSpecies(self, self.thermodata) self.tableViewSpecies.setModel(self.modelSpecies) # Delegates delegateLabel = NameDelegate(self.tableViewSpecies) delegateChemicalFormula = ChemicalFormulaDelegate( self.tableViewSpecies) delegateCompFuel = ValueDelegate(self.tableViewSpecies) delegateCompOxi = ValueDelegate(self.tableViewSpecies) delegateCompProd = ValueDelegate(self.tableViewSpecies) delegateCoeffAbsorp = ValueDelegate(self.tableViewSpecies) self.tableViewSpecies.setItemDelegateForColumn(0, delegateLabel) self.tableViewSpecies.setItemDelegateForColumn( 1, delegateChemicalFormula) self.tableViewSpecies.setItemDelegateForColumn(2, delegateCompFuel) self.tableViewSpecies.setItemDelegateForColumn(3, delegateCompOxi) self.tableViewSpecies.setItemDelegateForColumn(4, delegateCompProd) self.tableViewSpecies.setItemDelegateForColumn(5, delegateCoeffAbsorp) # tableView if QT_API == "PYQT4": self.tableViewSpecies.horizontalHeader().setResizeMode( QHeaderView.Stretch) self.tableViewSpecies.horizontalHeader().setResizeMode( 0, QHeaderView.ResizeToContents) self.tableViewSpecies.horizontalHeader().setResizeMode( 1, QHeaderView.ResizeToContents) elif QT_API == "PYQT5": self.tableViewSpecies.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.tableViewSpecies.horizontalHeader().setSectionResizeMode( 0, QHeaderView.ResizeToContents) self.tableViewSpecies.horizontalHeader().setSectionResizeMode( 1, QHeaderView.ResizeToContents) # Set models and number of elements for combo boxes self.modelGasCombustionOption = ComboModel( self.comboBoxGasCombustionOption, 1, 1) # Combo models to choose the mode to create the Janaf File self.userModeForChemicalReaction = ComboModel(self.comboBoxUserChoice, 2, 1) self.userModeForChemicalReaction.addItem("Automatic definition", 'auto') self.userModeForChemicalReaction.addItem("Defined by user", 'user') # Connections self.comboBoxUserChoice.activated[str].connect(self.slotUserChoice) self.comboBoxGasCombustionOption.activated[str].connect( self.slotGasCombustionOption) self.pushButtonThermochemistryData.pressed.connect( self.__slotSearchThermochemistryData) self.radioButtonCreateJanafFile.clicked.connect( self.slotCreateJanafFile) self.lineEditNbPointsTabu.textChanged[str].connect( self.slotNbPointsTabu) self.lineEditMaximumTemp.textChanged[str].connect(self.slotMaximumTemp) self.lineEditMinimumTemp.textChanged[str].connect(self.slotMinimumTemp) self.pushButtonAddSpecies.clicked.connect(self.slotAddSpecies) self.pushButtonDeleteSpecies.clicked.connect(self.slotDeleteSpecies) self.pushButtonGenerateJanafFile.clicked.connect( self.slotGenerateJanafFile) self.lineEditFuel.textChanged[str].connect(self.slotFuel) self.lineEditO2.textChanged[str].connect(self.slotVolPropO2) self.lineEditN2.textChanged[str].connect(self.slotVolPropN2) self.lineEditCOyield.textChanged[str].connect(self.slotCOyield) self.lineEditCSyield.textChanged[str].connect(self.slotCSyield) self.modelSpecies.dataChanged.connect(self.dataChanged) # Validators validatorNbPointsTabu = IntValidator(self.lineEditNbPointsTabu, min=1) validatorMaximumTemp = DoubleValidator(self.lineEditMaximumTemp, min=273.0) validatorMinimumTemp = DoubleValidator(self.lineEditMinimumTemp, min=273.0) rx = "[chonlCHONL()][CHONLchonl()0-9]{0," + str(LABEL_LENGTH_MAX - 1) + "}" validatorFuel = RegExpValidator(self.lineEditFuel, QRegExp(rx)) validatorO2 = DoubleValidator(self.lineEditO2, min=1e-12, max=1.0) validatorN2 = DoubleValidator(self.lineEditN2, min=0.0, max=1.0) validatorCOyield = DoubleValidator(self.lineEditCOyield, min=0.0) validatorCSyield = DoubleValidator(self.lineEditCSyield, min=0.0) self.lineEditNbPointsTabu.setValidator(validatorNbPointsTabu) self.lineEditMaximumTemp.setValidator(validatorMaximumTemp) self.lineEditMinimumTemp.setValidator(validatorMinimumTemp) self.lineEditFuel.setValidator(validatorFuel) self.lineEditO2.setValidator(validatorO2) self.lineEditN2.setValidator(validatorN2) self.lineEditCOyield.setValidator(validatorCOyield) self.lineEditCSyield.setValidator(validatorCSyield) NbPointsTabu = self.thermodata.getNbPointsTabu() MaximumTemp = self.thermodata.getMaximumTemp() MinimumTemp = self.thermodata.getMinimumTemp() Option_UserMode = self.thermodata.getUserModeForChemicalReaction() ChemicalFormulaFuel = self.thermodata.getChemicalFormulaFuel() VolPropO2 = self.thermodata.getVolPropO2() VolPropN2 = self.thermodata.getVolPropN2() COyield = self.thermodata.getCOyield() CSyield = self.thermodata.getCSyield() self.lineEditNbPointsTabu.setText(str(NbPointsTabu)) self.lineEditMaximumTemp.setText(str(MaximumTemp)) self.lineEditMinimumTemp.setText(str(MinimumTemp)) self.lineEditFuel.setText(str(ChemicalFormulaFuel)) self.lineEditO2.setText(str(VolPropO2)) self.lineEditN2.setText(str(VolPropN2)) self.lineEditCOyield.setText(str(COyield)) self.lineEditCSyield.setText(str(CSyield)) # Initialize Widgets self.tableViewSpecies.reset() self.modelSpecies = StandardItemModelSpecies(self, self.thermodata) self.tableViewSpecies.setModel(self.modelSpecies) model = self.mdl.getGasCombustionModel() if model == 'd3p': self.modelGasCombustionOption.addItem(self.tr("adiabatic model"), "adiabatic") self.modelGasCombustionOption.addItem( self.tr("non adiabatic model"), "extended") elif model == 'ebu': self.modelGasCombustionOption.addItem( self.tr("reference Spalding model"), "spalding") self.modelGasCombustionOption.addItem( self.tr("extended model with enthalpy source term"), "enthalpy_st") self.modelGasCombustionOption.addItem( self.tr("extended model with mixture fraction transport"), "mixture_st") self.modelGasCombustionOption.addItem( self. tr("extended model with enthalpy and mixture fraction transport" ), "enthalpy_mixture_st") elif model == 'lwp': self.modelGasCombustionOption.addItem( self.tr("reference two-peak model with adiabatic condition"), "2-peak_adiabatic") self.modelGasCombustionOption.addItem( self.tr("reference two-peak model with enthalpy source term"), "2-peak_enthalpy") self.modelGasCombustionOption.addItem( self.tr("reference three-peak model with adiabatic condition"), "3-peak_adiabatic") self.modelGasCombustionOption.addItem( self.tr( "reference three-peak model with enthalpy source term"), "3-peak_enthalpy") self.modelGasCombustionOption.addItem( self.tr("reference four-peak model with adiabatic condition"), "4-peak_adiabatic") self.modelGasCombustionOption.addItem( self.tr("reference four-peak model with enthalpy source term"), "4-peak_enthalpy") option = self.mdl.getGasCombustionOption() self.modelGasCombustionOption.setItem(str_model=option) name = self.mdl.getThermoChemistryDataFileName() if name != None and name != "": self.labelThermochemistryFile.setText(str(name)) self.pushButtonThermochemistryData.setStyleSheet( "background-color: green") else: self.pushButtonThermochemistryData.setStyleSheet( "background-color: red") self.radioButtonCreateJanafFile.hide() if self.thermodata.getCreateThermoDataFile() == 'on': self.radioButtonCreateJanafFile.setChecked(True) self.userModeForChemicalReaction.setItem(str_model=Option_UserMode) for label in self.thermodata.getSpeciesNamesList(): self.modelSpecies.newItem(label) else: self.radioButtonCreateJanafFile.setChecked(False) # for the moment the option to create Janaf file in the GUI is only available with d3p if model == 'd3p': self.radioButtonCreateJanafFile.show() self.groupBoxTabulation.show() self.groupBoxChemicalReaction.show() self.groupBoxDefinedByUser.show() self.groupBoxGenerateDataFile.show() self.groupBoxAutomatic.show() self.slotCreateJanafFile() self.case.undoStartGlobal()