def displayPythonScannableParameters(self, _pythonLine, _parameterScanFile): print '_pythonLine=', _pythonLine from ParameterScanUtils import ParameterScanUtils psu = ParameterScanUtils() foundGlobalVar = psu.checkPythonLineForGlobalVariable(_pythonLine) print 'foundGlobalVar=', foundGlobalVar
def __init__(self): CC3DResource.__init__(self) self.resourceName = 'CC3DParameterScanResource' self.type = 'ParameterScan' self.basePath = '' self.parameterScanXMLElements = {} self.parameterScanFileToDataMap = {} # {file name:dictionary of parameterScanData} parameterScanDataMap={hash:parameterScanData} # self.parameterScanDataMap = {} self.fileTypeForEditor = 'xml' self.parameterScanXMLHandler = None # self.parameterScanEditor=None self.psu = ParameterScanUtils() # ParameterScanUtils is the class where all parsing and parameter scan data processing takes place
def prepareParameterScan(_cc3dSimulationDataHandler): """This fcn returns True if preparation of the next PS run was succesfull or False otherwise - this will usually happen when parameter scan reaches max iteration . """ pScanFilePath = _cc3dSimulationDataHandler.cc3dSimulationData.parameterScanResource.path # parameter scan file path cc3dProjectPath = _cc3dSimulationDataHandler.cc3dSimulationData.path cc3dProjectDir = _cc3dSimulationDataHandler.cc3dSimulationData.basePath # psu = _cc3dSimulationDataHandler.cc3dSimulationData.parameterScanResource.psu #parameter scan utils # checking if simulation file directory is writeable if not parameterscan cannot run properly - writeable simulation fiel directory is requirement for parameter scan if not os.access(cc3dProjectDir, os.W_OK): raise AssertionError( "parameter Scan Error: CC3D project directory:" + cc3dProjectDir + " has to be writeable. Please change permission on the directory of the .cc3d project" ) # check if parameter scan file is writeable if not os.access(pScanFilePath, os.W_OK): raise AssertionError( "parameter Scan Error: Parameter Scan xml file :" + pScanFilePath + " has to be writeable. Please change permission on this file" ) # We use separate ParameterScanUtils object to handle parameter scan from ParameterScanUtils import ParameterScanUtils psu = ParameterScanUtils() psu.readParameterScanSpecs(pScanFilePath) paramScanSpecsDirName = os.path.dirname(pScanFilePath) outputDir = ( getRootOutputDir() ) # output dir is determined in a way that dpes not require PyQt4 and Configuration module customOutputPath = psu.prepareParameterScanOutputDirs(_outputDirRoot=outputDir) if not customOutputPath: return False, False _cc3dSimulationDataHandler.copySimulationDataFiles(customOutputPath) # tweak simulation files according to parameter scan file # construct path to the just-copied .cc3d file cc3dFileBaseName = os.path.basename(_cc3dSimulationDataHandler.cc3dSimulationData.path) cc3dFileFullName = os.path.join(customOutputPath, cc3dFileBaseName) # set output directory for parameter scan setSimulationResultStorageDirectory(customOutputPath) # replace values simulation files with values defined in the the parameter scan spcs psu.replaceValuesInSimulationFiles(_pScanFileName=pScanFilePath, _simulationDir=customOutputPath) # save parameter Scan spec file with incremented ityeration psu.saveParameterScanState(_pScanFileName=pScanFilePath) return customOutputPath, cc3dFileFullName
def displayXMLScannableParameters(self, _elem, _accessPath, _parameterScanFile): self.accessPath = _accessPath from ParameterScanUtils import ParameterScanUtils psu = ParameterScanUtils() print 'xmlElem=', _elem self.xmlString = '<' + _elem.name + ' ' for key in _elem.attributes.keys(): self.xmlString += ' ' + key + '="' + _elem.attributes[key] + '"' self.xmlString += '>' self.elemLE.setText(self.xmlString) self.scannableParams = psu.extractXMLScannableParameters( _elem, _parameterScanFile) table = self.paramTW for paramName, paramProps in self.scannableParams.iteritems(): currentRow = table.rowCount() # if table.rowCount()>0 else 0 print 'currentRow=', currentRow, 'paramName=', paramName table.insertRow(currentRow) paramNameItem = QTableWidgetItem(paramName) paramValueItem = QTableWidgetItem(paramProps[0]) paramTypeItem = QTableWidgetItem(TYPE_DICT[paramProps[1]]) btn = TablePushButton(table) actionItem = None btn.setText('Edit...') # if paramProps[1]==0: # btn.setText('Add To Scan...') # # actionItem=QTableWidgetItem('Add To Scan') # elif paramProps[1]==1: # btn.setText('View/Edit...') # # actionItem=QTableWidgetItem('View/Edit...') table.setItem(currentRow, PARAMETER, paramNameItem) table.setItem(currentRow, VALUE, paramValueItem) table.setItem(currentRow, TYPE, paramTypeItem) table.setCellWidget(currentRow, ACTION, btn) btn.setPosition(currentRow, ACTION) btn.clicked.connect(self.__handleActionClicked)
def prepareParameterScan(_cc3dSimulationDataHandler): '''This fcn returns True if preparation of the next PS run was succesfull or False otherwise - this will usually happen when parameter scan reaches max iteration . ''' pScanFilePath = _cc3dSimulationDataHandler.cc3dSimulationData.parameterScanResource.path # parameter scan file path cc3dProjectPath = _cc3dSimulationDataHandler.cc3dSimulationData.path cc3dProjectDir = _cc3dSimulationDataHandler.cc3dSimulationData.basePath # psu = _cc3dSimulationDataHandler.cc3dSimulationData.parameterScanResource.psu #parameter scan utils # checking if simulation file directory is writeable if not parameterscan cannot run properly - writeable simulation fiel directory is requirement for parameter scan if not os.access(cc3dProjectDir, os.W_OK): # raise AssertionError('parameter Scan Error: CC3D project directory:'+cc3dProjectDir+' has to be writeable. Please change permission on the directory of the .cc3d project') raise AssertionError('Parameter Scan ERRORCODE=' + str( ParameterScanEnums.SCAN_FINISHED_OR_DIRECTORY_ISSUE) + ': : CC3D project directory:' + cc3dProjectDir + ' has to be writeable. Please change permission on the directory of the .cc3d project') # check if parameter scan file is writeable if not os.access(pScanFilePath, os.W_OK): raise AssertionError('Parameter Scan ERRORCODE=' + str( ParameterScanEnums.SCAN_FINISHED_OR_DIRECTORY_ISSUE) + ': Parameter Scan xml file :' + pScanFilePath + ' has to be writeable. Please change permission on this file') # raise AssertionError('parameter Scan Error: Parameter Scan xml file :'+pScanFilePath+ ' has to be writeable. Please change permission on this file') # We use separate ParameterScanUtils object to handle parameter scan from ParameterScanUtils import ParameterScanUtils psu = ParameterScanUtils() psu.readParameterScanSpecs(pScanFilePath) paramScanSpecsDirName = os.path.dirname(pScanFilePath) outputDir = getRootOutputDir() # output dir is determined in a way that dpes not require PyQt4 and Configuration module customOutputPath = psu.prepareParameterScanOutputDirs(_outputDirRoot=outputDir) if not customOutputPath: return False, False _cc3dSimulationDataHandler.copySimulationDataFiles(customOutputPath) # tweak simulation files according to parameter scan file # construct path to the just-copied .cc3d file cc3dFileBaseName = os.path.basename(_cc3dSimulationDataHandler.cc3dSimulationData.path) cc3dFileFullName = os.path.join(customOutputPath, cc3dFileBaseName) # set output directory for parameter scan setSimulationResultStorageDirectory(customOutputPath) # replace values simulation files with values defined in the the parameter scan spcs psu.replaceValuesInSimulationFiles(_pScanFileName=pScanFilePath, _simulationDir=customOutputPath) # save parameter Scan spec file with incremented ityeration psu.saveParameterScanState(_pScanFileName=pScanFilePath) return customOutputPath, cc3dFileFullName
def displayXMLScannableParameters(self,_elem,_accessPath,_parameterScanFile): self.accessPath=_accessPath from ParameterScanUtils import ParameterScanUtils psu=ParameterScanUtils() print 'xmlElem=',_elem self.xmlString='<'+_elem.name+' ' for key in _elem.attributes.keys(): self.xmlString+=' '+key+'="'+_elem.attributes[key]+'"' self.xmlString+='>' self.elemLE.setText(self.xmlString) self.scannableParams=psu.extractXMLScannableParameters(_elem,_parameterScanFile) table=self.paramTW for paramName, paramProps in self.scannableParams.iteritems(): currentRow=table.rowCount() # if table.rowCount()>0 else 0 print 'currentRow=',currentRow,'paramName=',paramName table.insertRow(currentRow) paramNameItem=QTableWidgetItem(paramName) paramValueItem=QTableWidgetItem(paramProps[0]) paramTypeItem=QTableWidgetItem(TYPE_DICT[paramProps[1]]) btn = TablePushButton(table) actionItem=None btn.setText('Edit...') # if paramProps[1]==0: # btn.setText('Add To Scan...') # # actionItem=QTableWidgetItem('Add To Scan') # elif paramProps[1]==1: # btn.setText('View/Edit...') # # actionItem=QTableWidgetItem('View/Edit...') table.setItem (currentRow,PARAMETER, paramNameItem) table.setItem (currentRow,VALUE, paramValueItem) table.setItem (currentRow,TYPE, paramTypeItem) table.setCellWidget(currentRow, ACTION, btn) btn.setPosition(currentRow, ACTION) btn.clicked.connect(self.__handleActionClicked)
class CC3DParameterScanResource(CC3DResource): def __init__(self): CC3DResource.__init__(self) self.resourceName = 'CC3DParameterScanResource' self.type = 'ParameterScan' self.basePath = '' self.parameterScanXMLElements = {} self.parameterScanFileToDataMap = {} # {file name:dictionary of parameterScanData} parameterScanDataMap={hash:parameterScanData} # self.parameterScanDataMap = {} self.fileTypeForEditor = 'xml' self.parameterScanXMLHandler = None # self.parameterScanEditor=None self.psu = ParameterScanUtils() # ParameterScanUtils is the class where all parsing and parameter scan data processing takes place def addParameterScanData(self, _file, _psd): print 'self.basePath=', self.basePath print '_file=', _file relativePath = findRelativePath(self.basePath, _file) # relative path of the scanned simulation file w.r.t. project directory print 'relativePath=', relativePath self.psu.addParameterScanData(relativePath, _psd) def readParameterScanSpecs(self): self.psu.readParameterScanSpecs(self.path) def writeParameterScanSpecs(self): self.psu.writeParameterScanSpecs(self.path)
from cc3d.twedit5.twedit.utils.global_imports import *
def displayPythonScannableParameters(self,_pythonLine,_parameterScanFile): print '_pythonLine=',_pythonLine from ParameterScanUtils import ParameterScanUtils psu=ParameterScanUtils() foundGlobalVar=psu.checkPythonLineForGlobalVariable(_pythonLine) print 'foundGlobalVar=',foundGlobalVar