10 |
|
|
11 |
|
import common |
12 |
|
import os |
13 |
< |
|
14 |
< |
# Naming convention: Methods starting with 'ws' provide the corresponding part of the job script |
15 |
< |
# ('ws' stands for 'write script'). |
13 |
> |
import socket |
14 |
> |
try: |
15 |
> |
from hashlib import sha1 |
16 |
> |
except: |
17 |
> |
from sha import sha as sha1 |
18 |
|
|
19 |
|
class SchedulerCondor(SchedulerLocal) : |
20 |
|
""" |
21 |
|
Class to implement the vanilla (local) Condor scheduler |
22 |
+ |
Naming convention: Methods starting with 'ws' provide |
23 |
+ |
the corresponding part of the job script |
24 |
+ |
('ws' stands for 'write script'). |
25 |
|
""" |
26 |
|
|
27 |
|
def __init__(self): |
28 |
|
SchedulerLocal.__init__(self,"CONDOR") |
29 |
|
self.datasetPath = None |
30 |
|
self.selectNoInput = None |
31 |
+ |
self.return_data = 0 |
32 |
+ |
self.copy_data = 0 |
33 |
+ |
|
34 |
|
self.environment_unique_identifier = None |
35 |
|
return |
36 |
|
|
41 |
|
""" |
42 |
|
|
43 |
|
SchedulerLocal.configure(self, cfg_params) |
36 |
– |
self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name') |
44 |
|
|
45 |
|
try: |
46 |
|
tmp = cfg_params['CMSSW.datasetpath'] |
54 |
|
msg = "Error: datasetpath not defined " |
55 |
|
raise CrabException(msg) |
56 |
|
|
57 |
+ |
self.return_data = cfg_params.get('USER.return_data', 0) |
58 |
+ |
self.copy_data = cfg_params.get("USER.copy_data", 0) |
59 |
+ |
|
60 |
+ |
self.proxyValid = 0 |
61 |
+ |
self.dontCheckProxy = int(cfg_params.get("GRID.dont_check_proxy", 0)) |
62 |
+ |
self.proxyServer = cfg_params.get("GRID.proxy_server", 'myproxy.cern.ch') |
63 |
+ |
common.logger.debug('Setting myproxy server to ' + self.proxyServer) |
64 |
+ |
|
65 |
+ |
self.group = cfg_params.get("GRID.group", None) |
66 |
+ |
self.role = cfg_params.get("GRID.role", None) |
67 |
+ |
self.VO = cfg_params.get('GRID.virtual_organization', 'cms') |
68 |
+ |
|
69 |
+ |
self.checkProxy() |
70 |
+ |
|
71 |
|
return |
72 |
|
|
73 |
+ |
def envUniqueID(self): |
74 |
+ |
taskHash = sha1(common._db.queryTask('name')).hexdigest() |
75 |
+ |
id = "https://" + socket.gethostname() + '/' + taskHash + "/${NJob}" |
76 |
+ |
return id |
77 |
|
|
78 |
|
def sched_parameter(self, i, task): |
79 |
|
""" |
80 |
|
Return scheduler-specific parameters |
81 |
|
""" |
82 |
+ |
req = '' |
83 |
+ |
if self.EDG_addJdlParam: |
84 |
+ |
if self.EDG_addJdlParam[-1] == '': |
85 |
+ |
self.EDG_addJdlParam = self.EDG_addJdlParam[:-1] |
86 |
+ |
for p in self.EDG_addJdlParam: |
87 |
+ |
req += p.strip()+';\n' |
88 |
|
|
89 |
< |
index = int(common._db.nJobs()) - 1 |
59 |
< |
schedParam = '' |
60 |
< |
|
61 |
< |
for i in range(index): |
62 |
< |
pass |
63 |
< |
|
64 |
< |
return schedParam |
89 |
> |
return req |
90 |
|
|
91 |
|
|
92 |
|
def realSchedParams(self, cfg_params): |
95 |
|
""" |
96 |
|
|
97 |
|
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
98 |
< |
params = {'tmpDir':tmpDir} |
98 |
> |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
99 |
> |
jobDir = common.work_space.jobDir() |
100 |
> |
params = {'tmpDir':tmpDir, |
101 |
> |
'jobDir':jobDir} |
102 |
|
return params |
103 |
|
|
104 |
|
|
107 |
|
Check the compatibility of available resources |
108 |
|
""" |
109 |
|
|
110 |
< |
if self.selectNoInput: |
83 |
< |
return [True] |
84 |
< |
else: |
85 |
< |
return SchedulerLocal.listMatch(self, seList, full) |
110 |
> |
return [True] |
111 |
|
|
112 |
|
|
113 |
|
def decodeLogInfo(self, fileName): |
121 |
|
return reason |
122 |
|
|
123 |
|
|
124 |
+ |
def wsCopyOutput(self): |
125 |
+ |
""" |
126 |
+ |
Write a CopyResults part of a job script, e.g. |
127 |
+ |
to copy produced output into a storage element. |
128 |
+ |
""" |
129 |
+ |
txt = self.wsCopyOutput_comm() |
130 |
+ |
return txt |
131 |
+ |
|
132 |
+ |
|
133 |
|
def wsExitFunc(self): |
134 |
|
""" |
135 |
|
Returns the part of the job script which runs prior to exit |
162 |
|
txt += 'printenv | sort\n' |
163 |
|
|
164 |
|
txt += 'middleware='+self.name()+' \n' |
165 |
+ |
txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n' |
166 |
+ |
txt += ' export PATH=${PATH}:/opt/d-cache/srm/bin\n' |
167 |
+ |
txt += 'fi\n' |
168 |
+ |
|
169 |
|
txt += """ |
170 |
|
if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then |
171 |
|
echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR" |
178 |
|
""" |
179 |
|
|
180 |
|
return txt |
181 |
+ |
|
182 |
+ |
|
183 |
+ |
def sched_fix_parameter(self): |
184 |
+ |
""" |
185 |
+ |
Returns string with requirements and scheduler-specific parameters |
186 |
+ |
""" |
187 |
+ |
|
188 |
+ |
if self.EDG_requirements: |
189 |
+ |
req = self.EDG_requirements |
190 |
+ |
taskReq = {'commonRequirements':req} |
191 |
+ |
common._db.updateTask_(taskReq) |