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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines