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

Comparing COMP/CRAB/python/SchedulerCondor.py (file contents):
Revision 1.10 by ewv, Tue Aug 5 18:48:52 2008 UTC vs.
Revision 1.19 by ewv, Thu Feb 19 21:15:01 2009 UTC

# Line 7 | Line 7 | __version__ = "$Revision$"
7  
8   from SchedulerLocal  import SchedulerLocal
9   from crab_exceptions import CrabException
10 #from crab_logger import Logger
10  
11   import common
12   import os
13 <
14 < # Naming convention:  Methods starting with 'ws' provide the corresponding part of the job script
16 < # ('ws' stands for 'write script').
13 > import socket
14 > import sha
15  
16   class SchedulerCondor(SchedulerLocal) :
17      """
18      Class to implement the vanilla (local) Condor scheduler
19 +     Naming convention:  Methods starting with 'ws' provide
20 +     the corresponding part of the job script
21 +     ('ws' stands for 'write script').
22      """
23  
24      def __init__(self):
25          SchedulerLocal.__init__(self,"CONDOR")
26          self.datasetPath   = None
27          self.selectNoInput = None
28 +        self.backup        = ''
29 +        self.return_data   = 0
30 +        self.copy_data     = 0
31 +        self.backup_copy   = 0
32 +
33          self.environment_unique_identifier = None
34          return
35  
# Line 34 | Line 40 | class SchedulerCondor(SchedulerLocal) :
40          """
41  
42          SchedulerLocal.configure(self, cfg_params)
43 <        self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
43 >        taskHash = sha.new(common._db.queryTask('name')).hexdigest()
44 >        self.environment_unique_identifier = "https://" + \
45 >            socket.gethostname() + '/' + taskHash + "/${NJob}"
46  
47          try:
48              tmp =  cfg_params['CMSSW.datasetpath']
# Line 48 | Line 56 | class SchedulerCondor(SchedulerLocal) :
56              msg = "Error: datasetpath not defined "
57              raise CrabException(msg)
58  
59 +        self.return_data = cfg_params.get('USER.return_data', 0)
60 +        self.copy_data   = cfg_params.get("USER.copy_data", 0)
61 +        self.backup_copy = cfg_params.get('USER.backup_copy', 0)
62 +
63 +        if int(self.return_data) == 0 and int(self.copy_data) == 0:
64 +            msg =  'Error: return_data and copy_data cannot both be set to 0\n'
65 +            msg += 'Please modify your crab.cfg file\n'
66 +            raise CrabException(msg)
67 +
68 +        if int(self.return_data) == 1 and int(self.copy_data) == 1:
69 +            msg =  'Error: return_data and copy_data cannot both be set to 1\n'
70 +            msg += 'Please modify your crab.cfg file\n'
71 +            raise CrabException(msg)
72 +
73 +        if int(self.copy_data) == 0 and int(self.publish_data) == 1:
74 +            msg =  'Warning: publish_data=1 must be used with copy_data=1\n'
75 +            msg += 'Please modify the copy_data value in your crab.cfg file\n'
76 +            common.logger.message(msg)
77 +            raise CrabException(msg)
78 +
79 +        if int(self.copy_data) == 0 and int(self.backup_copy) == 1:
80 +            msg =  'Error: copy_data = 0 and backup_data = 1 ==> to use the '
81 +            msg += 'backup_copy function, the copy_data value has to be = 1\n'
82 +            msg += 'Please modify copy_data value in your crab.cfg file\n'
83 +            raise CrabException(msg)
84 +
85 +        if int(self.backup_copy) == 1 and int(self.publish_data) == 1:
86 +            msg =  'Warning: currently the publication is not supported '
87 +            msg += 'with the backup copy. Work in progress....\n'
88 +            common.logger.message(msg)
89 +            raise CrabException(msg)
90 +
91 +        if int(self.copy_data) == 1:
92 +            self.SE = cfg_params.get('USER.storage_element', None)
93 +            if not self.SE:
94 +                msg = "Error. The [USER] section has no 'storage_element'"
95 +                common.logger.message(msg)
96 +                raise CrabException(msg)
97 +
98 +            self.proxyValid = 0
99 +            self.dontCheckProxy = int(cfg_params.get("EDG.dont_check_proxy", 0))
100 +            self.proxyServer = cfg_params.get("EDG.proxy_server", 'myproxy.cern.ch')
101 +            common.logger.debug(5,'Setting myproxy server to ' + self.proxyServer)
102 +
103 +            self.group = cfg_params.get("EDG.group", None)
104 +            self.role  = cfg_params.get("EDG.role", None)
105 +            self.VO    = cfg_params.get('EDG.virtual_organization', 'cms')
106 +
107 +            self.checkProxy()
108 +
109 +        if int(self.backup_copy) == 1:
110 +            self.backup = '--backup'
111 +
112 +        self.role  = None
113 +
114          return
115  
116  
# Line 71 | Line 134 | class SchedulerCondor(SchedulerLocal) :
134          """
135  
136          tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
137 <        params = {'tmpDir':tmpDir}
137 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
138 >        jobDir = common.work_space.jobDir()
139 >        params = {'tmpDir':tmpDir,
140 >                  'jobDir':jobDir}
141          return params
142  
143  
# Line 80 | Line 146 | class SchedulerCondor(SchedulerLocal) :
146          Check the compatibility of available resources
147          """
148  
149 <        if self.selectNoInput:
84 <            return [True]
85 <        else:
86 <            return SchedulerLocal.listMatch(self, seList, full)
149 >        return [True]
150  
151  
152      def decodeLogInfo(self, fileName):
# Line 97 | Line 160 | class SchedulerCondor(SchedulerLocal) :
160          return reason
161  
162  
163 +    def wsCopyOutput(self):
164 +        """
165 +        Write a CopyResults part of a job script, e.g.
166 +        to copy produced output into a storage element.
167 +        """
168 +        txt = self.wsCopyOutput_comm()
169 +        return txt
170 +
171 +
172      def wsExitFunc(self):
173          """
174          Returns the part of the job script which runs prior to exit
# Line 111 | Line 183 | class SchedulerCondor(SchedulerLocal) :
183          txt += self.wsExitFunc_common()
184  
185          txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
186 <        txt += '    cp  ${out_files}.tgz $ORIG_WD/\n'
187 <        txt += '    cp  crab_fjr_$NJob.xml $ORIG_WD/\n'
186 >        txt += '    cp  ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n'
187 >        txt += '    cp  crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n'
188  
189          txt += '    exit $job_exit_code\n'
190          txt += '}\n'
# Line 129 | Line 201 | class SchedulerCondor(SchedulerLocal) :
201          txt += 'printenv | sort\n'
202  
203          txt += 'middleware='+self.name()+' \n'
204 +        txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n'
205 +        txt += '  export PATH=${PATH}:/opt/d-cache/srm/bin\n'
206 +        txt += 'fi\n'
207 +
208          txt += """
209   if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
210 <    ORIG_WD=`pwd`
135 <    echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
210 >    echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
211      if [ -e ../default.tgz ] ;then
212        echo "Found ISB in parent directory (Local Condor)"
213        cp ../default.tgz $_CONDOR_SCRATCH_DIR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines