ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerCondor.py
(Generate patch)

Comparing COMP/CRAB/python/SchedulerCondor.py (file contents):
Revision 1.8.2.1 by fanzago, Tue Jun 24 13:54:11 2008 UTC vs.
Revision 1.14 by ewv, Fri Oct 10 19:24:44 2008 UTC

# Line 1 | Line 1
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  
13 #  Naming convention:
14 #  methods starting with 'ws' are responsible to provide
15 #  corresponding part of the job script ('ws' stands for 'write script').
14  
15   class SchedulerCondor(SchedulerLocal) :
16 +    """
17 +    Class to implement the vanilla (local) Condor scheduler
18 +     Naming convention:  Methods starting with 'ws' provide
19 +     the corresponding part of the job script
20 +     ('ws' stands for 'write script').
21 +    """
22  
23 <  def __init__(self):
24 <    Scheduler.__init__(self,"CONDOR")
25 <    return
26 <
27 <
28 <  def configure(self, cfg_params):
25 <    SchedulerLocal.configure(self, cfg_params)
26 <    self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
27 <
28 <    try:
29 <      tmp =  cfg_params['CMSSW.datasetpath']
30 <      if string.lower(tmp)=='none':
31 <        self.datasetPath = None
32 <        self.selectNoInput = 1
33 <      else:
34 <        self.datasetPath = tmp
35 <        self.selectNoInput = 0
36 <    except KeyError:
37 <      msg = "Error: datasetpath not defined "
38 <      raise CrabException(msg)
23 >    def __init__(self):
24 >        SchedulerLocal.__init__(self,"CONDOR")
25 >        self.datasetPath   = None
26 >        self.selectNoInput = None
27 >        self.environment_unique_identifier = None
28 >        return
29  
40    return
30  
31 +    def configure(self, cfg_params):
32 +        """
33 +        Configure the scheduler with the config settings from the user
34 +        """
35  
36 <  def sched_parameter(self,i,task):
37 <    """
38 <    Return scheduler-specific parameters
46 <    """
47 <    index = int(common._db.nJobs()) - 1
48 <    sched_param= ''
36 >        SchedulerLocal.configure(self, cfg_params)
37 >        self.environment_unique_identifier = '${HOSTNAME}_${CONDOR_ID}_' \
38 >                                             + common._db.queryTask('name')
39  
40 <    for i in range(index):
41 <      pass
40 >        try:
41 >            tmp =  cfg_params['CMSSW.datasetpath']
42 >            if tmp.lower() == 'none':
43 >                self.datasetPath = None
44 >                self.selectNoInput = 1
45 >            else:
46 >                self.datasetPath = tmp
47 >                self.selectNoInput = 0
48 >        except KeyError:
49 >            msg = "Error: datasetpath not defined "
50 >            raise CrabException(msg)
51  
52 <    return sched_param
52 >        return
53  
54  
55 <  def realSchedParams(self,cfg_params):
56 <    """
57 <    Return dictionary with specific parameters, to use
58 <    with real scheduler
60 <    """
55 >    def sched_parameter(self, i, task):
56 >        """
57 >        Return scheduler-specific parameters
58 >        """
59  
60 <    tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
61 <    params = {'tmpDir':tmpDir}
64 <    return  params
60 >        index = int(common._db.nJobs()) - 1
61 >        schedParam = ''
62  
63 +        for i in range(index):
64 +            pass
65  
66 <  def listMatch(self, seList, full, onlyOSG=True):
68 <    """
69 <    Check the compatibility of available resources
70 <    """
66 >        return schedParam
67  
72    # May have problems with onlyOSG being false, probably due to lengths of lists and command line.
73    # Either re-write osg_bdii.py with a proper ldap library or break the queries apart
68  
69 <    if self.selectNoInput:
70 <      return [True]
71 <    else:
72 <      return SchedulerLocal.listMatch(self, seList, full)
69 >    def realSchedParams(self, cfg_params):
70 >        """
71 >        Return dictionary with specific parameters, to use with real scheduler
72 >        """
73  
74 <  def decodeLogInfo(self, file):
75 <    """
76 <    Parse logging info file and return main info
77 <    """
78 <    import CondorGLoggingInfo
79 <    loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
86 <    reason = loggingInfo.decodeReason(file)
87 <    return reason
74 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
75 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
76 >        jobDir = common.work_space.jobDir()
77 >        params = {'tmpDir':tmpDir,
78 >                  'jobDir':jobDir}
79 >        return params
80  
81  
82 <  def wsExitFunc(self):
83 <    """
84 <    """
85 <    txt = '\n'
94 <    txt += '#\n'
95 <    txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
96 <    txt += '#\n\n'
82 >    def listMatch(self, seList, full):
83 >        """
84 >        Check the compatibility of available resources
85 >        """
86  
87 <    txt += 'func_exit() { \n'
88 <    txt += self.wsExitFunc_common()
87 >        if self.selectNoInput:
88 >            return [True]
89 >        else:
90 >            return SchedulerLocal.listMatch(self, seList, full)
91  
101    txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
102    txt += '    cp  ${out_files}.tgz $ORIG_WD/\n'
103    txt += '    cp  crab_fjr_$NJob.xml $ORIG_WD/\n'
92  
93 <    txt += '    exit $job_exit_code\n'
94 <    txt += '}\n'
93 >    def decodeLogInfo(self, fileName):
94 >        """
95 >        Parse logging info file and return main info
96 >        """
97  
98 <    return txt
98 >        import CondorGLoggingInfo
99 >        loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
100 >        reason = loggingInfo.decodeReason(fileName)
101 >        return reason
102  
110  def wsInitialEnvironment(self):
111    """
112    Returns part of a job script which does scheduler-specific work.
113    """
103  
104 <    txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
105 <    txt += 'echo "Beginning environment"\n'
106 <    txt += 'printenv | sort\n'
104 >    def wsCopyOutput(self):
105 >        """
106 >        Write a CopyResults part of a job script, e.g.
107 >        to copy produced output into a storage element.
108 >        """
109 >        txt = self.wsCopyOutput_comm()
110 >        return txt
111 >
112 >
113 >    def wsExitFunc(self):
114 >        """
115 >        Returns the part of the job script which runs prior to exit
116 >        """
117 >
118 >        txt = '\n'
119 >        txt += '#\n'
120 >        txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
121 >        txt += '#\n\n'
122 >
123 >        txt += 'func_exit() { \n'
124 >        txt += self.wsExitFunc_common()
125 >
126 >        txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
127 >        txt += '    cp  ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n'
128 >        txt += '    cp  crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n'
129 >
130 >        txt += '    exit $job_exit_code\n'
131 >        txt += '}\n'
132 >
133 >        return txt
134 >
135 >    def wsInitialEnvironment(self):
136 >        """
137 >        Returns part of a job script which does scheduler-specific work.
138 >        """
139 >
140 >        txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
141 >        txt += 'echo "Beginning environment"\n'
142 >        txt += 'printenv | sort\n'
143 >
144 >        txt += 'middleware='+self.name()+' \n'
145 >        txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n'
146 >        txt += '  export PATH=${PATH}:/opt/d-cache/srm/bin\n'
147 >        txt += 'fi\n'
148  
149 <    txt += 'middleware='+self.name()+' \n'
120 <    txt += """
149 >        txt += """
150   if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
151 <    ORIG_WD=`pwd`
123 <    echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
151 >    echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
152      if [ -e ../default.tgz ] ;then
153        echo "Found ISB in parent directory (Local Condor)"
154        cp ../default.tgz $_CONDOR_SCRATCH_DIR
# Line 129 | Line 157 | if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CO
157   fi
158   """
159  
160 <    return txt
160 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines