1 |
spiga |
1.8 |
__revision__ = "$Id: SchedulerCondor.py,v 1.7 2008/06/10 17:46:00 ewv Exp $"
|
2 |
|
|
__version__ = "$Revision: 1.7 $"
|
3 |
ewv |
1.1 |
|
4 |
|
|
from Scheduler import Scheduler
|
5 |
|
|
from SchedulerLocal import SchedulerLocal
|
6 |
|
|
from crab_exceptions import *
|
7 |
|
|
from crab_util import *
|
8 |
|
|
from crab_logger import Logger
|
9 |
|
|
import common
|
10 |
|
|
|
11 |
|
|
import os
|
12 |
|
|
|
13 |
|
|
# Naming convention:
|
14 |
|
|
# methods starting with 'ws' are responsible to provide
|
15 |
|
|
# corresponding part of the job script ('ws' stands for 'write script').
|
16 |
|
|
|
17 |
|
|
class SchedulerCondor(SchedulerLocal) :
|
18 |
|
|
|
19 |
|
|
def __init__(self):
|
20 |
|
|
Scheduler.__init__(self,"CONDOR")
|
21 |
|
|
return
|
22 |
|
|
|
23 |
ewv |
1.3 |
|
24 |
ewv |
1.1 |
def configure(self, cfg_params):
|
25 |
|
|
SchedulerLocal.configure(self, cfg_params)
|
26 |
|
|
self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
|
27 |
ewv |
1.7 |
|
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)
|
39 |
|
|
|
40 |
ewv |
1.1 |
return
|
41 |
|
|
|
42 |
ewv |
1.3 |
|
43 |
ewv |
1.1 |
def sched_parameter(self,i,task):
|
44 |
|
|
"""
|
45 |
|
|
Return scheduler-specific parameters
|
46 |
|
|
"""
|
47 |
|
|
index = int(common._db.nJobs()) - 1
|
48 |
|
|
sched_param= ''
|
49 |
|
|
|
50 |
|
|
for i in range(index):
|
51 |
|
|
pass
|
52 |
|
|
|
53 |
|
|
return sched_param
|
54 |
|
|
|
55 |
ewv |
1.3 |
|
56 |
ewv |
1.2 |
def realSchedParams(self,cfg_params):
|
57 |
|
|
"""
|
58 |
|
|
Return dictionary with specific parameters, to use
|
59 |
|
|
with real scheduler
|
60 |
|
|
"""
|
61 |
|
|
|
62 |
|
|
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
|
63 |
|
|
params = {'tmpDir':tmpDir}
|
64 |
|
|
return params
|
65 |
|
|
|
66 |
ewv |
1.3 |
|
67 |
ewv |
1.7 |
def listMatch(self, seList, full, onlyOSG=True):
|
68 |
|
|
"""
|
69 |
|
|
Check the compatibility of available resources
|
70 |
|
|
"""
|
71 |
|
|
|
72 |
|
|
# May have problems with onlyOSG being false, probably due to lengths of lists and command line.
|
73 |
|
|
# Either re-write osg_bdii.py with a proper ldap library or break the queries apart
|
74 |
|
|
|
75 |
|
|
#scram = Scram.Scram(None)
|
76 |
|
|
#versionCMSSW = scram.getSWVersion()
|
77 |
|
|
#arch = scram.getArch()
|
78 |
|
|
|
79 |
|
|
if self.selectNoInput:
|
80 |
|
|
return [True]
|
81 |
|
|
|
82 |
|
|
|
83 |
ewv |
1.4 |
def decodeLogInfo(self, file):
|
84 |
|
|
"""
|
85 |
|
|
Parse logging info file and return main info
|
86 |
|
|
"""
|
87 |
|
|
import CondorGLoggingInfo
|
88 |
|
|
loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
|
89 |
|
|
reason = loggingInfo.decodeReason(file)
|
90 |
|
|
return reason
|
91 |
ewv |
1.3 |
|
92 |
|
|
|
93 |
|
|
def wsExitFunc(self):
|
94 |
|
|
"""
|
95 |
|
|
"""
|
96 |
|
|
txt = '\n'
|
97 |
|
|
txt += '#\n'
|
98 |
|
|
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
|
99 |
|
|
txt += '#\n\n'
|
100 |
|
|
|
101 |
|
|
txt += 'func_exit() { \n'
|
102 |
spiga |
1.8 |
txt += self.wsExitFunc_common()
|
103 |
|
|
|
104 |
ewv |
1.3 |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n'
|
105 |
|
|
txt += ' cp ${out_files}.tgz $ORIG_WD/\n'
|
106 |
|
|
txt += ' cp crab_fjr_$NJob.xml $ORIG_WD/\n'
|
107 |
|
|
|
108 |
|
|
txt += ' exit $job_exit_code\n'
|
109 |
|
|
txt += '}\n'
|
110 |
|
|
|
111 |
|
|
return txt
|
112 |
ewv |
1.5 |
|
113 |
|
|
def wsInitialEnvironment(self):
|
114 |
|
|
"""
|
115 |
|
|
Returns part of a job script which does scheduler-specific work.
|
116 |
|
|
"""
|
117 |
|
|
|
118 |
|
|
txt = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
|
119 |
|
|
txt += 'echo "Beginning environment"\n'
|
120 |
|
|
txt += 'printenv | sort\n'
|
121 |
|
|
|
122 |
|
|
txt += 'middleware='+self.name()+' \n'
|
123 |
|
|
txt += """
|
124 |
ewv |
1.6 |
if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
|
125 |
|
|
ORIG_WD=`pwd`
|
126 |
|
|
echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
|
127 |
|
|
if [ -e ../default.tgz ] ;then
|
128 |
|
|
echo "Found ISB in parent directory (Local Condor)"
|
129 |
|
|
cp ../default.tgz $_CONDOR_SCRATCH_DIR
|
130 |
|
|
fi
|
131 |
|
|
cd $_CONDOR_SCRATCH_DIR
|
132 |
|
|
fi
|
133 |
|
|
"""
|
134 |
ewv |
1.5 |
|
135 |
|
|
return txt
|