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.12 by ewv, Thu Sep 4 21:26:18 2008 UTC vs.
Revision 1.30 by ewv, Wed Dec 16 17:40:08 2009 UTC

# Line 10 | Line 10 | from crab_exceptions import CrabExceptio
10  
11   import common
12   import os
13 + import socket
14  
15 < # Naming convention:  Methods starting with 'ws' provide the corresponding part of the job script
16 < # ('ws' stands for 'write script').
15 > # FUTURE: for python 2.4 & 2.6
16 > try:
17 >    from hashlib import sha1
18 > except:
19 >    from sha import sha as sha1
20  
21   class SchedulerCondor(SchedulerLocal) :
22      """
23      Class to implement the vanilla (local) Condor scheduler
24 +     Naming convention:  Methods starting with 'ws' provide
25 +     the corresponding part of the job script
26 +     ('ws' stands for 'write script').
27      """
28  
29      def __init__(self):
30          SchedulerLocal.__init__(self,"CONDOR")
31          self.datasetPath   = None
32          self.selectNoInput = None
33 +        self.return_data   = 0
34 +        self.copy_data     = 0
35 +
36          self.environment_unique_identifier = None
37          return
38  
# Line 33 | Line 43 | class SchedulerCondor(SchedulerLocal) :
43          """
44  
45          SchedulerLocal.configure(self, cfg_params)
36        self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
46  
47          try:
48              tmp =  cfg_params['CMSSW.datasetpath']
# Line 47 | 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 +
62 +        self.proxyValid = 0
63 +        self.dontCheckProxy = int(cfg_params.get("GRID.dont_check_proxy", 0))
64 +        self.proxyServer = cfg_params.get("GRID.proxy_server", 'myproxy.cern.ch')
65 +        common.logger.debug('Setting myproxy server to ' + self.proxyServer)
66 +
67 +        self.group = cfg_params.get("GRID.group", None)
68 +        self.role  = cfg_params.get("GRID.role", None)
69 +        self.VO    = cfg_params.get('GRID.virtual_organization', 'cms')
70 +
71 +        self.checkProxy()
72 +
73          return
74  
75 +    def envUniqueID(self):
76 +        taskHash = sha1(common._db.queryTask('name')).hexdigest()
77 +        id = "https://" + socket.gethostname() + '/' + taskHash + "/${NJob}"
78 +        return id
79  
80      def sched_parameter(self, i, task):
81          """
82          Return scheduler-specific parameters
83          """
84 +        req = ''
85 +        if self.EDG_addJdlParam:
86 +            if self.EDG_addJdlParam[-1] == '':
87 +                self.EDG_addJdlParam = self.EDG_addJdlParam[:-1]
88 +            for p in self.EDG_addJdlParam:
89 +                req += p.strip()+';\n'
90  
91 <        index = int(common._db.nJobs()) - 1
59 <        schedParam = ''
60 <
61 <        for i in range(index):
62 <            pass
63 <
64 <        return schedParam
91 >        return req
92  
93  
94      def realSchedParams(self, cfg_params):
# Line 70 | Line 97 | class SchedulerCondor(SchedulerLocal) :
97          """
98  
99          tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
100 <        params = {'tmpDir':tmpDir}
100 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
101 >        jobDir = common.work_space.jobDir()
102 >        params = {'tmpDir':tmpDir,
103 >                  'jobDir':jobDir}
104          return params
105  
106  
# Line 79 | Line 109 | class SchedulerCondor(SchedulerLocal) :
109          Check the compatibility of available resources
110          """
111  
112 <        if self.selectNoInput:
83 <            return [True]
84 <        else:
85 <            return SchedulerLocal.listMatch(self, seList, full)
112 >        return [True]
113  
114  
115      def decodeLogInfo(self, fileName):
# Line 96 | Line 123 | class SchedulerCondor(SchedulerLocal) :
123          return reason
124  
125  
126 +    def wsCopyOutput(self):
127 +        """
128 +        Write a CopyResults part of a job script, e.g.
129 +        to copy produced output into a storage element.
130 +        """
131 +        txt = self.wsCopyOutput_comm()
132 +        return txt
133 +
134 +
135      def wsExitFunc(self):
136          """
137          Returns the part of the job script which runs prior to exit
# Line 128 | Line 164 | class SchedulerCondor(SchedulerLocal) :
164          txt += 'printenv | sort\n'
165  
166          txt += 'middleware='+self.name()+' \n'
167 +        txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n'
168 +        txt += '  export PATH=${PATH}:/opt/d-cache/srm/bin\n'
169 +        txt += 'fi\n'
170 +
171          txt += """
172   if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
173      echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
# Line 140 | Line 180 | fi
180   """
181  
182          return txt
183 +
184 +
185 +    def sched_fix_parameter(self):
186 +        """
187 +        Returns string with requirements and scheduler-specific parameters
188 +        """
189 +
190 +        if self.EDG_requirements:
191 +            req = self.EDG_requirements
192 +            taskReq = {'commonRequirements':req}
193 +            common._db.updateTask_(taskReq)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines