ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PsetManipulator.py
(Generate patch)

Comparing COMP/CRAB/python/PsetManipulator.py (file contents):
Revision 1.18 by slacapra, Wed Jun 11 17:55:30 2008 UTC vs.
Revision 1.26 by ewv, Tue Feb 24 16:19:25 2009 UTC

# Line 26 | Line 26 | class PsetManipulator:
26          #convert Pset
27          from FWCore.ParameterSet.Config import include
28          common.logger.debug(3,"PsetManipulator::__init__: PSet file = "+self.pset)
29 +        # FUTURE: Can drop cfg mode for CMSSW < 2_1_x
30          if self.pset.endswith('py'):
31              handle = open(self.pset, 'r')
32              try:   # Nested form for Python < 2.5
# Line 43 | Line 44 | class PsetManipulator:
44                  self.cmsProcess = self.cfo
45              except Exception, ex:
46                  msg =  "Your cfg file is not valid, %s\n" % str(ex)
47 <                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/CrabFaq#Problem_with_ParameterSet_parsin\n"
47 >                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#Problem_with_ParameterSet_parsin\n"
48                  msg += "  may help you understand the problem."
49                  raise CrabException(msg)
50          self.cfg = CfgInterface(self.cmsProcess)
# Line 55 | Line 56 | class PsetManipulator:
56          self.cfg.maxEvents.setMaxEventsInput(maxEv)
57          return
58  
59 +    def skipEvent(self, skipEv):
60 +        """
61 +        Set max event in the standalone untracked module
62 +        """
63 +        self.cfg.inputSource.setSkipEvents(skipEv)
64 +        return
65 +
66      def psetWriter(self, name):
67          """
68          Write out modified CMSSW.cfg
# Line 64 | Line 72 | class PsetManipulator:
72          outFile = open(common.work_space.jobDir()+name,"w")
73          if name.endswith('py'):
74              outFile.write("import FWCore.ParameterSet.Config as cms\n")
75 <            outFile.write(self.cmsProcess.dumpPython())
75 >            try:
76 >                outFile.write(self.cmsProcess.dumpPython())
77 >            except Exception, ex:
78 >                msg =  "Your cfg file is not valid, %s\n" % str(ex)
79 >                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#Problem_with_ParameterSet_parsin\n"
80 >                msg += "  may help you understand the problem."
81 >                raise CrabException(msg)
82 >
83          else:
84 <            outFile.write(str(self.cfg))
84 >            outFile.write(self.cfg.data.dumpConfig())
85          outFile.close()
86  
87          return
88  
74    def addCrabFJR(self,name):
75        """
76        _addCrabFJR_
77        add CRAB specific FrameworkJobReport (FJR)
78        if a FJR already exists in input CMSSW parameter-set, add a second one.
79        This code is not needed for CMSSW >= 1.5.x and is non-functional in CMSSW >= 1.7.x.
80        It should be removed at some point in the future.
81        """
82
83        # Check if MessageLogger service already exists in configuration. If not, add it
84        svcs = self.cfg.data.services
85        if not svcs.has_key('MessageLogger'):
86            self.cfg.data.add_(CfgModules.Service("MessageLogger"))
87
88        messageLogger = self.cfg.data.services['MessageLogger']
89
90        # Add fwkJobReports to Message logger if it doesn't exist
91        if "fwkJobReports" not in messageLogger.parameterNames_():
92            messageLogger.fwkJobReports = CfgTypes.untracked(CfgTypes.vstring())
93
94        # should figure out how to remove "name" if it is there.
95
96        if name not in messageLogger.fwkJobReports:
97            messageLogger.fwkJobReports.append(name)
98
99        return
100
89      def getTFileService(self):
90          """ Get Output filename from TFileService and return it. If not existing, return None """
91          if not self.cfg.data.services.has_key('TFileService'):
# Line 107 | Line 95 | class PsetManipulator:
95              fileName = getattr(tFileService,'fileName',None).value()
96              return fileName
97          return None
98 <        
99 <        #fileName
98 >
99 >    def getPoolOutputModule(self):
100 >        """ Get Output filename from PoolOutputModule and return it. If not existing, return None """
101 >        if not self.cfg.data.outputModules:
102 >            return None
103 >        poolOutputModule = self.cfg.data.outputModules
104 >        for out in poolOutputModule:
105 >            return poolOutputModule[out].fileName.value()
106  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines