def setConfiguration(self, cfgFile, **args): """ _setConfiguration_ Provide the CMSSW configuration to be used. By default, assume that cfgFile is a python format string. The format & type can be specified using args: - Type : must be "file" or "string" or "instance" """ cfgType = args.get("Type", "instance") if cfgType not in ("file", "string", "instance"): msg = "Illegal Type for cfg file: %s\n" % cfgType msg += "Should be \"file\" or \"string\"\n" raise RuntimeError, msg cfgContent = cfgFile if cfgType == "file": cfgContent = file(cfgFile).read() cfgType = "string" if cfgType == "string": cfgData = cfgContent cfgContent = CMSSWConfig() cfgContent.unpack(cfgData) self.cmsRunNode.cfgInterface = cfgContent self.configurations.append(cfgContent) return
def unpackPayloadNodeData(self, improvNode): """ _unpackPayloadNodeData_ Unpack PayloadNode data from improv Node provided and add information to self """ self.name = str(improvNode.attrs["Name"]) self.type = str(improvNode.attrs["Type"]) workflowName = improvNode.attrs.get('Workflow', None) if workflowName != None: self.workflow = str(workflowName) # // # // Unpack data for this instance #// App details appDataQ = IMProvQuery("/%s/Application" % self.__class__.__name__) appData = appDataQ(improvNode)[0] for appField in appData.children: field = str(appField.name) value = str(appField.attrs['Value']) self.application[field] = value # // # // App Control details #// appConDataQ = IMProvQuery("/%s/ApplicationControl/*" % self.__class__.__name__) appConData = appConDataQ(improvNode) for appConField in appConData: field = str(appConField.name) value = str(appConField.attrs['Value']) self.applicationControls[field] = value # // # // Script Controls #// scriptConQ = IMProvQuery("/%s/ScriptControls/ScriptList" % self.__class__.__name__) scriptLists = scriptConQ(improvNode) for scriptList in scriptLists: listName = scriptList.attrs.get("Name", None) if listName == None: continue listName = str(listName) for script in scriptList.children: scriptName = script.attrs.get("Value", None) if scriptName == None: continue self.scriptControls[listName].append(str(scriptName)) # // # // Dataset details #// Input Datasets inputDSQ = IMProvQuery("/%s/InputDatasets/DatasetInfo" % self.__class__.__name__) inputDS = inputDSQ(improvNode) # print improvNode for item in inputDS: newDS = DatasetInfo() newDS.load(item) self._InputDatasets.append(newDS) # // # // Output Datasets #// outputDSQ = IMProvQuery("/%s/OutputDatasets/DatasetInfo" % self.__class__.__name__) outputDS = outputDSQ(improvNode) for item in outputDS: newDS = DatasetInfo() newDS.load(item) self._OutputDatasets.append(newDS) # // # // Pileup Datasets #// pileupDSQ = IMProvQuery("/%s/PileupDatasets/DatasetInfo" % self.__class__.__name__) pileupDS = pileupDSQ(improvNode) for item in pileupDS: newDS = DatasetInfo() newDS.load(item) self._PileupDatasets.append(newDS) # // # // Input Links #// inpLinkQ = IMProvQuery("/%s/InputLinks/InputLink" % self.__class__.__name__) inpLinks = inpLinkQ(improvNode) for ilink in inpLinks: newLink = InputLink() newLink.load(ilink) self._InputLinks.append(newLink) # // # // Configuration #// configQ = IMProvQuery("/%s/Configuration" % self.__class__.__name__) configNodes = configQ(improvNode) if len(configNodes) > 0: configNode = configNodes[0] self.configuration = base64.decodestring(str(configNode.chardata)) cfgIntQ = IMProvQuery("/%s/CMSSWConfig" % self.__class__.__name__) cfgNodes = cfgIntQ(improvNode) if len(cfgNodes) > 0: cfgNode = cfgNodes[0] self.cfgInterface = CMSSWConfig() self.cfgInterface.load(cfgNode) # // # // User sandbox #// sandboxQ = IMProvQuery("/%s/UserSandbox" % self.__class__.__name__) sandboxNodes = sandboxQ(improvNode) if len(sandboxNodes) > 0: sandboxNode = sandboxNodes[-1] self.userSandbox = str(sandboxNode.chardata) return
def __init__(self, cmsswConfigData, isString=False, appControls={}): self.template = cmsswConfigData self.appControls = appControls if isString == True: self.template = CMSSWConfig() self.template.unpack(cmsswConfigData)