Exemple #1
0
    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'])
    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()