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.23 by slacapra, Thu Nov 6 17:51:43 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 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 <            try:
77 <                outFile.write(self.cmsProcess.dumpPython())
78 <            except Exception, ex:
70 <                msg =  "Your cfg file is not valid, %s\n" % str(ex)
71 <                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#Problem_with_ParameterSet_parsin\n"
72 <                msg += "  may help you understand the problem."
73 <                raise CrabException(msg)
74 <
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(self.cfg.data.dumpConfig())
81          outFile.close()
82  
83          return
84  
81    def addCrabFJR(self,name):
82        """
83        _addCrabFJR_
84        add CRAB specific FrameworkJobReport (FJR)
85        if a FJR already exists in input CMSSW parameter-set, add a second one.
86        This code is not needed for CMSSW >= 1.5.x and is non-functional in CMSSW >= 1.7.x.
87        It should be removed at some point in the future.
88        """
89
90        # Check if MessageLogger service already exists in configuration. If not, add it
91        svcs = self.cfg.data.services
92        if not svcs.has_key('MessageLogger'):
93            self.cfg.data.add_(CfgModules.Service("MessageLogger"))
94
95        messageLogger = self.cfg.data.services['MessageLogger']
96
97        # Add fwkJobReports to Message logger if it doesn't exist
98        if "fwkJobReports" not in messageLogger.parameterNames_():
99            messageLogger.fwkJobReports = CfgTypes.untracked(CfgTypes.vstring())
100
101        # should figure out how to remove "name" if it is there.
102
103        if name not in messageLogger.fwkJobReports:
104            messageLogger.fwkJobReports.append(name)
105
106        return
107
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 123 | 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