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.4.1 by ewv, Tue Jul 1 14:18:36 2008 UTC vs.
Revision 1.13 by ewv, Tue Sep 30 19:35:34 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  
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
25 <
26 <
27 <  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)
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  
40    return
29  
30 +    def configure(self, cfg_params):
31 +        """
32 +        Configure the scheduler with the config settings from the user
33 +        """
34  
35 <  def sched_parameter(self,i,task):
36 <    """
45 <    Return scheduler-specific parameters
46 <    """
47 <    index = int(common._db.nJobs()) - 1
48 <    sched_param= ''
35 >        SchedulerLocal.configure(self, cfg_params)
36 >        self.environment_unique_identifier ='${HOSTNAME}_${CONDOR_ID}_' + common._db.queryTask('name')
37  
38 <    for i in range(index):
39 <      pass
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 <    return sched_param
50 >        return
51  
52  
53 <  def realSchedParams(self,cfg_params):
54 <    """
55 <    Return dictionary with specific parameters, to use
56 <    with real scheduler
60 <    """
53 >    def sched_parameter(self, i, task):
54 >        """
55 >        Return scheduler-specific parameters
56 >        """
57  
58 <    tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
59 <    params = {'tmpDir':tmpDir}
64 <    return  params
58 >        index = int(common._db.nJobs()) - 1
59 >        schedParam = ''
60  
61 +        for i in range(index):
62 +            pass
63  
64 <  def listMatch(self, seList, full, onlyOSG=True):
68 <    """
69 <    Check the compatibility of available resources
70 <    """
64 >        return schedParam
65  
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
66  
67 <    if self.selectNoInput:
68 <      return [True]
69 <    else:
70 <      return SchedulerLocal.listMatch(self, seList, full)
67 >    def realSchedParams(self, cfg_params):
68 >        """
69 >        Return dictionary with specific parameters, to use with real scheduler
70 >        """
71  
72 <  def decodeLogInfo(self, file):
73 <    """
74 <    Parse logging info file and return main info
75 <    """
76 <    import CondorGLoggingInfo
77 <    loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
86 <    reason = loggingInfo.decodeReason(file)
87 <    return reason
72 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
73 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
74 >        jobDir = common.work_space.jobDir()
75 >        params = {'tmpDir':tmpDir,
76 >                  'jobDir':jobDir}
77 >        return params
78  
79  
80 <  def wsExitFunc(self):
81 <    """
82 <    """
83 <    txt = '\n'
94 <    txt += '#\n'
95 <    txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
96 <    txt += '#\n\n'
80 >    def listMatch(self, seList, full):
81 >        """
82 >        Check the compatibility of available resources
83 >        """
84  
85 <    txt += 'func_exit() { \n'
86 <    txt += self.wsExitFunc_common()
85 >        if self.selectNoInput:
86 >            return [True]
87 >        else:
88 >            return SchedulerLocal.listMatch(self, seList, full)
89  
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'
90  
91 <    txt += '    exit $job_exit_code\n'
92 <    txt += '}\n'
91 >    def decodeLogInfo(self, fileName):
92 >        """
93 >        Parse logging info file and return main info
94 >        """
95  
96 <    return txt
96 >        import CondorGLoggingInfo
97 >        loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
98 >        reason = loggingInfo.decodeReason(fileName)
99 >        return reason
100  
110  def wsInitialEnvironment(self):
111    """
112    Returns part of a job script which does scheduler-specific work.
113    """
101  
102 <    txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
103 <    txt += 'echo "Beginning environment"\n'
104 <    txt += 'printenv | sort\n'
102 >    def wsExitFunc(self):
103 >        """
104 >        Returns the part of the job script which runs prior to exit
105 >        """
106 >
107 >        txt = '\n'
108 >        txt += '#\n'
109 >        txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
110 >        txt += '#\n\n'
111 >
112 >        txt += 'func_exit() { \n'
113 >        txt += self.wsExitFunc_common()
114 >
115 >        txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
116 >        txt += '    cp  ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n'
117 >        txt += '    cp  crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n'
118 >
119 >        txt += '    exit $job_exit_code\n'
120 >        txt += '}\n'
121 >
122 >        return txt
123 >
124 >    def wsInitialEnvironment(self):
125 >        """
126 >        Returns part of a job script which does scheduler-specific work.
127 >        """
128 >
129 >        txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
130 >        txt += 'echo "Beginning environment"\n'
131 >        txt += 'printenv | sort\n'
132  
133 <    txt += 'middleware='+self.name()+' \n'
134 <    txt += """
133 >        txt += 'middleware='+self.name()+' \n'
134 >        txt += """
135   if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
136 <    ORIG_WD=`pwd`
123 <    echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
136 >    echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
137      if [ -e ../default.tgz ] ;then
138        echo "Found ISB in parent directory (Local Condor)"
139        cp ../default.tgz $_CONDOR_SCRATCH_DIR
# Line 129 | Line 142 | if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CO
142   fi
143   """
144  
145 <    return txt
145 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines