1 |
+ |
""" |
2 |
+ |
Implements the vanilla (local) Condor scheduler |
3 |
+ |
""" |
4 |
+ |
|
5 |
|
__revision__ = "$Id$" |
6 |
|
__version__ = "$Revision$" |
7 |
|
|
8 |
< |
from Scheduler import Scheduler |
9 |
< |
from SchedulerLocal import SchedulerLocal |
6 |
< |
from crab_exceptions import * |
7 |
< |
from crab_util import * |
8 |
< |
from crab_logger import Logger |
9 |
< |
import common |
8 |
> |
from SchedulerLocal import SchedulerLocal |
9 |
> |
from crab_exceptions import CrabException |
10 |
|
|
11 |
+ |
import common |
12 |
|
import os |
13 |
|
|
14 |
< |
# Naming convention: |
15 |
< |
# methods starting with 'ws' are responsible to provide |
15 |
< |
# corresponding part of the job script ('ws' stands for 'write script'). |
14 |
> |
# Naming convention: Methods starting with 'ws' provide the corresponding part of the job script |
15 |
> |
# ('ws' stands for 'write script'). |
16 |
|
|
17 |
|
class SchedulerCondor(SchedulerLocal) : |
18 |
+ |
""" |
19 |
+ |
Class to implement the vanilla (local) Condor scheduler |
20 |
+ |
""" |
21 |
|
|
22 |
< |
def __init__(self): |
23 |
< |
Scheduler.__init__(self,"CONDOR") |
24 |
< |
return |
22 |
> |
def __init__(self): |
23 |
> |
SchedulerLocal.__init__(self,"CONDOR") |
24 |
> |
self.datasetPath = None |
25 |
> |
self.selectNoInput = None |
26 |
> |
self.environment_unique_identifier = None |
27 |
> |
return |
28 |
|
|
29 |
|
|
30 |
< |
def configure(self, cfg_params): |
31 |
< |
SchedulerLocal.configure(self, cfg_params) |
32 |
< |
self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name') |
33 |
< |
return |
30 |
> |
def configure(self, cfg_params): |
31 |
> |
""" |
32 |
> |
Configure the scheduler with the config settings from the user |
33 |
> |
""" |
34 |
|
|
35 |
+ |
SchedulerLocal.configure(self, cfg_params) |
36 |
+ |
self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name') |
37 |
|
|
38 |
< |
def sched_parameter(self,i,task): |
39 |
< |
""" |
40 |
< |
Return scheduler-specific parameters |
41 |
< |
""" |
42 |
< |
index = int(common._db.nJobs()) - 1 |
43 |
< |
sched_param= '' |
38 |
> |
try: |
39 |
> |
tmp = cfg_params['CMSSW.datasetpath'] |
40 |
> |
if tmp.lower() == 'none': |
41 |
> |
self.datasetPath = None |
42 |
> |
self.selectNoInput = 1 |
43 |
> |
else: |
44 |
> |
self.datasetPath = tmp |
45 |
> |
self.selectNoInput = 0 |
46 |
> |
except KeyError: |
47 |
> |
msg = "Error: datasetpath not defined " |
48 |
> |
raise CrabException(msg) |
49 |
|
|
50 |
< |
for i in range(index): |
38 |
< |
pass |
50 |
> |
return |
51 |
|
|
40 |
– |
return sched_param |
52 |
|
|
53 |
+ |
def sched_parameter(self, i, task): |
54 |
+ |
""" |
55 |
+ |
Return scheduler-specific parameters |
56 |
+ |
""" |
57 |
|
|
58 |
< |
def realSchedParams(self,cfg_params): |
59 |
< |
""" |
45 |
< |
Return dictionary with specific parameters, to use |
46 |
< |
with real scheduler |
47 |
< |
""" |
58 |
> |
index = int(common._db.nJobs()) - 1 |
59 |
> |
schedParam = '' |
60 |
|
|
61 |
< |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
62 |
< |
params = {'tmpDir':tmpDir} |
51 |
< |
return params |
61 |
> |
for i in range(index): |
62 |
> |
pass |
63 |
|
|
64 |
+ |
return schedParam |
65 |
|
|
54 |
– |
def decodeLogInfo(self, file): |
55 |
– |
""" |
56 |
– |
Parse logging info file and return main info |
57 |
– |
""" |
58 |
– |
import CondorGLoggingInfo |
59 |
– |
loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo() |
60 |
– |
reason = loggingInfo.decodeReason(file) |
61 |
– |
return reason |
66 |
|
|
67 |
+ |
def realSchedParams(self, cfg_params): |
68 |
+ |
""" |
69 |
+ |
Return dictionary with specific parameters, to use with real scheduler |
70 |
+ |
""" |
71 |
|
|
72 |
< |
def wsExitFunc(self): |
73 |
< |
""" |
74 |
< |
""" |
67 |
< |
txt = '\n' |
68 |
< |
txt += '#\n' |
69 |
< |
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n' |
70 |
< |
txt += '#\n\n' |
71 |
< |
|
72 |
< |
txt += 'func_exit() { \n' |
73 |
< |
txt += ' if [ $PYTHONPATH ]; then \n' |
74 |
< |
txt += ' update_fjr\n' |
75 |
< |
txt += ' fi\n' |
76 |
< |
txt += ' for file in $filesToCheck ; do\n' |
77 |
< |
txt += ' if [ -e $file ]; then\n' |
78 |
< |
txt += ' echo "tarring file $file in $out_files"\n' |
79 |
< |
txt += ' else\n' |
80 |
< |
txt += ' echo "WARNING: output file $file not found!"\n' |
81 |
< |
txt += ' fi\n' |
82 |
< |
txt += ' done\n' |
83 |
< |
txt += ' final_list=$filesToCheck\n' |
84 |
< |
txt += ' echo "JOB_EXIT_STATUS = $job_exit_code"\n' |
85 |
< |
txt += ' echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n' |
86 |
< |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
87 |
< |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
88 |
< |
txt += ' cp ${out_files}.tgz $ORIG_WD/\n' |
89 |
< |
txt += ' cp crab_fjr_$NJob.xml $ORIG_WD/\n' |
72 |
> |
tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp') |
73 |
> |
params = {'tmpDir':tmpDir} |
74 |
> |
return params |
75 |
|
|
91 |
– |
txt += ' exit $job_exit_code\n' |
92 |
– |
txt += '}\n' |
76 |
|
|
77 |
< |
return txt |
77 |
> |
def listMatch(self, seList, full): |
78 |
> |
""" |
79 |
> |
Check the compatibility of available resources |
80 |
> |
""" |
81 |
|
|
82 |
< |
def wsInitialEnvironment(self): |
83 |
< |
""" |
84 |
< |
Returns part of a job script which does scheduler-specific work. |
85 |
< |
""" |
82 |
> |
if self.selectNoInput: |
83 |
> |
return [True] |
84 |
> |
else: |
85 |
> |
return SchedulerLocal.listMatch(self, seList, full) |
86 |
> |
|
87 |
> |
|
88 |
> |
def decodeLogInfo(self, fileName): |
89 |
> |
""" |
90 |
> |
Parse logging info file and return main info |
91 |
> |
""" |
92 |
> |
|
93 |
> |
import CondorGLoggingInfo |
94 |
> |
loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo() |
95 |
> |
reason = loggingInfo.decodeReason(fileName) |
96 |
> |
return reason |
97 |
> |
|
98 |
> |
|
99 |
> |
def wsExitFunc(self): |
100 |
> |
""" |
101 |
> |
Returns the part of the job script which runs prior to exit |
102 |
> |
""" |
103 |
> |
|
104 |
> |
txt = '\n' |
105 |
> |
txt += '#\n' |
106 |
> |
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n' |
107 |
> |
txt += '#\n\n' |
108 |
> |
|
109 |
> |
txt += 'func_exit() { \n' |
110 |
> |
txt += self.wsExitFunc_common() |
111 |
> |
|
112 |
> |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
113 |
> |
txt += ' cp ${out_files}.tgz $ORIG_WD/\n' |
114 |
> |
txt += ' cp crab_fjr_$NJob.xml $ORIG_WD/\n' |
115 |
> |
|
116 |
> |
txt += ' exit $job_exit_code\n' |
117 |
> |
txt += '}\n' |
118 |
> |
|
119 |
> |
return txt |
120 |
> |
|
121 |
> |
def wsInitialEnvironment(self): |
122 |
> |
""" |
123 |
> |
Returns part of a job script which does scheduler-specific work. |
124 |
> |
""" |
125 |
|
|
126 |
< |
txt = '\n# Written by SchedulerCondor::wsInitialEnvironment\n' |
127 |
< |
txt += 'echo "Beginning environment"\n' |
128 |
< |
txt += 'printenv | sort\n' |
126 |
> |
txt = '\n# Written by SchedulerCondor::wsInitialEnvironment\n' |
127 |
> |
txt += 'echo "Beginning environment"\n' |
128 |
> |
txt += 'printenv | sort\n' |
129 |
|
|
130 |
< |
txt += 'middleware='+self.name()+' \n' |
131 |
< |
txt += """ |
130 |
> |
txt += 'middleware='+self.name()+' \n' |
131 |
> |
txt += """ |
132 |
|
if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then |
133 |
|
ORIG_WD=`pwd` |
134 |
|
echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR" |
140 |
|
fi |
141 |
|
""" |
142 |
|
|
143 |
< |
return txt |
143 |
> |
return txt |