def __init__(self, config, name): self._name = name # needed for changeView calls before the constructor head = [('DATASETNICK', 'Nickname')] # Mapping between nickname and config files: self._nmCfg = config.getLookup('nickname config', {}, defaultMatcher = 'regex', parser = lambda x: lmap(str.strip, x.split(',')), strfun = lambda x: str.join(',', x)) if not self._nmCfg.empty(): allConfigFiles = sorted(set(ichain(self._nmCfg.get_values()))) config.set('config file', str.join('\n', allConfigFiles)) head.append((1, 'Config file')) elif config.get('config file', ''): raise ConfigError("Please use 'nickname config' instead of 'config file'") # Mapping between nickname and constants - only display - work is handled by the 'normal' parameter factory nmCName = config.getList('nickname constants', [], onChange = None) param_config = config.changeView(viewClass = 'TaggedConfigView', setClasses = None, setNames = None, addSections = ['parameters']) param_config.set('constants', str.join(' ', nmCName), '+=') for cName in nmCName: param_config.set(cName + ' matcher', 'regex') param_config.set(cName + ' lookup', 'DATASETNICK') head.append((cName, cName)) # Mapping between nickname and lumi filter - only display - work is handled by the 'normal' lumi filter config.set('lumi filter matcher', 'regex') if 'nickname lumi filter' in config.getOptions(): config.set('lumi filter', strDictLong(config.getDict('nickname lumi filter', {}, onChange = None))) self._nmLumi = config.getLookup('lumi filter', {}, parser = parseLumiFilter, strfun = strLumi, onChange = None) if not self._nmLumi.empty(): head.append((2, 'Lumi filter')) CMSSW.__init__(self, config, name) self._displaySetup(config.getWorkPath('datacache.dat'), head)
def __init__(self, config, name): head = [(0, "Nickname")] # Mapping between nickname and config files: cfgList = config.get("nickname config", "") self.nmCfg = config.getDict( "nickname config", {}, parser=lambda x: map(str.strip, x.split(",")), str=lambda x: str.join(",", x) )[0] if cfgList: if "config file" in config.getOptions(): raise ConfigError("Please use 'nickname config' instead of 'config file'") allConfigFiles = utils.flatten(self.nmCfg.values()) config.set("config file", str.join("\n", allConfigFiles)) head.append((1, "Config file")) # Mapping between nickname and constants: self.nmCName = map(str.strip, config.get("nickname constants", "").split()) self.nmConst = {} for var in self.nmCName: tmp = config.getDict(var, {})[0] for (nick, value) in tmp.items(): if value: self.nmConst.setdefault(nick, {})[var] = value else: self.nmConst.setdefault(nick, {})[var] = "" head.append((var, var)) # Mapping between nickname and lumi filter: if "lumi filter" in config.getOptions(): raise ConfigError("Please use 'nickname lumi filter' instead of 'lumi filter'") lumiParse = lambda x: formatLumi(parseLumiFilter(x)) self.nmLumi = config.getDict("nickname lumi filter", {}, parser=lumiParse)[0] if self.nmLumi: for dataset in config.get("dataset", "").splitlines(): (datasetNick, datasetProvider, datasetExpr) = DataProvider.parseDatasetExpr(config, dataset, None) config.set( "dataset %s" % datasetNick, "lumi filter", str.join(",", utils.flatten(fromNM(self.nmLumi, datasetNick, []))), ) config.set("lumi filter", str.join(",", self.nmLumi.get(None, []))) head.append((2, "Lumi filter")) utils.vprint("Mapping between nickname and other settings:\n", -1) def report(): for nick in sorted(set(self.nmCfg.keys() + self.nmConst.keys() + self.nmLumi.keys())): tmp = { 0: nick, 1: str.join(", ", map(os.path.basename, self.nmCfg.get(nick, ""))), 2: self.displayLumi(self.nmLumi.get(nick, "")), } yield utils.mergeDicts([tmp, self.nmConst.get(nick, {})]) utils.printTabular(head, report(), "cl") utils.vprint(level=-1) CMSSW.__init__(self, config, name)
def __init__(self, config, name): self._name = name # needed for changeView calls before the constructor head = [('DATASETNICK', 'Nickname')] # Mapping between nickname and config files: self._nmCfg = config.getLookup( 'nickname config', {}, defaultMatcher='regex', parser=lambda x: lmap(str.strip, x.split(',')), strfun=lambda x: str.join(',', x)) if not self._nmCfg.empty(): if 'config file' in config.getOptions(): raise ConfigError( "Please use 'nickname config' instead of 'config file'") allConfigFiles = sorted( set(utils.flatten(self._nmCfg.get_values()))) config.set('config file', str.join('\n', allConfigFiles)) head.append((1, 'Config file')) # Mapping between nickname and constants - only display - work is handled by the 'normal' parameter factory nmCName = config.getList('nickname constants', [], onChange=None) param_config = config.changeView(viewClass='TaggedConfigView', setClasses=None, setNames=None, addSections=['parameters']) param_config.set('constants', str.join(' ', nmCName), '+=') for cName in nmCName: param_config.set(cName + ' matcher', 'regex') param_config.set(cName + ' lookup', 'DATASETNICK') head.append((cName, cName)) # Mapping between nickname and lumi filter - only display - work is handled by the 'normal' lumi filter if ('lumi filter' in config.getOptions()) and ('nickname lumi filter' in config.getOptions()): raise ConfigError('Please use "lumi filter" exclusively') config.set('lumi filter matcher', 'regex') config.set( 'lumi filter', strDictLong( config.getDict('nickname lumi filter', {}, onChange=None))) self._nmLumi = config.getLookup('lumi filter', {}, parser=parseLumiFilter, strfun=strLumi, onChange=None) if not self._nmLumi.empty(): head.append((2, 'Lumi filter')) CMSSW.__init__(self, config, name) self._displaySetup(config.getWorkPath('datacache.dat'), head)
def getJobConfig(self, jobNum): data = CMSSW.getJobConfig(self, jobNum) configFiles = self._nmCfg.lookup(data.get('DATASETNICK'), [], is_selector=False) data['CMSSW_CONFIG'] = str.join(' ', imap(os.path.basename, configFiles)) return data
def getJobConfig(self, jobNum): data = CMSSW.getJobConfig(self, jobNum) nickdata = self.getVarsForNick(data.get("DATASETNICK")) data.update(nickdata) data["LUMI_RANGE"] = self.getActiveLumiFilter(data["LUMI_RANGE"], jobNum) if utils.verbosity() > 0: utils.vprint("Nickname: %s" % data.get("DATASETNICK"), 1) utils.vprint(" * Config files: %s" % data["CMSSW_CONFIG"], 1) utils.vprint(" * Lumi range: %s" % data["LUMI_RANGE"], 1) utils.vprint( " * Variables: %s" % utils.filterDict(nickdata, lambda k: k not in ["CMSSW_CONFIG", "LUMI_RANGE"]), 1 ) return data
def getDatasetOverviewInfo(self, blocks): (head, blockInfos, fmt) = CMSSW.getDatasetOverviewInfo(self, blocks) head.extend([("CMSSW_CONFIG", "Config file"), ("LUMI_RANGE", "Lumi filter")]) def fmtLR(x): if x: return self.displayLumi(formatLumi(x)) return x fmt["LUMI_RANGE"] = fmtLR for blockInfo in blockInfos: data = self.getVarsForNick(blockInfo.get(DataProvider.Nickname, None)) for key in filter(lambda k: k not in ["CMSSW_CONFIG", "LUMI_RANGE"], data.keys()): if (key, key) not in head: head.append((key, key)) blockInfo.update(data) return (head, blockInfos, fmt)
def getJobConfig(self, jobNum): data = CMSSW.getJobConfig(self, jobNum) configFiles = self._nmCfg.lookup(data.get('DATASETNICK'), [], is_selector = False) data['CMSSW_CONFIG'] = str.join(' ', imap(os.path.basename, configFiles)) return data
def getTaskConfig(self): # Remove config file variable from the global settings data = CMSSW.getTaskConfig(self) data.pop('CMSSW_CONFIG') return data
def getJobConfig(self, jobNum): data = CMSSW.getJobConfig(self, jobNum) data['CMSSW_CONFIG'] = self._nmCfg.lookup(data.get('DATASETNICK'), '', is_selector=False) return data
def getVarNames(self): return CMSSW.getVarNames(self) + self.getJobConfig(0).keys()
def neededVars(self): if self.nmLumi: return CMSSW.neededVars(self) + ["LUMI_RANGE"] return CMSSW.neededVars(self)
def getJobConfig(self, jobNum): data = CMSSW.getJobConfig(self, jobNum) data['CMSSW_CONFIG'] = self._nmCfg.lookup(data.get('DATASETNICK'), '', is_selector = False) return data