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.2 by ewv, Wed May 21 19:27:30 2008 UTC vs.
Revision 1.17 by ewv, Mon Feb 9 21:16:34 2009 UTC

# Line 1 | Line 1
1 + """
2 + Implements the vanilla (local) Condor scheduler
3 + """
4 +
5   __revision__ = "$Id$"
6   __version__ = "$Revision$"
7  
8 < from Scheduler import Scheduler
9 < from SchedulerLocal import SchedulerLocal
6 < from crab_exceptions import *
7 < from crab_util import *
8 < from crab_logger import Logger
9 < import common
8 > from SchedulerLocal  import SchedulerLocal
9 > from crab_exceptions import CrabException
10  
11 + import common
12   import os
13 <
14 < #  Naming convention:
14 < #  methods starting with 'ws' are responsible to provide
15 < #  corresponding part of the job script ('ws' stands for 'write script').
13 > import socket
14 > import sha
15  
16   class SchedulerCondor(SchedulerLocal) :
18
19  def __init__(self):
20    Scheduler.__init__(self,"CONDOR")
21    return
22
23  def configure(self, cfg_params):
24    SchedulerLocal.configure(self, cfg_params)
25    self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
26    return
27
28  def sched_parameter(self,i,task):
17      """
18 <    Return scheduler-specific parameters
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      """
32    index = int(common._db.nJobs()) - 1
33    sched_param= ''
34
35    for i in range(index):
36      pass
37
38    return sched_param
23  
24 <  def realSchedParams(self,cfg_params):
25 <    """
26 <    Return dictionary with specific parameters, to use
27 <    with real scheduler
28 <    """
24 >    def __init__(self):
25 >        SchedulerLocal.__init__(self,"CONDOR")
26 >        self.datasetPath   = None
27 >        self.selectNoInput = None
28 >        self.environment_unique_identifier = None
29 >        return
30 >
31 >
32 >    def configure(self, cfg_params):
33 >        """
34 >        Configure the scheduler with the config settings from the user
35 >        """
36 >
37 >        SchedulerLocal.configure(self, cfg_params)
38 >        taskHash = sha.new(common._db.queryTask('name')).hexdigest()
39 >        self.environment_unique_identifier = "https://" + socket.gethostname() + \
40 >                                              '/' + taskHash + "/${NJob}"
41 >
42 >        try:
43 >            tmp =  cfg_params['CMSSW.datasetpath']
44 >            if tmp.lower() == 'none':
45 >                self.datasetPath = None
46 >                self.selectNoInput = 1
47 >            else:
48 >                self.datasetPath = tmp
49 >                self.selectNoInput = 0
50 >        except KeyError:
51 >            msg = "Error: datasetpath not defined "
52 >            raise CrabException(msg)
53 >
54 >        self.return_data = cfg_params.get('USER.return_data', 0)
55 >        self.copy_data   = cfg_params.get("USER.copy_data", 0)
56 >
57 >        if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ):
58 >            msg = 'Error: return_data and copy_data cannot be set both to 0\n'
59 >            msg = msg + 'Please modify your crab.cfg file\n'
60 >            raise CrabException(msg)
61 >
62 >        if ( int(self.return_data) == 1 and int(self.copy_data) == 1 ):
63 >            msg = 'Error: return_data and copy_data cannot be set both to 1\n'
64 >            msg = msg + 'Please modify your crab.cfg file\n'
65 >            raise CrabException(msg)
66 >
67 >        if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ):
68 >            msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n'
69 >            msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
70 >            common.logger.message(msg)
71 >            raise CrabException(msg)
72 >
73 >        if int(self.copy_data) == 1:
74 >            self.SE = cfg_params.get('USER.storage_element', None)
75 >            if not self.SE:
76 >                msg = "Error. The [USER] section has no 'storage_element'"
77 >                common.logger.message(msg)
78 >                raise CrabException(msg)
79 >
80 >            self.proxyValid = 0
81 >            self.dontCheckProxy = int(cfg_params.get("EDG.dont_check_proxy",0))
82 >            self.proxyServer = cfg_params.get("EDG.proxy_server",'myproxy.cern.ch')
83 >            common.logger.debug(5,'Setting myproxy server to ' + self.proxyServer)
84 >
85 >            self.group = cfg_params.get("EDG.group", None)
86 >            self.role  = cfg_params.get("EDG.role", None)
87 >            self.VO    = cfg_params.get('EDG.virtual_organization', 'cms')
88 >
89 >            self.checkProxy()
90 >        self.role  = None
91 >
92 >        return
93 >
94 >
95 >    def sched_parameter(self, i, task):
96 >        """
97 >        Return scheduler-specific parameters
98 >        """
99 >
100 >        index = int(common._db.nJobs()) - 1
101 >        schedParam = ''
102 >
103 >        for i in range(index):
104 >            pass
105 >
106 >        return schedParam
107 >
108 >
109 >    def realSchedParams(self, cfg_params):
110 >        """
111 >        Return dictionary with specific parameters, to use with real scheduler
112 >        """
113 >
114 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
115 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
116 >        jobDir = common.work_space.jobDir()
117 >        params = {'tmpDir':tmpDir,
118 >                  'jobDir':jobDir}
119 >        return params
120 >
121 >
122 >    def listMatch(self, seList, full):
123 >        """
124 >        Check the compatibility of available resources
125 >        """
126 >
127 >        return [True]
128 >
129 >
130 >    def decodeLogInfo(self, fileName):
131 >        """
132 >        Parse logging info file and return main info
133 >        """
134 >
135 >        import CondorGLoggingInfo
136 >        loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
137 >        reason = loggingInfo.decodeReason(fileName)
138 >        return reason
139 >
140 >
141 >    def wsCopyOutput(self):
142 >        """
143 >        Write a CopyResults part of a job script, e.g.
144 >        to copy produced output into a storage element.
145 >        """
146 >        txt = self.wsCopyOutput_comm()
147 >        return txt
148 >
149 >
150 >    def wsExitFunc(self):
151 >        """
152 >        Returns the part of the job script which runs prior to exit
153 >        """
154 >
155 >        txt = '\n'
156 >        txt += '#\n'
157 >        txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
158 >        txt += '#\n\n'
159 >
160 >        txt += 'func_exit() { \n'
161 >        txt += self.wsExitFunc_common()
162 >
163 >        txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
164 >        txt += '    cp  ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n'
165 >        txt += '    cp  crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n'
166 >
167 >        txt += '    exit $job_exit_code\n'
168 >        txt += '}\n'
169 >
170 >        return txt
171 >
172 >    def wsInitialEnvironment(self):
173 >        """
174 >        Returns part of a job script which does scheduler-specific work.
175 >        """
176 >
177 >        txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
178 >        txt += 'echo "Beginning environment"\n'
179 >        txt += 'printenv | sort\n'
180 >
181 >        txt += 'middleware='+self.name()+' \n'
182 >        txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n'
183 >        txt += '  export PATH=${PATH}:/opt/d-cache/srm/bin\n'
184 >        txt += 'fi\n'
185 >
186 >        txt += """
187 > if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
188 >    echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
189 >    if [ -e ../default.tgz ] ;then
190 >      echo "Found ISB in parent directory (Local Condor)"
191 >      cp ../default.tgz $_CONDOR_SCRATCH_DIR
192 >    fi
193 >    cd $_CONDOR_SCRATCH_DIR
194 > fi
195 > """
196  
197 <    tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
47 <    params = {'tmpDir':tmpDir}
48 <    return  params
49 <
50 <  def loggingInfo(self, id):
51 <    """ return logging info about job nj """
52 <    cmd = 'something'
53 <    #cmd_out = runCommand(cmd)
54 <    return ''
197 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines