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

Comparing COMP/CRAB/python/SchedulerEdg.py (file contents):
Revision 1.31 by slacapra, Tue Dec 6 13:18:48 2005 UTC vs.
Revision 1.37 by fanzago, Wed Feb 15 13:36:01 2006 UTC

# Line 64 | Line 64 | class SchedulerEdg(Scheduler):
64              self.register_data = cfg_params["USER.register_data"]
65              if int(self.register_data) == 1:
66                  try:
67 +                    self.lfc_host = cfg_params['EDG.lfc_host']
68 +                except KeyError:
69 +                    msg = "Error. The [EDG] section does not have 'lfc_host' value"
70 +                    msg = msg + " it's necessary to know the LFC host name"
71 +                    common.logger.message(msg)
72 +                    raise CrabException(msg)
73 +                try:
74 +                    self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type']
75 +                except KeyError:
76 +                    msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value"
77 +                    msg = msg + " it's necessary to know the catalog type"
78 +                    common.logger.message(msg)
79 +                    raise CrabException(msg)
80 +                try:
81 +                    self.lfc_home = cfg_params['EDG.lfc_home']
82 +                except KeyError:
83 +                    msg = "Error. The [EDG] section does not have 'lfc_home' value"
84 +                    msg = msg + " it's necessary to know the home catalog dir"
85 +                    common.logger.message(msg)
86 +                    raise CrabException(msg)
87 +                try:
88                      self.LFN = cfg_params['USER.lfn_dir']
89                  except KeyError:
90                      msg = "Error. The [USER] section does not have 'lfn_dir' value"
91 <                    msg = msg + " it's necessary for RLS registration"
91 >                    msg = msg + " it's necessary for LCF registration"
92                      common.logger.message(msg)
93                      raise CrabException(msg)
94 +                
95 +                              
96          except KeyError: self.register_data = 0
97  
98          if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ):
# Line 138 | Line 161 | class SchedulerEdg(Scheduler):
161                txt += 'echo "SE_PATH = $SE_PATH"\n'
162                                                                                                                                                              
163          if int(self.register_data) == 1:
164 <           if self.VO:
165 <              txt += 'export VO='+self.VO+'\n'
166 <           if self.LFN:
167 <              txt += 'export LFN='+self.LFN+'\n'
168 <              txt += '\n'
164 >           txt += 'export VO='+self.VO+'\n'
165 >           ### FEDE: add some line for LFC catalog setting
166 >           txt += 'if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
167 >           txt += '   export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
168 >           txt += 'fi\n'
169 >           txt += 'if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
170 >           txt += 'export LFC_HOST='+self.lfc_host+'\n'
171 >           txt += 'fi\n'
172 >           txt += 'if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
173 >           txt += 'export LFC_HOME='+self.lfc_home+'\n'
174 >           txt += 'fi\n'
175 >           #####
176 >           txt += 'export LFN='+self.LFN+'\n'
177 >           txt += 'lfc-ls $LFN\n'
178 >           txt += 'result=$?\n'
179 >           txt += 'echo $result\n'
180 >           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
181 >           txt += 'if [ $result != 0 ]; then\n'
182 >           txt += '   lfc-mkdir $LFN\n'
183 >           txt += '   result=$?\n'
184 >           txt += '   echo $result\n'
185 >           txt += 'fi\n'
186 >           txt += '\n'
187          txt += 'CloseCEs=`edg-brokerinfo getCE`\n'
188          txt += 'echo "CloseCEs = $CloseCEs"\n'
189          txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
# Line 161 | Line 202 | class SchedulerEdg(Scheduler):
202             txt += '#   Copy output to SE = $SE\n'
203             txt += '#\n'
204             txt += 'if [ $exe_result -eq 0 ]; then\n'
205 <           txt += '  for out_file in $file_list ; do\n'
206 <           txt += '    echo "Trying to copy output file to $SE "\n'
207 <           txt += '    echo "'+copy+'"\n'
208 <           txt += '    '+copy+' 2>&1\n'
209 <           txt += '    copy_exit_status=$?\n'
210 <           txt += '    echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
211 <           txt += '    echo "STAGE_OUT = $copy_exit_status"\n'
212 <           txt += '    if [ $copy_exit_status -ne 0 ]; then \n'
213 <           txt += '       echo "Problems with SE= $SE" \n'
214 <           txt += '    else \n'
215 <           txt += '       echo "output copied into $SE/$SE_PATH directory"\n'
216 <           txt += '    fi \n'
217 <           txt += '  done\n'
218 <           txt += 'fi \n'
205 >           txt += '    for out_file in $file_list ; do\n'
206 >           txt += '        echo "Trying to copy output file to $SE "\n'
207 >           txt += '        echo "lcg-cp --vo cms -t 30 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
208 > #           txt += '        echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
209 >           txt += '        exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
210 > #           txt += '        exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
211 >           txt += '        copy_exit_status=$?\n'
212 >           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
213 >           txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
214 >           txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
215 >           txt += '            echo "Problems with SE = $SE"\n'
216 >           txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
217 >           txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
218 >           txt += '        else\n'
219 >           txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
220 >           txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
221 >           txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
222 >           txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
223 >           txt += '         fi\n'
224 >           txt += '     done\n'
225 >           txt += 'fi\n'
226          return txt
227  
228      def wsRegisterOutput(self):
# Line 185 | Line 233 | class SchedulerEdg(Scheduler):
233          txt = ''
234          if int(self.register_data) == 1:
235             txt += '#\n'
236 <           txt += '#  Register output to RLS\n'
236 >           txt += '#  Register output to LFC\n'
237             txt += '#\n'
238             txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
239             txt += '   for out_file in $file_list ; do\n'
240 <           txt += '      echo "Trying to register the output file into RLS"\n'
240 >           txt += '      echo "Trying to register the output file into LFC"\n'
241             txt += '      echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
242             txt += '      lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
243             txt += '      register_exit_status=$?\n'
244             txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
245             txt += '      echo "STAGE_OUT = $register_exit_status"\n'
246             txt += '      if [ $register_exit_status -ne 0 ]; then \n'
247 <           txt += '         echo "Problems with the registration to RLS" \n'
247 >           txt += '         echo "Problems with the registration to LFC" \n'
248             txt += '         echo "Try with srm protocol" \n'
249             txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
250             txt += '         lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
# Line 204 | Line 252 | class SchedulerEdg(Scheduler):
252             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
253             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
254             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
255 <           txt += '            echo "Problems with the registration into RLS" \n'
255 >           txt += '            echo "Problems with the registration into LFC" \n'
256             txt += '         fi \n'
257             txt += '      else \n'
258 <           txt += '         echo "output registered to RLS"\n'
258 >           txt += '         echo "output registered to LFC"\n'
259             txt += '      fi \n'
260 +           txt += '      echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
261             txt += '   done\n'
262             txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
263             txt += '   echo "Trying to copy output file to CloseSE"\n'
# Line 226 | Line 275 | class SchedulerEdg(Scheduler):
275             txt += '         echo "SE = $CLOSE_SE"\n'
276             txt += '         echo "LFN for the file is LFN=${LFN}/$out_file"\n'
277             txt += '      fi \n'
278 +           txt += '      echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
279             txt += '   done\n'
280             txt += 'else\n'
281             txt += '   echo "Problem with the executable"\n'
# Line 237 | Line 287 | class SchedulerEdg(Scheduler):
287          retrieve the logging info from logging and bookkeeping and return it
288          """
289          self.checkProxy()
240      #  id = common.jobDB.jobId(nj)
290          cmd = 'edg-job-get-logging-info -v 2 ' + id
291 <        cmd_out = os.popen(cmd)
292 <      #  cmd_out = runCommand(cmd)
291 >        #cmd_out = os.popen(cmd)
292 >        cmd_out = runCommand(cmd)
293          return cmd_out
294  
295      def listMatch(self, nj):
# Line 250 | Line 299 | class SchedulerEdg(Scheduler):
299          self.checkProxy()
300          jdl = common.job_list[nj].jdlFilename()
301          cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
302 <        # myCmd = os.popen(cmd)
254 <        # cmd_out = myCmd.readlines()
255 <        # myCmd.close()
256 <        cmd_out = runCommand(cmd,0,240)
302 >        cmd_out = runCommand(cmd,0,10)
303          return self.parseListMatch_(cmd_out, jdl)
304  
305      def parseListMatch_(self, out, jdl):
# Line 349 | Line 395 | class SchedulerEdg(Scheduler):
395              pass
396          return jid
397  
398 +    def resubmit(self, nj_list):
399 +        """
400 +        Prepare jobs to be submit
401 +        """
402 +        return
403 +
404      def getExitStatus(self, id):
405          return self.getStatusAttribute_(id, 'exit_code')
406  
# Line 456 | Line 508 | class SchedulerEdg(Scheduler):
508  
509          #if common.use_jam:
510          #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
511 +        # Marco (VERY TEMPORARY ML STUFF)
512 +        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
513 +                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
514 +                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
515 +                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
516 +        # End Marco
517  
518          for addFile in jbt.additional_inbox_files:
519              addFile = os.path.abspath(addFile)
# Line 533 | Line 591 | class SchedulerEdg(Scheduler):
591          timeleft = -999
592          minTimeLeft=10 # in hours
593          cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00'
594 <        try: cmd_out = runCommand(cmd,0)
595 <        except: print cmd_out
596 <        if (cmd_out == None or cmd_out=='1'):
594 >        # SL Here I have to use os.system since the stupid command exit with >0 if no valid proxy is found
595 >        cmd_out = os.system(cmd)
596 >        if (cmd_out>0):
597              common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n")
598              cmd = 'grid-proxy-init -valid 100:00'
599              try:
600 +                # SL as above: damn it!
601                  out = os.system(cmd)
602                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
603              except:
604                  msg = "Unable to create a valid proxy!\n"
605                  raise CrabException(msg)
606 <            cmd = 'grid-proxy-info -timeleft'
607 <            cmd_out = runCommand(cmd,0)
606 >            # cmd = 'grid-proxy-info -timeleft'
607 >            # cmd_out = runCommand(cmd,0,20)
608              pass
609          self.proxyValid=1
610          return

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines