1 |
from Scheduler import Scheduler
|
2 |
from SchedulerLocal import SchedulerLocal
|
3 |
from crab_exceptions import *
|
4 |
from crab_util import *
|
5 |
import common
|
6 |
|
7 |
import os,string
|
8 |
|
9 |
# PBS/torque interface for CRAB (dave.newbold@cern.ch, June 09)
|
10 |
#
|
11 |
#
|
12 |
# In the [CRAB] section of crab.cfg, use:
|
13 |
#
|
14 |
# scheduler = pbs
|
15 |
#
|
16 |
# In the [PBS] section of crab.cfg, use the following optional parameters
|
17 |
#
|
18 |
# queue= pbs_queue_to_use [default, use the default queue in your local PBS config]
|
19 |
# resources = resource_1=value,resource_2=value, etc [like qsub -l syntax]
|
20 |
# wnBase = /tmp (top level directory where CRAB should unpack on worker nodes. $HOME is a bad default for many)
|
21 |
#
|
22 |
# NB: - the scheduler uses a wrapper script to create a local dir (see BossLite scheduler module)
|
23 |
# Both wrapper stdout/stderr and job script output files are placed in your crab_*/res directory by default
|
24 |
#
|
25 |
|
26 |
#
|
27 |
# Naming convention:
|
28 |
# methods starting with 'ws' are responsible to provide
|
29 |
# corresponding part of the job script ('ws' stands for 'write script').
|
30 |
#
|
31 |
|
32 |
class SchedulerPbs(SchedulerLocal) :
|
33 |
|
34 |
def __init__(self):
|
35 |
Scheduler.__init__(self,"PBS")
|
36 |
self.OSBsize = None
|
37 |
|
38 |
def configure(self, cfg_params):
|
39 |
SchedulerLocal.configure(self, cfg_params)
|
40 |
if "PBS.queue" in cfg_params:
|
41 |
if len(cfg_params["PBS.queue"]) == 0 or cfg_params["PBS.queue"] == "default":
|
42 |
common.logger.info(" The default queue of local PBS configuration will be used")
|
43 |
else:
|
44 |
common.logger.info(" The default queue of local PBS configuration will be used")
|
45 |
|
46 |
return
|
47 |
|
48 |
|
49 |
def envUniqueID(self):
|
50 |
id = "https://"+common.scheduler.name()+":/${PBS_JOBID}-"+ \
|
51 |
string.replace(common._db.queryTask('name'),"_","-")
|
52 |
return id
|
53 |
|
54 |
def realSchedParams(self,cfg_params):
|
55 |
"""
|
56 |
Return dictionary with specific parameters, to use
|
57 |
with real scheduler
|
58 |
"""
|
59 |
|
60 |
params={'jobScriptDir':common.work_space.jobDir(),
|
61 |
'jobResDir':common.work_space.resDir()
|
62 |
}
|
63 |
|
64 |
# update parameters
|
65 |
for s in ('resources', 'queue'):
|
66 |
params[s] = cfg_params.get( self.name().upper()+'.'+s,'' )
|
67 |
|
68 |
params['workDir'] = cfg_params.get(self.name().upper()+'.wnbase','')
|
69 |
|
70 |
return params
|
71 |
|
72 |
def listMatch(self, dest, full):
|
73 |
return [str(getLocalDomain(self))]
|
74 |
|
75 |
def wsCopyOutput(self):
|
76 |
return self.wsCopyOutput_comm()
|
77 |
|
78 |
def wsExitFunc(self):
|
79 |
"""
|
80 |
"""
|
81 |
s=[]
|
82 |
s.append('func_exit(){')
|
83 |
s.append(self.wsExitFunc_common())
|
84 |
s.append('tar zcvf '+common.work_space.resDir()+'${out_files}.tgz ${filesToCheck}')
|
85 |
s.append('exit $job_exit_code')
|
86 |
s.append('}')
|
87 |
return '\n'.join(s)
|
88 |
|
89 |
def envUniqueID(self):
|
90 |
id = "https://"+common.scheduler.name()+":/${PBS_JOBID}-"+ \
|
91 |
string.replace(common._db.queryTask('name'),"_","-")
|
92 |
return id
|
93 |
|