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.20 by slacapra, Mon Jun 16 15:35:53 2008 UTC vs.
Revision 1.28 by ewv, Wed May 20 16:37:01 2009 UTC

# Line 3 | Line 3
3   import os
4   import common
5   import imp
6 + import pickle
7  
8   from crab_util import *
9   from crab_exceptions import *
# Line 26 | Line 27 | class PsetManipulator:
27          #convert Pset
28          from FWCore.ParameterSet.Config import include
29          common.logger.debug(3,"PsetManipulator::__init__: PSet file = "+self.pset)
30 +        # FUTURE: Can drop cfg mode for CMSSW < 2_1_x
31          if self.pset.endswith('py'):
32              handle = open(self.pset, 'r')
33              try:   # Nested form for Python < 2.5
# Line 43 | Line 45 | class PsetManipulator:
45                  self.cmsProcess = self.cfo
46              except Exception, ex:
47                  msg =  "Your cfg file is not valid, %s\n" % str(ex)
48 <                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/CrabFaq#Problem_with_ParameterSet_parsin\n"
48 >                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#Problem_with_ParameterSet_parsin\n"
49                  msg += "  may help you understand the problem."
50                  raise CrabException(msg)
51          self.cfg = CfgInterface(self.cmsProcess)
# Line 55 | Line 57 | class PsetManipulator:
57          self.cfg.maxEvents.setMaxEventsInput(maxEv)
58          return
59  
60 +    def skipEvent(self, skipEv):
61 +        """
62 +        Set max event in the standalone untracked module
63 +        """
64 +        self.cfg.inputSource.setSkipEvents(skipEv)
65 +        return
66 +
67      def psetWriter(self, name):
68          """
69          Write out modified CMSSW.cfg
# Line 64 | Line 73 | class PsetManipulator:
73          outFile = open(common.work_space.jobDir()+name,"w")
74          if name.endswith('py'):
75              outFile.write("import FWCore.ParameterSet.Config as cms\n")
76 <            outFile.write(self.cmsProcess.dumpPython())
76 >            outFile.write("import pickle\n")
77 >            outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(self.cmsProcess))
78 >            outFile.write("process = pickle.loads(pickledCfg)\n")
79          else:
80 <            outFile.write(str(self.cfg))
80 >            outFile.write(self.cfg.data.dumpConfig())
81          outFile.close()
82  
83          return
84  
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
85      def getTFileService(self):
86          """ Get Output filename from TFileService and return it. If not existing, return None """
87          if not self.cfg.data.services.has_key('TFileService'):
# Line 107 | Line 91 | class PsetManipulator:
91              fileName = getattr(tFileService,'fileName',None).value()
92              return fileName
93          return None
94 <        
94 >
95      def getPoolOutputModule(self):
96          """ Get Output filename from PoolOutputModule and return it. If not existing, return None """
97          if not self.cfg.data.outputModules:
# Line 116 | Line 100 | class PsetManipulator:
100          for out in poolOutputModule:
101              return poolOutputModule[out].fileName.value()
102  
103 +    def getBadFilesSetting(self):
104 +        setting = False
105 +        try:
106 +            if self.cfg.data.source.skipBadFiles.value():
107 +                setting = True
108 +        except AttributeError:
109 +            pass # Either no source or no setting of skipBadFiles
110 +        return setting

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines