5 |
|
from SchedulerGrid import SchedulerGrid |
6 |
|
from crab_exceptions import CrabException |
7 |
|
from crab_util import runCommand |
8 |
+ |
#from WMCore.SiteScreening.BlackWhiteListParser import CEBlackWhiteListParser |
9 |
+ |
from WMCore.SiteScreening.BlackWhiteListParser import SEBlackWhiteListParser |
10 |
+ |
import Scram |
11 |
+ |
|
12 |
|
|
13 |
|
|
14 |
|
import common |
15 |
|
import os |
16 |
|
import socket |
17 |
+ |
import re |
18 |
|
|
19 |
|
# FUTURE: for python 2.4 & 2.6 |
20 |
|
try: |
32 |
|
|
33 |
|
def __init__(self): |
34 |
|
SchedulerGrid.__init__(self,"RCONDOR") |
35 |
+ |
self.rcondorHost = os.getenv('RCONDOR_HOST') |
36 |
+ |
if self.rcondorHost == None: |
37 |
+ |
raise CrabException('FATAL ERROR: env.var RCONDOR_HOST not defined') |
38 |
|
self.datasetPath = None |
39 |
|
self.selectNoInput = None |
40 |
< |
self.OSBsize = 100*1000*1000 # 100 MB |
40 |
> |
self.OSBsize = 50*1000*1000 # 50 MB |
41 |
|
|
42 |
|
self.environment_unique_identifier = None |
43 |
+ |
|
44 |
|
return |
45 |
|
|
46 |
|
|
54 |
|
self.proxyValid=0 |
55 |
|
self.dontCheckProxy=int(cfg_params.get("GRID.dont_check_proxy",0)) |
56 |
|
self.space_token = cfg_params.get("USER.space_token",None) |
57 |
< |
try: |
49 |
< |
self.proxyServer = Downloader("http://cmsdoc.cern.ch/cms/LCG/crab/config/").config("myproxy_server.conf") |
50 |
< |
self.proxyServer = self.proxyServer.strip() |
51 |
< |
if self.proxyServer is None: |
52 |
< |
raise CrabException("myproxy_server.conf retrieved but empty") |
53 |
< |
except Exception, e: |
54 |
< |
common.logger.info("Problem setting myproxy server endpoint: using myproxy.cern.ch") |
55 |
< |
common.logger.debug(e) |
56 |
< |
self.proxyServer= 'myproxy.cern.ch' |
57 |
> |
self.proxyServer= 'myproxy.cern.ch' |
58 |
|
self.group = cfg_params.get("GRID.group", None) |
59 |
|
self.role = cfg_params.get("GRID.role", None) |
60 |
|
self.VO = cfg_params.get('GRID.virtual_organization','cms') |
61 |
< |
|
61 |
> |
|
62 |
|
try: |
63 |
|
tmp = cfg_params['CMSSW.datasetpath'] |
64 |
|
if tmp.lower() == 'none': |
87 |
|
|
88 |
|
def sched_parameter(self, i, task): |
89 |
|
""" |
90 |
< |
Return scheduler-specific parameters |
90 |
> |
Return scheduler-specific parameters. Used at crab -submit time |
91 |
|
""" |
91 |
– |
req = '' |
92 |
– |
if self.EDG_addJdlParam: |
93 |
– |
if self.EDG_addJdlParam[-1] == '': |
94 |
– |
self.EDG_addJdlParam = self.EDG_addJdlParam[:-1] |
95 |
– |
for p in self.EDG_addJdlParam: |
96 |
– |
req += p.strip()+';\n' |
92 |
|
|
93 |
< |
return req |
93 |
> |
#SB paste from crab ScheduerGlidein |
94 |
> |
|
95 |
> |
jobParams = "" |
96 |
> |
|
97 |
> |
seDest = task.jobs[i-1]['dlsDestination'] |
98 |
> |
|
99 |
> |
if seDest == [''] : |
100 |
> |
seDest = self.blackWhiteListParser.expandList("T") # all of SiteDB |
101 |
> |
|
102 |
> |
seString=self.blackWhiteListParser.cleanForBlackWhiteList(seDest) |
103 |
> |
|
104 |
> |
jobParams += '+DESIRED_SEs = "'+seString+'"; ' |
105 |
> |
|
106 |
> |
scram = Scram.Scram(None) |
107 |
> |
cmsVersion = scram.getSWVersion() |
108 |
> |
scramArch = scram.getArch() |
109 |
> |
|
110 |
> |
cmsver=re.split('_', cmsVersion) |
111 |
> |
numericCmsVersion = "%s%.2d%.2d" %(cmsver[1], int(cmsver[2]), int(cmsver[3])) |
112 |
> |
|
113 |
> |
jobParams += '+DESIRED_CMSVersion ="' +cmsVersion+'";' |
114 |
> |
jobParams += '+DESIRED_CMSVersionNr ="' +numericCmsVersion+'";' |
115 |
> |
jobParams += '+DESIRED_CMSScramArch ="' +scramArch+'";' |
116 |
> |
|
117 |
> |
myschedName = self.rcondorHost |
118 |
> |
jobParams += '+Glidein_MonitorID = "https://'+ myschedName + '//$(Cluster).$(Process)"; ' |
119 |
> |
|
120 |
> |
if (self.EDG_clock_time): |
121 |
> |
jobParams += '+MaxWallTimeMins = '+self.EDG_clock_time+'; ' |
122 |
> |
else: |
123 |
> |
jobParams += '+MaxWallTimeMins = %d; ' % (60*24) |
124 |
> |
|
125 |
> |
common._db.updateTask_({'jobType':jobParams}) |
126 |
> |
|
127 |
> |
|
128 |
> |
return jobParams |
129 |
|
|
130 |
|
|
131 |
|
def realSchedParams(self, cfg_params): |
132 |
|
""" |
133 |
|
Return dictionary with specific parameters, to use with real scheduler |
134 |
+ |
is called when scheduler is initialized in Boss, i.e. at each crab command |
135 |
|
""" |
136 |
+ |
#SB this method is used to pass directory names to Boss Scheduler |
137 |
+ |
# via params dictionary |
138 |
|
|
106 |
– |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
107 |
– |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
139 |
|
jobDir = common.work_space.jobDir() |
109 |
– |
|
140 |
|
taskDir=common.work_space.topDir().split('/')[-2] |
141 |
< |
rcondorDir = "/afs/cern.ch/user/b/belforte/w0/crabtest/rc/igor/" |
142 |
< |
rcondorDir ='%s/.rcondor/mount/' % os.getenv('HOME') |
113 |
< |
tmpDir = os.path.join(rcondorDir,taskDir) |
114 |
< |
tmpDir = os.path.join(tmpDir,'condor_temp') |
141 |
> |
shareDir = common.work_space.shareDir() |
142 |
> |
#SBtmpDir = common.work_space.tmpDir() |
143 |
|
|
144 |
< |
params = {'tmpDir':tmpDir, |
145 |
< |
'jobDir':jobDir} |
144 |
> |
params = {'rcondorHost':self.rcondorHost, |
145 |
> |
'shareDir':shareDir, |
146 |
> |
#SB'tmpDir':tmpDir, |
147 |
> |
'jobDir':jobDir, |
148 |
> |
'taskDir':taskDir} |
149 |
> |
|
150 |
|
return params |
151 |
|
|
152 |
|
|
191 |
|
txt += 'func_exit() { \n' |
192 |
|
txt += self.wsExitFunc_common() |
193 |
|
|
194 |
< |
txt += ' cp ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n' |
195 |
< |
txt += ' cp crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n' |
194 |
> |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
195 |
> |
txt += ' tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n' |
196 |
> |
txt += ' rm ${out_files}.tgz\n' |
197 |
> |
txt += ' size=`expr $tmp_size`\n' |
198 |
> |
txt += ' echo "Total Output dimension: $size"\n' |
199 |
> |
txt += ' limit='+str(self.OSBsize) +' \n' |
200 |
> |
txt += ' echo "WARNING: output files size limit is set to: $limit"\n' |
201 |
> |
txt += ' if [ "$limit" -lt "$size" ]; then\n' |
202 |
> |
txt += ' exceed=1\n' |
203 |
> |
txt += ' job_exit_code=70000\n' |
204 |
> |
txt += ' echo "Output Sanbox too big. Produced output is lost "\n' |
205 |
> |
txt += ' else\n' |
206 |
> |
txt += ' exceed=0\n' |
207 |
> |
txt += ' echo "Total Output dimension $size is fine."\n' |
208 |
> |
txt += ' fi\n' |
209 |
> |
|
210 |
> |
txt += ' echo "JOB_EXIT_STATUS = $job_exit_code"\n' |
211 |
> |
txt += ' echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n' |
212 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
213 |
> |
txt += ' if [ $exceed -ne 1 ]; then\n' |
214 |
> |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
215 |
> |
txt += ' else\n' |
216 |
> |
txt += ' tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n' |
217 |
> |
txt += ' fi\n' |
218 |
> |
txt += ' python $RUNTIME_AREA/fillCrabFjr.py $RUNTIME_AREA/crab_fjr_$NJob.xml --errorcode $job_exit_code \n' |
219 |
|
|
220 |
|
txt += ' exit $job_exit_code\n' |
221 |
|
txt += '}\n' |
234 |
|
common._db.updateTask_(taskReq) |
235 |
|
|
236 |
|
|
182 |
– |
# presa di brutto da SchedulerGrid.py |
183 |
– |
""" |
184 |
– |
|
185 |
– |
def wsSetupEnvironment(self): |
186 |
– |
|
187 |
– |
#Returns part of a job script which does scheduler-specific work. |
188 |
– |
|
189 |
– |
taskId =common._db.queryTask('name') |
190 |
– |
index = int(common._db.nJobs()) |
191 |
– |
job = common.job_list[index-1] |
192 |
– |
jbt = job.type() |
193 |
– |
if not self.environment_unique_identifier: |
194 |
– |
try : |
195 |
– |
self.environment_unique_identifier = self.envUniqueID() |
196 |
– |
except : |
197 |
– |
raise CrabException('environment_unique_identifier not set') |
198 |
– |
|
199 |
– |
# start with wrapper timing |
200 |
– |
txt = 'export TIME_WRAP_INI=`date +%s` \n' |
201 |
– |
txt += 'export TIME_STAGEOUT=-2 \n\n' |
202 |
– |
txt += '# '+self.name()+' specific stuff\n' |
203 |
– |
txt += '# strip arguments\n' |
204 |
– |
txt += 'echo "strip arguments"\n' |
205 |
– |
txt += 'args=("$@")\n' |
206 |
– |
txt += 'nargs=$#\n' |
207 |
– |
txt += 'shift $nargs\n' |
208 |
– |
txt += "# job number (first parameter for job wrapper)\n" |
209 |
– |
txt += "NJob=${args[0]}; export NJob\n" |
210 |
– |
txt += "NResub=${args[1]}; export NResub\n" |
211 |
– |
txt += "NRand=`getRandSeed`; export NRand\n" |
212 |
– |
# append random code |
213 |
– |
txt += 'OutUniqueID=_$NRand\n' |
214 |
– |
txt += 'OutUniqueID=_$NResub$OutUniqueID\n' |
215 |
– |
txt += 'OutUniqueID=$NJob$OutUniqueID; export OutUniqueID\n' |
216 |
– |
txt += 'CRAB_UNIQUE_JOB_ID=%s_${OutUniqueID}; export CRAB_UNIQUE_JOB_ID\n' % taskId |
217 |
– |
txt += 'echo env var CRAB_UNIQUE_JOB_ID set to: ${CRAB_UNIQUE_JOB_ID}\n' |
218 |
– |
# if we want to prepend |
219 |
– |
#txt += 'OutUniqueID=_$NResub\n' |
220 |
– |
#txt += 'OutUniqueID=_$NJob$OutUniqueID\n' |
221 |
– |
#txt += 'OutUniqueID=$NRand$OutUniqueID; export OutUniqueID\n' |
222 |
– |
|
223 |
– |
txt += "out_files=out_files_${NJob}; export out_files\n" |
224 |
– |
txt += "echo $out_files\n" |
225 |
– |
txt += jbt.outList() |
226 |
– |
# txt += 'if [ $JobRunCount ] && [ `expr $JobRunCount - 1` -gt 0 ] && [ $Glidein_MonitorID ]; then \n' |
227 |
– |
txt += 'if [ $Glidein_MonitorID ]; then \n' |
228 |
– |
# txt += ' attempt=`expr $JobRunCount - 1` \n' |
229 |
– |
# txt += ' MonitorJobID=${NJob}_${Glidein_MonitorID}__${attempt}\n' |
230 |
– |
# txt += ' SyncGridJobId=${Glidein_MonitorID}__${attempt}\n' |
231 |
– |
txt += ' MonitorJobID=${NJob}_${Glidein_MonitorID}\n' |
232 |
– |
txt += ' SyncGridJobId=${Glidein_MonitorID}\n' |
233 |
– |
txt += 'else \n' |
234 |
– |
txt += ' MonitorJobID=${NJob}_'+self.environment_unique_identifier+'\n' |
235 |
– |
txt += ' SyncGridJobId='+self.environment_unique_identifier+'\n' |
236 |
– |
txt += 'fi\n' |
237 |
– |
txt += 'MonitorID='+taskId+'\n' |
238 |
– |
txt += 'echo "MonitorJobID=$MonitorJobID" > $RUNTIME_AREA/$repo \n' |
239 |
– |
txt += 'echo "SyncGridJobId=$SyncGridJobId" >> $RUNTIME_AREA/$repo \n' |
240 |
– |
txt += 'echo "MonitorID=$MonitorID" >> $RUNTIME_AREA/$repo\n' |
241 |
– |
|
242 |
– |
txt += 'echo ">>> GridFlavour discovery: " \n' |
243 |
– |
txt += 'if [ $OSG_GRID ]; then \n' |
244 |
– |
txt += ' middleware=OSG \n' |
245 |
– |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
246 |
– |
txt += ' SyncCE="$OSG_JOB_CONTACT"; \n' |
247 |
– |
txt += ' echo "SyncCE=$SyncCE" >> $RUNTIME_AREA/$repo ;\n' |
248 |
– |
txt += ' else\n' |
249 |
– |
txt += ' echo "not reporting SyncCE";\n' |
250 |
– |
txt += ' fi\n'; |
251 |
– |
txt += ' echo "GridFlavour=$middleware" | tee -a $RUNTIME_AREA/$repo \n' |
252 |
– |
txt += ' echo "source OSG GRID setup script" \n' |
253 |
– |
txt += ' source $OSG_GRID/setup.sh \n' |
254 |
– |
txt += 'elif [ $NORDUGRID_CE ]; then \n' # We look for $NORDUGRID_CE before $VO_CMS_SW_DIR, |
255 |
– |
txt += ' middleware=ARC \n' # because the latter is defined for ARC too |
256 |
– |
txt += ' echo "SyncCE=${NORDUGRID_CE}:2811/nordugrid-GE-${QUEUE:-queue}" >> $RUNTIME_AREA/$repo \n' |
257 |
– |
txt += ' echo "GridFlavour=$middleware" | tee -a $RUNTIME_AREA/$repo \n' |
258 |
– |
txt += 'elif [ $VO_CMS_SW_DIR ]; then \n' |
259 |
– |
txt += ' middleware=LCG \n' |
260 |
– |
txt += ' if [ $GLIDEIN_Gatekeeper ]; then \n' |
261 |
– |
txt += ' echo "SyncCE=`echo $GLIDEIN_Gatekeeper | sed -e s/:2119//`" >> $RUNTIME_AREA/$repo \n' |
262 |
– |
txt += ' else \n' |
263 |
– |
txt += ' echo "SyncCE=`glite-brokerinfo getCE`" >> $RUNTIME_AREA/$repo \n' |
264 |
– |
txt += ' fi \n' |
265 |
– |
txt += ' echo "GridFlavour=$middleware" | tee -a $RUNTIME_AREA/$repo \n' |
266 |
– |
txt += 'else \n' |
267 |
– |
txt += ' echo "ERROR ==> GridFlavour not identified" \n' |
268 |
– |
txt += ' job_exit_code=10030 \n' |
269 |
– |
txt += ' func_exit \n' |
270 |
– |
txt += 'fi \n' |
271 |
– |
|
272 |
– |
txt += 'dumpStatus $RUNTIME_AREA/$repo \n' |
273 |
– |
txt += '\n\n' |
274 |
– |
|
275 |
– |
|
276 |
– |
txt += 'export VO='+self.VO+'\n' |
277 |
– |
txt += 'if [ $middleware == LCG ]; then\n' |
278 |
– |
txt += ' if [ $GLIDEIN_Gatekeeper ]; then\n' |
279 |
– |
txt += ' CloseCEs=$GLIDEIN_Gatekeeper \n' |
280 |
– |
txt += ' else\n' |
281 |
– |
txt += ' CloseCEs=`glite-brokerinfo getCE`\n' |
282 |
– |
txt += ' fi\n' |
283 |
– |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
284 |
– |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
285 |
– |
txt += ' echo "CE = $CE"\n' |
286 |
– |
txt += 'elif [ $middleware == OSG ]; then \n' |
287 |
– |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
288 |
– |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
289 |
– |
txt += ' else \n' |
290 |
– |
txt += ' echo "ERROR ==> OSG mode in setting CE name from OSG_JOB_CONTACT" \n' |
291 |
– |
txt += ' job_exit_code=10099\n' |
292 |
– |
txt += ' func_exit\n' |
293 |
– |
txt += ' fi \n' |
294 |
– |
txt += 'elif [ $middleware == ARC ]; then \n' |
295 |
– |
txt += ' echo "CE = $NORDUGRID_CE"\n' |
296 |
– |
txt += 'fi \n' |
297 |
– |
|
298 |
– |
return txt |
299 |
– |
""" |