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 by spiga, Wed Jun 11 10:03:07 2008 UTC vs.
Revision 1.12 by ewv, Thu Sep 4 21:26:18 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 <    #scram = Scram.Scram(None)
68 <    #versionCMSSW = scram.getSWVersion()
69 <    #arch = scram.getArch()
67 >    def realSchedParams(self, cfg_params):
68 >        """
69 >        Return dictionary with specific parameters, to use with real scheduler
70 >        """
71  
72 <    if self.selectNoInput:
73 <      return [True]
72 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
73 >        params = {'tmpDir':tmpDir}
74 >        return params
75  
76  
77 <  def decodeLogInfo(self, file):
78 <    """
79 <    Parse logging info file and return main info
80 <    """
87 <    import CondorGLoggingInfo
88 <    loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
89 <    reason = loggingInfo.decodeReason(file)
90 <    return reason
77 >    def listMatch(self, seList, full):
78 >        """
79 >        Check the compatibility of available resources
80 >        """
81  
82 +        if self.selectNoInput:
83 +            return [True]
84 +        else:
85 +            return SchedulerLocal.listMatch(self, seList, full)
86  
93  def wsExitFunc(self):
94    """
95    """
96    txt = '\n'
97    txt += '#\n'
98    txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
99    txt += '#\n\n'
87  
88 <    txt += 'func_exit() { \n'
89 <    txt += self.wsExitFunc_common()
88 >    def decodeLogInfo(self, fileName):
89 >        """
90 >        Parse logging info file and return main info
91 >        """
92  
93 <    txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
94 <    txt += '    cp  ${out_files}.tgz $ORIG_WD/\n'
95 <    txt += '    cp  crab_fjr_$NJob.xml $ORIG_WD/\n'
93 >        import CondorGLoggingInfo
94 >        loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
95 >        reason = loggingInfo.decodeReason(fileName)
96 >        return reason
97  
108    txt += '    exit $job_exit_code\n'
109    txt += '}\n'
98  
99 <    return txt
99 >    def wsExitFunc(self):
100 >        """
101 >        Returns the part of the job script which runs prior to exit
102 >        """
103  
104 <  def wsInitialEnvironment(self):
105 <    """
106 <    Returns part of a job script which does scheduler-specific work.
107 <    """
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 $_CONDOR_SCRATCH_DIR/\n'
114 >        txt += '    cp  crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\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`
126 <    echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
133 >    echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
134      if [ -e ../default.tgz ] ;then
135        echo "Found ISB in parent directory (Local Condor)"
136        cp ../default.tgz $_CONDOR_SCRATCH_DIR
# Line 132 | Line 139 | if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CO
139   fi
140   """
141  
142 <    return txt
142 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines