本文整理汇总了Python中grid_control.parameters.psource_base.ParameterSource.getClass方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterSource.getClass方法的具体用法?Python ParameterSource.getClass怎么用?Python ParameterSource.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grid_control.parameters.psource_base.ParameterSource
的用法示例。
在下文中一共展示了ParameterSource.getClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _resyncInternal
# 需要导入模块: from grid_control.parameters.psource_base import ParameterSource [as 别名]
# 或者: from grid_control.parameters.psource_base.ParameterSource import getClass [as 别名]
def _resyncInternal(self): # This function is _VERY_ time critical!
tmp = self._rawSource.resync() # First ask about psource changes
(redoNewPNum, disableNewPNum, sizeChange) = (set(tmp[0]), set(tmp[1]), tmp[2])
hashNew = self._rawSource.getHash()
hashChange = self._storedHash != hashNew
self._storedHash = hashNew
if not (redoNewPNum or disableNewPNum or sizeChange or hashChange):
self._resyncState = None
return
psource_old = ParameterAdapter(None, ParameterSource.createInstance('GCDumpParameterSource', self._pathParams))
psource_new = ParameterAdapter(None, self._rawSource)
mapJob2PID = {}
(pAdded, pMissing, _) = self._diffParams(psource_old, psource_new, mapJob2PID, redoNewPNum, disableNewPNum)
self._source = self._getResyncSource(psource_old, psource_new, mapJob2PID, pAdded, pMissing, disableNewPNum)
self._mapJob2PID = mapJob2PID # Update Job2PID map
redoNewPNum = redoNewPNum.difference(disableNewPNum)
if redoNewPNum or disableNewPNum:
mapPID2Job = dict(ismap(utils.swap, self._mapJob2PID.items()))
translate = lambda pNum: mapPID2Job.get(pNum, pNum)
self._resyncState = (set(imap(translate, redoNewPNum)), set(imap(translate, disableNewPNum)), sizeChange)
elif sizeChange:
self._resyncState = (set(), set(), sizeChange)
# Write resynced state
self._writeJob2PID(self._pathJob2PID + '.tmp')
ParameterSource.getClass('GCDumpParameterSource').write(self._pathParams + '.tmp', self)
os.rename(self._pathJob2PID + '.tmp', self._pathJob2PID)
os.rename(self._pathParams + '.tmp', self._pathParams)
示例2: createLookupHelper
# 需要导入模块: from grid_control.parameters.psource_base import ParameterSource [as 别名]
# 或者: from grid_control.parameters.psource_base.ParameterSource import getClass [as 别名]
def createLookupHelper(pconfig, var_list, lookup_list):
# Return list of (doElevate, PSourceClass, arguments) entries
if len(var_list) != 1: # multi-lookup handling
result = []
for var_name in var_list:
result.extend(createLookupHelper(pconfig, [var_name], lookup_list))
return result
var_name = var_list[0]
pvalue = pconfig.getParameter(var_name.lstrip('!'))
if isinstance(pvalue, list): # simple parameter source
if len(pvalue) == 1:
return [(False, ParameterSource.getClass('ConstParameterSource'), [var_name, pvalue[0]])]
else:
return [(False, ParameterSource.getClass('SimpleParameterSource'), [var_name, pvalue])]
elif isinstance(pvalue, tuple) and pvalue[0] == 'format':
return [(False, ParameterSource.getClass('FormatterParameterSource'), pvalue[1:])]
lookup_key = None
if lookup_list: # default lookup key
lookup_key = KeyParameterSource(*lookup_list)
# Determine kind of lookup, [3] == lookupDictConfig, [0] == lookupContent
tmp = lookupConfigParser(pconfig, KeyParameterSource(var_name), lookup_key)
lookupContent = tmp[3][0]
lookupLen = lmap(len, lookupContent.values())
if (min(lookupLen) == 1) and (max(lookupLen) == 1): # simple lookup sufficient for this setup
return [(False, SimpleLookupParameterSource, list(tmp))]
# switch needs elevation beyond local scope
return [(True, SwitchingLookupParameterSource, list(tmp))]
示例3: _createRef
# 需要导入模块: from grid_control.parameters.psource_base import ParameterSource [as 别名]
# 或者: from grid_control.parameters.psource_base.ParameterSource import getClass [as 别名]
def _createRef(self, arg):
refTypeDefault = 'dataset'
DataParameterSource = ParameterSource.getClass('DataParameterSource')
if arg not in DataParameterSource.datasetsAvailable:
refTypeDefault = 'csv'
refType = self._paramConfig.get(arg, 'type', refTypeDefault)
if refType == 'dataset':
return DataParameterSource.create(self._paramConfig, arg)
elif refType == 'csv':
return ParameterSource.getClass('CSVParameterSource').create(self._paramConfig, arg)
raise APIError('Unknown reference type: "%s"' % refType)
示例4: __init__
# 需要导入模块: from grid_control.parameters.psource_base import ParameterSource [as 别名]
# 或者: from grid_control.parameters.psource_base.ParameterSource import getClass [as 别名]
def __init__(self, config, source):
self._rawSource = source
BasicParameterAdapter.__init__(self, config, source)
self._mapJob2PID = {}
if not os.path.isdir(config.getWorkPath()):
os.makedirs(config.getWorkPath())
self._pathJob2PID = config.getWorkPath('params.map.gz')
self._pathParams = config.getWorkPath('params.dat.gz')
# Find out if init should be performed - overrides userResync!
userInit = config.getState('init', detail = 'parameters')
needInit = False
if not (os.path.exists(self._pathParams) and os.path.exists(self._pathJob2PID)):
needInit = True # Init needed if no parameter log exists
if userInit and not needInit and (source.getMaxParameters() is not None):
utils.eprint('Re-Initialization will overwrite the current mapping between jobs and parameter/dataset content! This can lead to invalid results!')
if utils.getUserBool('Do you want to perform a syncronization between the current mapping and the new one to avoid this?', True):
userInit = False
doInit = userInit or needInit
# Find out if resync should be performed
userResync = config.getState('resync', detail = 'parameters')
config.setState(False, 'resync', detail = 'parameters')
needResync = False
pHash = self._rawSource.getHash()
self._storedHash = config.get('parameter hash', pHash, persistent = True)
if self._storedHash != pHash:
needResync = True # Resync needed if parameters have changed
self._log.info('Parameter hash has changed')
self._log.debug('\told hash: %s', self._storedHash)
self._log.debug('\tnew hash: %s', pHash)
config.setState(True, 'init', detail = 'config')
doResync = (userResync or needResync) and not doInit
if not doResync and not doInit: # Reuse old mapping
activity = utils.ActivityLog('Loading cached parameter information')
self._readJob2PID()
activity.finish()
return
elif doResync: # Perform sync
activity = utils.ActivityLog('Syncronizing parameter information')
self._storedHash = None
self._resyncState = self.resync()
activity.finish()
elif doInit: # Write current state
self._writeJob2PID(self._pathJob2PID)
ParameterSource.getClass('GCDumpParameterSource').write(self._pathParams, self)
config.set('parameter hash', self._rawSource.getHash())
示例5: _createPSpace
# 需要导入模块: from grid_control.parameters.psource_base import ParameterSource [as 别名]
# 或者: from grid_control.parameters.psource_base.ParameterSource import getClass [as 别名]
def _createPSpace(self, args):
SubSpaceParameterSource = ParameterSource.getClass('SubSpaceParameterSource')
if len(args) == 1:
return SubSpaceParameterSource.create(self._paramConfig, args[0])
elif len(args) == 3:
return SubSpaceParameterSource.create(self._paramConfig, args[2], args[0])
else:
raise APIError('Invalid subspace reference!: %r' % args)
示例6: wrapper
# 需要导入模块: from grid_control.parameters.psource_base import ParameterSource [as 别名]
# 或者: from grid_control.parameters.psource_base.ParameterSource import getClass [as 别名]
def wrapper(*args):
try:
parameterClass = ParameterSource.getClass(clsName)
except Exception:
raise ParameterError('Unable to create parameter source "%r"!' % clsName)
try:
return parameterClass.create(self._paramConfig, *args)
except Exception:
raise ParameterError('Error while creating "%r" with arguments "%r"' % (parameterClass.__name__, args))