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.15 by ewv, Tue Nov 25 22:24:23 2008 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  
13 #  Naming convention:
14 #  methods starting with 'ws' are responsible to provide
15 #  corresponding part of the job script ('ws' stands for 'write script').
14  
15   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):
16      """
17 <    Return scheduler-specific parameters
17 >    Class to implement the vanilla (local) Condor scheduler
18 >     Naming convention:  Methods starting with 'ws' provide
19 >     the corresponding part of the job script
20 >     ('ws' stands for 'write script').
21      """
32    index = int(common._db.nJobs()) - 1
33    sched_param= ''
22  
23 <    for i in range(index):
24 <      pass
25 <
26 <    return sched_param
27 <
28 <  def realSchedParams(self,cfg_params):
29 <    """
30 <    Return dictionary with specific parameters, to use
31 <    with real scheduler
32 <    """
23 >    def __init__(self):
24 >        SchedulerLocal.__init__(self,"CONDOR")
25 >        self.datasetPath   = None
26 >        self.selectNoInput = None
27 >        self.environment_unique_identifier = None
28 >        return
29 >
30 >
31 >    def configure(self, cfg_params):
32 >        """
33 >        Configure the scheduler with the config settings from the user
34 >        """
35 >
36 >        SchedulerLocal.configure(self, cfg_params)
37 >        self.environment_unique_identifier = '${HOSTNAME}_${CONDOR_ID}_' \
38 >                                             + common._db.queryTask('name')
39 >
40 >        try:
41 >            tmp =  cfg_params['CMSSW.datasetpath']
42 >            if tmp.lower() == 'none':
43 >                self.datasetPath = None
44 >                self.selectNoInput = 1
45 >            else:
46 >                self.datasetPath = tmp
47 >                self.selectNoInput = 0
48 >        except KeyError:
49 >            msg = "Error: datasetpath not defined "
50 >            raise CrabException(msg)
51 >
52 >        self.return_data = cfg_params.get('USER.return_data', 0)
53 >        self.copy_data   = cfg_params.get("USER.copy_data", 0)
54 >
55 >        if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ):
56 >            msg = 'Error: return_data and copy_data cannot be set both to 0\n'
57 >            msg = msg + 'Please modify your crab.cfg file\n'
58 >            raise CrabException(msg)
59 >
60 >        if ( int(self.return_data) == 1 and int(self.copy_data) == 1 ):
61 >            msg = 'Error: return_data and copy_data cannot be set both to 1\n'
62 >            msg = msg + 'Please modify your crab.cfg file\n'
63 >            raise CrabException(msg)
64 >
65 >        if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ):
66 >            msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n'
67 >            msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
68 >            common.logger.message(msg)
69 >            raise CrabException(msg)
70 >
71 >        if int(self.copy_data) == 1:
72 >            self.SE = cfg_params.get('USER.storage_element', None)
73 >            if not self.SE:
74 >                msg = "Error. The [USER] section has no 'storage_element'"
75 >                common.logger.message(msg)
76 >                raise CrabException(msg)
77 >
78 >            self.proxyValid = 0
79 >            self.dontCheckProxy = int(cfg_params.get("EDG.dont_check_proxy",0))
80 >            self.proxyServer = cfg_params.get("EDG.proxy_server",'myproxy.cern.ch')
81 >            common.logger.debug(5,'Setting myproxy server to ' + self.proxyServer)
82 >
83 >            self.group = cfg_params.get("EDG.group", None)
84 >            self.role  = cfg_params.get("EDG.role", None)
85 >            self.VO    = cfg_params.get('EDG.virtual_organization', 'cms')
86 >
87 >            self.checkProxy()
88 >
89 >        return
90 >
91 >
92 >    def sched_parameter(self, i, task):
93 >        """
94 >        Return scheduler-specific parameters
95 >        """
96 >
97 >        index = int(common._db.nJobs()) - 1
98 >        schedParam = ''
99 >
100 >        for i in range(index):
101 >            pass
102 >
103 >        return schedParam
104 >
105 >
106 >    def realSchedParams(self, cfg_params):
107 >        """
108 >        Return dictionary with specific parameters, to use with real scheduler
109 >        """
110 >
111 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
112 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
113 >        jobDir = common.work_space.jobDir()
114 >        params = {'tmpDir':tmpDir,
115 >                  'jobDir':jobDir}
116 >        return params
117 >
118 >
119 >    def listMatch(self, seList, full):
120 >        """
121 >        Check the compatibility of available resources
122 >        """
123 >
124 >        if self.selectNoInput:
125 >            return [True]
126 >        else:
127 >            return SchedulerLocal.listMatch(self, seList, full)
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