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.7 by ewv, Tue Jun 10 17:46:00 2008 UTC vs.
Revision 1.21 by spiga, Fri Mar 6 16:54:42 2009 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:
14 < #  methods starting with 'ws' are responsible to provide
15 < #  corresponding part of the job script ('ws' stands for 'write script').
13 > import socket
14 > import sha
15  
16   class SchedulerCondor(SchedulerLocal) :
17 +    """
18 +    Class to implement the vanilla (local) Condor scheduler
19 +     Naming convention:  Methods starting with 'ws' provide
20 +     the corresponding part of the job script
21 +     ('ws' stands for 'write script').
22 +    """
23  
24 <  def __init__(self):
25 <    Scheduler.__init__(self,"CONDOR")
26 <    return
27 <
28 <
29 <  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)
24 >    def __init__(self):
25 >        SchedulerLocal.__init__(self,"CONDOR")
26 >        self.datasetPath   = None
27 >        self.selectNoInput = None
28 >        self.return_data   = 0
29 >        self.copy_data     = 0
30  
31 <    return
31 >        self.environment_unique_identifier = None
32 >        return
33  
34  
35 <  def sched_parameter(self,i,task):
36 <    """
37 <    Return scheduler-specific parameters
38 <    """
47 <    index = int(common._db.nJobs()) - 1
48 <    sched_param= ''
35 >    def configure(self, cfg_params):
36 >        """
37 >        Configure the scheduler with the config settings from the user
38 >        """
39  
40 <    for i in range(index):
41 <      pass
40 >        SchedulerLocal.configure(self, cfg_params)
41 >        taskHash = sha.new(common._db.queryTask('name')).hexdigest()
42 >        self.environment_unique_identifier = "https://" + \
43 >            socket.gethostname() + '/' + taskHash + "/${NJob}"
44  
45 <    return sched_param
45 >        try:
46 >            tmp =  cfg_params['CMSSW.datasetpath']
47 >            if tmp.lower() == 'none':
48 >                self.datasetPath = None
49 >                self.selectNoInput = 1
50 >            else:
51 >                self.datasetPath = tmp
52 >                self.selectNoInput = 0
53 >        except KeyError:
54 >            msg = "Error: datasetpath not defined "
55 >            raise CrabException(msg)
56  
57 +        self.return_data = cfg_params.get('USER.return_data', 0)
58 +        self.copy_data   = cfg_params.get("USER.copy_data", 0)
59  
60 <  def realSchedParams(self,cfg_params):
57 <    """
58 <    Return dictionary with specific parameters, to use
59 <    with real scheduler
60 <    """
60 >        if int(self.copy_data) == 1:
61  
62 <    tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
63 <    params = {'tmpDir':tmpDir}
64 <    return  params
62 >            self.proxyValid = 0
63 >            self.dontCheckProxy = int(cfg_params.get("EDG.dont_check_proxy", 0))
64 >            self.proxyServer = cfg_params.get("EDG.proxy_server", 'myproxy.cern.ch')
65 >            common.logger.debug(5,'Setting myproxy server to ' + self.proxyServer)
66  
67 +            self.group = cfg_params.get("EDG.group", None)
68 +            self.role  = cfg_params.get("EDG.role", None)
69 +            self.VO    = cfg_params.get('EDG.virtual_organization', 'cms')
70  
71 <  def listMatch(self, seList, full, onlyOSG=True):
68 <    """
69 <    Check the compatibility of available resources
70 <    """
71 >            self.checkProxy()
72  
73 <    # 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
73 >        self.role  = None
74  
75 <    #scram = Scram.Scram(None)
76 <    #versionCMSSW = scram.getSWVersion()
77 <    #arch = scram.getArch()
75 >        return
76  
79    if self.selectNoInput:
80      return [True]
77  
78 +    def sched_parameter(self, i, task):
79 +        """
80 +        Return scheduler-specific parameters
81 +        """
82  
83 <  def decodeLogInfo(self, file):
84 <    """
85 <    Parse logging info file and return main info
86 <    """
87 <    import CondorGLoggingInfo
88 <    loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
89 <    reason = loggingInfo.decodeReason(file)
90 <    return reason
83 >        index = int(common._db.nJobs()) - 1
84 >        schedParam = ''
85  
86 +        for i in range(index):
87 +            pass
88  
89 <  def wsExitFunc(self):
94 <    """
95 <    """
96 <    txt = '\n'
97 <    txt += '#\n'
98 <    txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
99 <    txt += '#\n\n'
100 <
101 <    txt += 'func_exit() { \n'
102 <    txt += '    if [ $PYTHONPATH ]; then \n'
103 <    txt += '        update_fjr\n'
104 <    txt += '    fi\n'
105 <    txt += '    for file in $filesToCheck ; do\n'
106 <    txt += '        if [ -e $file ]; then\n'
107 <    txt += '            echo "tarring file $file in  $out_files"\n'
108 <    txt += '        else\n'
109 <    txt += '            echo "WARNING: output file $file not found!"\n'
110 <    txt += '        fi\n'
111 <    txt += '    done\n'
112 <    txt += '    final_list=$filesToCheck\n'
113 <    txt += '    echo "JOB_EXIT_STATUS = $job_exit_code"\n'
114 <    txt += '    echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n'
115 <    txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
116 <    txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
117 <    txt += '    cp  ${out_files}.tgz $ORIG_WD/\n'
118 <    txt += '    cp  crab_fjr_$NJob.xml $ORIG_WD/\n'
89 >        return schedParam
90  
120    txt += '    exit $job_exit_code\n'
121    txt += '}\n'
91  
92 <    return txt
92 >    def realSchedParams(self, cfg_params):
93 >        """
94 >        Return dictionary with specific parameters, to use with real scheduler
95 >        """
96  
97 <  def wsInitialEnvironment(self):
98 <    """
99 <    Returns part of a job script which does scheduler-specific work.
100 <    """
97 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
98 >        tmpDir = os.path.join(common.work_space.shareDir(),'.condor_temp')
99 >        jobDir = common.work_space.jobDir()
100 >        params = {'tmpDir':tmpDir,
101 >                  'jobDir':jobDir}
102 >        return params
103 >
104 >
105 >    def listMatch(self, seList, full):
106 >        """
107 >        Check the compatibility of available resources
108 >        """
109 >
110 >        return [True]
111 >
112 >
113 >    def decodeLogInfo(self, fileName):
114 >        """
115 >        Parse logging info file and return main info
116 >        """
117 >
118 >        import CondorGLoggingInfo
119 >        loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
120 >        reason = loggingInfo.decodeReason(fileName)
121 >        return reason
122 >
123 >
124 >    def wsCopyOutput(self):
125 >        """
126 >        Write a CopyResults part of a job script, e.g.
127 >        to copy produced output into a storage element.
128 >        """
129 >        txt = self.wsCopyOutput_comm()
130 >        return txt
131 >
132 >
133 >    def wsExitFunc(self):
134 >        """
135 >        Returns the part of the job script which runs prior to exit
136 >        """
137 >
138 >        txt = '\n'
139 >        txt += '#\n'
140 >        txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
141 >        txt += '#\n\n'
142 >
143 >        txt += 'func_exit() { \n'
144 >        txt += self.wsExitFunc_common()
145 >
146 >        txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
147 >        txt += '    cp  ${out_files}.tgz $_CONDOR_SCRATCH_DIR/\n'
148 >        txt += '    cp  crab_fjr_$NJob.xml $_CONDOR_SCRATCH_DIR/\n'
149 >
150 >        txt += '    exit $job_exit_code\n'
151 >        txt += '}\n'
152 >
153 >        return txt
154 >
155 >    def wsInitialEnvironment(self):
156 >        """
157 >        Returns part of a job script which does scheduler-specific work.
158 >        """
159 >
160 >        txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
161 >        txt += 'echo "Beginning environment"\n'
162 >        txt += 'printenv | sort\n'
163  
164 <    txt  = '\n# Written by SchedulerCondor::wsInitialEnvironment\n'
165 <    txt += 'echo "Beginning environment"\n'
166 <    txt += 'printenv | sort\n'
164 >        txt += 'middleware='+self.name()+' \n'
165 >        txt += 'if [ -e /opt/d-cache/srm/bin ]; then\n'
166 >        txt += '  export PATH=${PATH}:/opt/d-cache/srm/bin\n'
167 >        txt += 'fi\n'
168  
169 <    txt += 'middleware='+self.name()+' \n'
135 <    txt += """
169 >        txt += """
170   if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CONDOR_SCRATCH_DIR ]; then
171 <    ORIG_WD=`pwd`
138 <    echo "Change from $ORIG_WD to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
171 >    echo "cd to Condor scratch directory: $_CONDOR_SCRATCH_DIR"
172      if [ -e ../default.tgz ] ;then
173        echo "Found ISB in parent directory (Local Condor)"
174        cp ../default.tgz $_CONDOR_SCRATCH_DIR
# Line 144 | Line 177 | if [ $_CONDOR_SCRATCH_DIR ] && [ -d $_CO
177   fi
178   """
179  
180 <    return txt
180 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines