1 |
from Scheduler import Scheduler
|
2 |
from SchedulerLocal import SchedulerLocal
|
3 |
from crab_exceptions import *
|
4 |
from crab_util import *
|
5 |
from crab_logger import Logger
|
6 |
import common
|
7 |
|
8 |
import os,string
|
9 |
|
10 |
#
|
11 |
# Naming convention:
|
12 |
# methods starting with 'ws' are responsible to provide
|
13 |
# corresponding part of the job script ('ws' stands for 'write script').
|
14 |
#
|
15 |
# Author: Hartmut Stadie <stadie@mail.desy.de> Inst. f. Experimentalphysik; Universitaet Hamburg
|
16 |
#
|
17 |
|
18 |
class SchedulerSge(SchedulerLocal) :
|
19 |
|
20 |
def __init__(self):
|
21 |
Scheduler.__init__(self,"SGE")
|
22 |
self.datasetPath = None
|
23 |
self.selectNoInput = None
|
24 |
return
|
25 |
|
26 |
def configure(self, cfg_params):
|
27 |
SchedulerLocal.configure(self, cfg_params)
|
28 |
|
29 |
try:
|
30 |
tmp = cfg_params['CMSSW.datasetpath']
|
31 |
if tmp.lower() == 'none':
|
32 |
self.datasetPath = None
|
33 |
self.selectNoInput = 1
|
34 |
else:
|
35 |
self.datasetPath = tmp
|
36 |
self.selectNoInput = 0
|
37 |
except KeyError:
|
38 |
msg = "Error: datasetpath not defined "
|
39 |
raise CrabException(msg)
|
40 |
|
41 |
self.return_data = cfg_params.get('USER.return_data', 0)
|
42 |
self.copy_data = cfg_params.get("USER.copy_data", 0)
|
43 |
|
44 |
if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ):
|
45 |
msg = 'Error: return_data and copy_data cannot be set both to 0\n'
|
46 |
msg = msg + 'Please modify your crab.cfg file\n'
|
47 |
raise CrabException(msg)
|
48 |
|
49 |
if ( int(self.return_data) == 1 and int(self.copy_data) == 1 ):
|
50 |
msg = 'Error: return_data and copy_data cannot be set both to 1\n'
|
51 |
msg = msg + 'Please modify your crab.cfg file\n'
|
52 |
raise CrabException(msg)
|
53 |
|
54 |
if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ):
|
55 |
msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n'
|
56 |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
|
57 |
common.logger.message(msg)
|
58 |
raise CrabException(msg)
|
59 |
|
60 |
if int(self.copy_data) == 1:
|
61 |
self.SE = cfg_params.get('USER.storage_element', None)
|
62 |
if not self.SE:
|
63 |
msg = "Error. The [USER] section has no 'storage_element'"
|
64 |
common.logger.message(msg)
|
65 |
raise CrabException(msg)
|
66 |
|
67 |
self.proxyValid = 0
|
68 |
self.dontCheckProxy = int(cfg_params.get("EDG.dont_check_proxy",0))
|
69 |
self.proxyServer = cfg_params.get("EDG.proxy_server",'myproxy.cern.ch')
|
70 |
common.logger.debug(5,'Setting myproxy server to ' + self.proxyServer)
|
71 |
|
72 |
self.group = cfg_params.get("EDG.group", None)
|
73 |
self.role = cfg_params.get("EDG.role", None)
|
74 |
self.VO = cfg_params.get('EDG.virtual_organization', 'cms')
|
75 |
|
76 |
self.checkProxy()
|
77 |
|
78 |
self.role = None
|
79 |
|
80 |
self.pool = cfg_params.get('USER.storage_pool',None)
|
81 |
# self.cpu = cfg_params.get('USER.cpu',172800)
|
82 |
# self.vmem = cfg_params.get('USER.vmem',2)
|
83 |
return
|
84 |
|
85 |
def envUniqueID(self):
|
86 |
id = "https://"+common.scheduler.name()+":/${JOB_ID}-"+ \
|
87 |
string.replace(common._db.queryTask('name'),"_","-")
|
88 |
return id
|
89 |
|
90 |
def realSchedParams(self,cfg_params):
|
91 |
"""
|
92 |
Return dictionary with specific parameters, to use
|
93 |
with real scheduler
|
94 |
"""
|
95 |
params = {}
|
96 |
return params
|
97 |
|
98 |
def sched_parameter(self,i,task):
|
99 |
"""
|
100 |
Returns parameter scheduler-specific, to use with BOSS .
|
101 |
"""
|
102 |
index = int(common._db.nJobs()) - 1
|
103 |
sched_param= ''
|
104 |
|
105 |
for i in range(index): # Add loop DS
|
106 |
sched_param= ''
|
107 |
if (self.queue):
|
108 |
sched_param += '-q '+self.queue +' '
|
109 |
if (self.res): sched_param += ' -l '+self.res +' '
|
110 |
pass
|
111 |
|
112 |
#default is request 2G memory and 48 hours CPU time
|
113 |
#sched_param += ' -V -l h_vmem=2G -l h_cpu=172800 '
|
114 |
# sched_param += ' -V -l h_vmem='
|
115 |
# sched_param += self.vmem.__str__()
|
116 |
# sched_param += 'G -l h_cpu='
|
117 |
# sched_param += self.cpu.__str__()
|
118 |
# sched_param += ' '
|
119 |
|
120 |
return sched_param
|
121 |
|
122 |
def loggingInfo(self, id):
|
123 |
""" return logging info about job nj """
|
124 |
print "Warning: SchedulerSge::loggingInfo not implemented!"
|
125 |
return ""
|
126 |
|
127 |
def wsExitFunc(self):
|
128 |
"""
|
129 |
"""
|
130 |
txt = '\n'
|
131 |
|
132 |
txt += '#\n'
|
133 |
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
|
134 |
txt += '#\n\n'
|
135 |
|
136 |
txt += 'func_exit() { \n'
|
137 |
txt += self.wsExitFunc_common()
|
138 |
|
139 |
txt += ' cp ${SGE_STDOUT_PATH} CMSSW_${NJob}.stdout \n'
|
140 |
txt += ' cp ${SGE_STDERR_PATH} CMSSW_${NJob}.stderr \n'
|
141 |
txt += ' tar zcvf ${out_files}.tgz ${filesToCheck}\n'
|
142 |
txt += ' exit $job_exit_code\n'
|
143 |
txt += '}\n'
|
144 |
|
145 |
return txt
|
146 |
|
147 |
def listMatch(self, dest, full):
|
148 |
"""
|
149 |
"""
|
150 |
#if len(dest)!=0:
|
151 |
sites = [self.blackWhiteListParser.cleanForBlackWhiteList(dest,'list')]
|
152 |
#else:
|
153 |
# sites = [str(getLocalDomain(self))]
|
154 |
return sites
|
155 |
|
156 |
def wsCopyOutput(self):
|
157 |
txt=self.wsCopyOutput_comm(self.pool)
|
158 |
return txt
|
159 |
|
160 |
def userName(self):
|
161 |
""" return the user name """
|
162 |
|
163 |
## hack for german naf
|
164 |
import pwd,getpass
|
165 |
tmp=pwd.getpwnam(getpass.getuser())[4]
|
166 |
tmp=tmp.rstrip(',')
|
167 |
tmp=tmp.rstrip(',')
|
168 |
tmp=tmp.rstrip(',')
|
169 |
|
170 |
|
171 |
return "/CN="+tmp.strip()
|