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 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