7 |
|
|
8 |
|
from SchedulerLocal import SchedulerLocal |
9 |
|
from crab_exceptions import CrabException |
10 |
– |
#from crab_logger import Logger |
10 |
|
|
11 |
|
import common |
12 |
|
import os |
13 |
|
|
15 |
– |
# Naming convention: Methods starting with 'ws' provide the corresponding part of the job script |
16 |
– |
# ('ws' stands for 'write script'). |
14 |
|
|
15 |
|
class SchedulerCondor(SchedulerLocal) : |
16 |
|
""" |
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 |
|
""" |
22 |
|
|
23 |
|
def __init__(self): |
34 |
|
""" |
35 |
|
|
36 |
|
SchedulerLocal.configure(self, cfg_params) |
37 |
< |
self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name') |
37 |
> |
self.environment_unique_identifier = '${HOSTNAME}_${CONDOR_ID}_' \ |
38 |
> |
+ common._db.queryTask('name') |
39 |
|
|
40 |
|
try: |
41 |
|
tmp = cfg_params['CMSSW.datasetpath'] |
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 |
+ |
self.role = None |
89 |
+ |
|
90 |
|
return |
91 |
|
|
92 |
|
|
110 |
|
""" |
111 |
|
|
112 |
|
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
113 |
< |
params = {'tmpDir':tmpDir} |
113 |
> |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
114 |
> |
jobDir = common.work_space.jobDir() |
115 |
> |
params = {'tmpDir':tmpDir, |
116 |
> |
'jobDir':jobDir} |
117 |
|
return params |
118 |
|
|
119 |
|
|
122 |
|
Check the compatibility of available resources |
123 |
|
""" |
124 |
|
|
125 |
< |
if self.selectNoInput: |
84 |
< |
return [True] |
85 |
< |
else: |
86 |
< |
return SchedulerLocal.listMatch(self, seList, full) |
125 |
> |
return [True] |
126 |
|
|
127 |
|
|
128 |
|
def decodeLogInfo(self, fileName): |
136 |
|
return reason |
137 |
|
|
138 |
|
|
139 |
+ |
def wsCopyOutput(self): |
140 |
+ |
""" |
141 |
+ |
Write a CopyResults part of a job script, e.g. |
142 |
+ |
to copy produced output into a storage element. |
143 |
+ |
""" |
144 |
+ |
txt = self.wsCopyOutput_comm() |
145 |
+ |
return txt |
146 |
+ |
|
147 |
+ |
|
148 |
|
def wsExitFunc(self): |
149 |
|
""" |
150 |
|
Returns the part of the job script which runs prior to exit |
159 |
|
txt += self.wsExitFunc_common() |
160 |
|
|
161 |
|
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
162 |
< |
txt += ' cp ${out_files}.tgz $ORIG_WD/\n' |
163 |
< |
txt += ' cp crab_fjr_$NJob.xml $ORIG_WD/\n' |
162 |
> |
txt += ' cp ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n' |
163 |
> |
txt += ' cp crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n' |
164 |
|
|
165 |
|
txt += ' exit $job_exit_code\n' |
166 |
|
txt += '}\n' |
177 |
|
txt += 'printenv | sort\n' |
178 |
|
|
179 |
|
txt += 'middleware='+self.name()+' \n' |
180 |
+ |
txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n' |
181 |
+ |
txt += ' export PATH=${PATH}:/opt/d-cache/srm/bin\n' |
182 |
+ |
txt += 'fi\n' |
183 |
+ |
|
184 |
|
txt += """ |
185 |
|
if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then |
186 |
< |
ORIG_WD=`pwd` |
135 |
< |
echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR" |
186 |
> |
echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR" |
187 |
|
if [ -e ../default.tgz ] ;then |
188 |
|
echo "Found ISB in parent directory (Local Condor)" |
189 |
|
cp ../default.tgz $_CONDOR_SCRATCH_DIR |