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

Comparing COMP/CRAB/python/DataDiscovery.py (file contents):
Revision 1.23 by spiga, Mon Jun 9 17:50:45 2008 UTC vs.
Revision 1.31 by spiga, Tue May 26 10:23:00 2009 UTC

# Line 89 | Line 89 | class DataDiscovery:
89          """
90          Contact DBS
91          """
92
92          ## get DBS URL
93 <        dbs_url="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet"
94 <        if (self.cfg_params.has_key('CMSSW.dbs_url')):
95 <            dbs_url=self.cfg_params['CMSSW.dbs_url']
96 <
97 <        common.logger.debug(3,"Accessing DBS at: "+dbs_url)
93 >        global_url="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet"
94 >        caf_url = "http://cmsdbsprod.cern.ch/cms_dbs_caf_analysis_01/servlet/DBSServlet"
95 >        dbs_url_map  =   {'glite':    global_url,
96 >                          'glitecoll':global_url,\
97 >                          'condor':   global_url,\
98 >                          'condor_g': global_url,\
99 >                          'glidein':  global_url,\
100 >                          'lsf':      global_url,\
101 >                          'caf':      caf_url,\
102 >                          'sge':      global_url,
103 >                          'arc':      global_url
104 >                          }
105 >
106 >        dbs_url_default = dbs_url_map[(common.scheduler.name()).lower()]
107 >        dbs_url=  self.cfg_params.get('CMSSW.dbs_url', dbs_url_default)
108 >        common.logger.debug("Accessing DBS at: "+dbs_url)
109  
110          ## check if runs are selected
111          runselection = []
112          if (self.cfg_params.has_key('CMSSW.runselection')):
113              runselection = parseRange2(self.cfg_params['CMSSW.runselection'])
114  
115 <        common.logger.debug(6,"runselection is: %s"%runselection)
115 >
116 >        self.splitByRun = int(self.cfg_params.get('CMSSW.split_by_run', 0))
117 >          
118 >        self.ads = int(self.cfg_params.get('CMSSW.ads', 0))
119 >
120 >        common.logger.log(10-1,"runselection is: %s"%runselection)
121          ## service API
122          args = {}
123          args['url']     = dbs_url
124          args['level']   = 'CRITICAL'
125  
126          ## check if has been requested to use the parent info
127 <        useParent = self.cfg_params.get('CMSSW.use_parent',False)
127 >        useparent = int(self.cfg_params.get('CMSSW.use_parent',0))
128  
129          ## check if has been asked for a non default file to store/read analyzed fileBlocks  
130          defaultName = common.work_space.shareDir()+'AnalyzedBlocks.txt'  
131          fileBlocks_FileName = os.path.abspath(self.cfg_params.get('CMSSW.fileblocks_file',defaultName))
132  
133          api = DBSAPI.dbsApi.DbsApi(args)
119        try:
120            if len(runselection) <= 0 :
121                if useParent:
122                    allowedRetriveValue = ['retrive_parent',
123                                           'retrive_block',
124                                           'retrive_lumi',
125                                           'retrive_run'
126                                           ]
127                    files = api.listFiles(path=self.datasetPath, retriveList=allowedRetriveValue)
128                    common.logger.debug(5,"Set of input parameters used for DBS query : \n"+str(allowedRetriveValue))
129                    common.logger.write("Set of input parameters used for DBS query : \n"+str(allowedRetriveValue))
130                else:
131                    files = api.listDatasetFiles(self.datasetPath)
132            else :
133                files=[]
134                for arun in runselection:
135                    try:
136                        filesinrun = api.listFiles(path=self.datasetPath,retriveList=allowedRetriveValue,runNumber=arun)
137                        files.extend(filesinrun)
138                    except:
139                        msg="WARNING: problem extracting info from DBS for run %s "%arun
140                        common.logger.message(msg)
141                        pass
134  
135 <        except DbsBadRequest, msg:
144 <            raise DataDiscoveryError(msg)
145 <        except DBSError, msg:
146 <            raise DataDiscoveryError(msg)
135 >        self.files = self.queryDbs(api,path=self.datasetPath,runselection=runselection,useParent=useparent)
136  
137          anFileBlocks = []
138          if self.skipBlocks: anFileBlocks = readTXTfile(self, fileBlocks_FileName)
139  
140          # parse files and fill arrays
141 <        for file in files :
141 >        for file in self.files :
142              parList = []
143              # skip already analyzed blocks
144              fileblock = file['Block']['Name']
145              if fileblock not in anFileBlocks :
146                  filename = file['LogicalFileName']
147                  # asked retry the list of parent for the given child
148 <                if useParent: parList = [x['LogicalFileName'] for x in file['ParentList']]
148 >                if useparent==1: parList = [x['LogicalFileName'] for x in file['ParentList']]
149                  self.parent[filename] = parList
150                  if filename.find('.dat') < 0 :
151                      events    = file['NumberOfEvents']
# Line 183 | Line 172 | class DataDiscovery:
172          saveFblocks=''
173          for block in self.eventsPerBlock.keys() :
174              saveFblocks += str(block)+'\n'
175 <            common.logger.debug(6,"DBSInfo: total nevts %i in block %s "%(self.eventsPerBlock[block],block))
175 >            common.logger.log(10-1,"DBSInfo: total nevts %i in block %s "%(self.eventsPerBlock[block],block))
176          writeTXTfile(self, fileBlocks_FileName , saveFblocks)
177                        
178          if len(self.eventsPerBlock) <= 0:
# Line 192 | Line 181 | class DataDiscovery:
181                                              % self.datasetPath)
182  
183  
184 + ###########################
185 +
186 +    def queryDbs(self,api,path=None,runselection=None,useParent=None):
187 +
188 +        allowedRetriveValue = ['retrive_block', 'retrive_run']
189 +        if useParent==1 : allowedRetriveValue = allowedRetriveValue + ['retrive_parent']
190 +        try:
191 +            if len(runselection) <=0 :
192 +                if useParent==1 or self.splitByRun==1 :
193 +                    if self.ads==1 :          
194 +                        files = api.listFiles(analysisDataset=path, retriveList=allowedRetriveValue)
195 +                    else :
196 +                        files = api.listFiles(path=path, retriveList=allowedRetriveValue)
197 +                    common.logger.debug("Set of input parameters used for DBS query : \n"+str(allowedRetriveValue))
198 +                else:
199 +                    files = api.listDatasetFiles(self.datasetPath)
200 +            else :
201 +                files=[]
202 +                for arun in runselection:
203 +                    try:
204 +                        if self.ads==1 : filesinrun = api.listFiles(analysisDataset=path,retriveList=allowedRetriveValue,runNumber=arun)
205 +                        else: filesinrun = api.listFiles(path=path,retriveList=allowedRetriveValue,runNumber=arun)
206 +                        files.extend(filesinrun)
207 +                    except:
208 +                        msg="WARNING: problem extracting info from DBS for run %s "%arun
209 +                        common.logger.info(msg)
210 +                        pass
211 +
212 +        except DbsBadRequest, msg:
213 +            raise DataDiscoveryError(msg)
214 +        except DBSError, msg:
215 +            raise DataDiscoveryError(msg)
216 +
217 +        return files
218 +
219   # #################################################
220      def getMaxEvents(self):
221          """
# Line 227 | Line 251 | class DataDiscovery:
251          """
252          return self.parent        
253  
254 + # #################################################
255 +    def getListFiles(self):
256 +        """
257 +        return parent grouped by file
258 +        """
259 +        return self.files        
260 +
261   ########################################################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines