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 |
> |
import sha |
15 |
|
|
16 |
|
class SchedulerCondor(SchedulerLocal) : |
17 |
|
""" |
18 |
|
Class to implement the vanilla (local) Condor scheduler |
19 |
+ |
Naming convention: Methods starting with 'ws' provide |
20 |
+ |
the corresponding part of the job script |
21 |
+ |
('ws' stands for 'write script'). |
22 |
|
""" |
23 |
|
|
24 |
|
def __init__(self): |
35 |
|
""" |
36 |
|
|
37 |
|
SchedulerLocal.configure(self, cfg_params) |
38 |
< |
self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name') |
38 |
> |
taskHash = sha.new(common._db.queryTask('name')).hexdigest() |
39 |
> |
self.environment_unique_identifier = "https://" + socket.gethostname() + \ |
40 |
> |
'/' + taskHash + "/${NJob}" |
41 |
|
|
42 |
|
try: |
43 |
|
tmp = cfg_params['CMSSW.datasetpath'] |
51 |
|
msg = "Error: datasetpath not defined " |
52 |
|
raise CrabException(msg) |
53 |
|
|
54 |
+ |
self.return_data = cfg_params.get('USER.return_data', 0) |
55 |
+ |
self.copy_data = cfg_params.get("USER.copy_data", 0) |
56 |
+ |
self.backup_copy = cfg_params.get('USER.backup_copy',0) |
57 |
+ |
|
58 |
+ |
if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ): |
59 |
+ |
msg = 'Error: return_data and copy_data cannot be set both to 0\n' |
60 |
+ |
msg = msg + 'Please modify your crab.cfg file\n' |
61 |
+ |
raise CrabException(msg) |
62 |
+ |
|
63 |
+ |
if ( int(self.return_data) == 1 and int(self.copy_data) == 1 ): |
64 |
+ |
msg = 'Error: return_data and copy_data cannot be set both to 1\n' |
65 |
+ |
msg = msg + 'Please modify your crab.cfg file\n' |
66 |
+ |
raise CrabException(msg) |
67 |
+ |
|
68 |
+ |
if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ): |
69 |
+ |
msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n' |
70 |
+ |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
71 |
+ |
common.logger.message(msg) |
72 |
+ |
raise CrabException(msg) |
73 |
+ |
|
74 |
+ |
if ( int(self.copy_data) == 0 and int(self.backup_copy) == 1 ): |
75 |
+ |
msg = 'Error: copy_data = 0 and backup_data = 1 ==> to use the backup_copy function, the copy_data value has to be = 1\n' |
76 |
+ |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
77 |
+ |
raise CrabException(msg) |
78 |
+ |
|
79 |
+ |
if int(self.copy_data) == 1: |
80 |
+ |
self.SE = cfg_params.get('USER.storage_element', None) |
81 |
+ |
if not self.SE: |
82 |
+ |
msg = "Error. The [USER] section has no 'storage_element'" |
83 |
+ |
common.logger.message(msg) |
84 |
+ |
raise CrabException(msg) |
85 |
+ |
|
86 |
+ |
if ( int(self.backup_copy) == 1 and int(self.publish_data) == 1 ): |
87 |
+ |
msg = 'Warning: currently the publication is not supported with the backup copy. Work in progress....\n' |
88 |
+ |
common.logger.message(msg) |
89 |
+ |
raise CrabException(msg) |
90 |
+ |
|
91 |
+ |
self.proxyValid = 0 |
92 |
+ |
self.dontCheckProxy = int(cfg_params.get("EDG.dont_check_proxy",0)) |
93 |
+ |
self.proxyServer = cfg_params.get("EDG.proxy_server",'myproxy.cern.ch') |
94 |
+ |
common.logger.debug(5,'Setting myproxy server to ' + self.proxyServer) |
95 |
+ |
|
96 |
+ |
self.group = cfg_params.get("EDG.group", None) |
97 |
+ |
self.role = cfg_params.get("EDG.role", None) |
98 |
+ |
self.VO = cfg_params.get('EDG.virtual_organization', 'cms') |
99 |
+ |
|
100 |
+ |
self.checkProxy() |
101 |
+ |
self.role = None |
102 |
+ |
|
103 |
|
return |
104 |
|
|
105 |
|
|
123 |
|
""" |
124 |
|
|
125 |
|
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
126 |
< |
params = {'tmpDir':tmpDir} |
126 |
> |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
127 |
> |
jobDir = common.work_space.jobDir() |
128 |
> |
params = {'tmpDir':tmpDir, |
129 |
> |
'jobDir':jobDir} |
130 |
|
return params |
131 |
|
|
132 |
|
|
135 |
|
Check the compatibility of available resources |
136 |
|
""" |
137 |
|
|
138 |
< |
if self.selectNoInput: |
83 |
< |
return [True] |
84 |
< |
else: |
85 |
< |
return SchedulerLocal.listMatch(self, seList, full) |
138 |
> |
return [True] |
139 |
|
|
140 |
|
|
141 |
|
def decodeLogInfo(self, fileName): |
149 |
|
return reason |
150 |
|
|
151 |
|
|
152 |
+ |
def wsCopyOutput(self): |
153 |
+ |
""" |
154 |
+ |
Write a CopyResults part of a job script, e.g. |
155 |
+ |
to copy produced output into a storage element. |
156 |
+ |
""" |
157 |
+ |
txt = self.wsCopyOutput_comm() |
158 |
+ |
return txt |
159 |
+ |
|
160 |
+ |
|
161 |
|
def wsExitFunc(self): |
162 |
|
""" |
163 |
|
Returns the part of the job script which runs prior to exit |
190 |
|
txt += 'printenv | sort\n' |
191 |
|
|
192 |
|
txt += 'middleware='+self.name()+' \n' |
193 |
+ |
txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n' |
194 |
+ |
txt += ' export PATH=${PATH}:/opt/d-cache/srm/bin\n' |
195 |
+ |
txt += 'fi\n' |
196 |
+ |
|
197 |
|
txt += """ |
198 |
|
if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then |
199 |
|
echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR" |