ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerCondor.py
Revision: 1.6
Committed: Thu May 29 19:20:40 2008 UTC (16 years, 11 months ago) by ewv
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_2_2_pre4, CRAB_2_2_2_pre3, CRAB_2_2_2_pre2, CRAB_2_2_2_pre1, CRAB_2_2_1, CRAB_2_2_1_pre6, CRAB_2_2_1_pre5, CRAB_2_2_1_pre4
Changes since 1.5: +12 -12 lines
Log Message:
Add wsInitialEnvironment for scheduler dependent code at top of wrapper script

File Contents

# User Rev Content
1 ewv 1.6 __revision__ = "$Id: SchedulerCondor.py,v 1.5 2008/05/29 19:18:49 ewv Exp $"
2     __version__ = "$Revision: 1.5 $"
3 ewv 1.1
4     from Scheduler import Scheduler
5     from SchedulerLocal import SchedulerLocal
6     from crab_exceptions import *
7     from crab_util import *
8     from crab_logger import Logger
9     import common
10    
11     import os
12    
13     # Naming convention:
14     # methods starting with 'ws' are responsible to provide
15     # corresponding part of the job script ('ws' stands for 'write script').
16    
17     class SchedulerCondor(SchedulerLocal) :
18    
19     def __init__(self):
20     Scheduler.__init__(self,"CONDOR")
21     return
22    
23 ewv 1.3
24 ewv 1.1 def configure(self, cfg_params):
25     SchedulerLocal.configure(self, cfg_params)
26     self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
27     return
28    
29 ewv 1.3
30 ewv 1.1 def sched_parameter(self,i,task):
31     """
32     Return scheduler-specific parameters
33     """
34     index = int(common._db.nJobs()) - 1
35     sched_param= ''
36    
37     for i in range(index):
38     pass
39    
40     return sched_param
41    
42 ewv 1.3
43 ewv 1.2 def realSchedParams(self,cfg_params):
44     """
45     Return dictionary with specific parameters, to use
46     with real scheduler
47     """
48    
49     tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
50     params = {'tmpDir':tmpDir}
51     return params
52    
53 ewv 1.3
54 ewv 1.4 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
62 ewv 1.3
63    
64     def wsExitFunc(self):
65     """
66     """
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'
90    
91     txt += ' exit $job_exit_code\n'
92     txt += '}\n'
93    
94     return txt
95 ewv 1.5
96     def wsInitialEnvironment(self):
97     """
98     Returns part of a job script which does scheduler-specific work.
99     """
100    
101     txt = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
102     txt += 'echo "Beginning environment"\n'
103     txt += 'printenv | sort\n'
104    
105     txt += 'middleware='+self.name()+' \n'
106     txt += """
107 ewv 1.6 if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
108     ORIG_WD=`pwd`
109     echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
110     if [ -e ../default.tgz ] ;then
111     echo "Found ISB in parent directory (Local Condor)"
112     cp ../default.tgz $_CONDOR_SCRATCH_DIR
113     fi
114     cd $_CONDOR_SCRATCH_DIR
115     fi
116     """
117 ewv 1.5
118     return txt