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

Comparing COMP/CRAB/python/ScriptWriter.py (file contents):
Revision 1.2 by nsmirnov, Tue Jun 7 07:21:04 2005 UTC vs.
Revision 1.3 by nsmirnov, Mon Jun 20 10:13:11 2005 UTC

# Line 11 | Line 11 | class ScriptWriter:
11      def __init__(self, template):
12          # pattern -> action
13          self.actions = {
14 <            'title' : self.title_,
15 <            'setup_monitoring' : None,
16 <            'setup_scheduler_environment' : None,
17 <            'setup_jobtype_environment' : None,
18 <            'copy_input_data' : None,
19 <            'build_executable' : self.buildExe_,
20 <            'run_executable' : self.runExe_,
21 <            'stop_monitoring' : None,
22 <            'move_output' : None,
23 <            'register_results' : None,
24 <            'make_summary' : None,
25 <            'notify' : None
14 >            'title'                       : self.title_,
15 >            'setup_scheduler_environment' : self.setupSchedulerEnvironment_,
16 >            'setup_jobtype_environment'   : self.setupJobTypeEnvironment_,
17 >            'build_executable'            : self.buildExe_,
18 >            'run_executable'              : self.runExe_,
19 >            'rename_output'               : self.renameOutput_,
20 >            'register_results'            : None
21              }
22          
23          self.template = template
# Line 71 | Line 66 | class ScriptWriter:
66          txt += ' (version '+common.prog_version_str+').\n'
67          return txt
68      
69 <    def setupEnvironment(self, script, nj):
75 <        """ Write SetupEnvironment part of a job script."""
76 <
77 <        script.write('#\n')
78 <        script.write('# SETUP ENVIRONMENT\n')
79 <        script.write('#\n')
80 <        #TODO
81 <        #common.scheduler.writeScript_SetupEnvironment(script, nj)
82 <        #common.job_list[nj].type().writeScript_SetupEnvironment(script, nj)
83 <        script.write('#\n')
84 <        script.write('# END OF SETUP ENVIRONMENT\n')
85 <        script.write('#\n')
86 <        return
87 <
88 <    def copyInputData(self, script, nj):
89 <        #TODO
90 <        #common.scheduler.writeScript_CopyInputData(script, nj)
91 <        return
92 <
93 <    def addFiles(self, script, nj):
69 >    def setupSchedulerEnvironment_(self):
70          """
71 <        Add into the script the content of some job-specific files.
71 >        Returns part of a job script which does scheduler-specific work.
72          """
73 <        #TODO: ???
74 <        #common.job_list.type().writeScript_AddFiles(script, nj)
99 <        return
73 >        txt = common.scheduler.wsSetupEnvironment()
74 >        return txt
75  
76 +    def setupJobTypeEnvironment_(self):
77 +        """
78 +        Returns part of a job script which does scheduler-specific work.
79 +        """
80 +        jbt = common.job_list.type()
81 +        txt = jbt.wsSetupEnvironment(self.nj)
82 +        return txt
83 +        
84      def buildExe_(self):
85          """
86          Returns part of a job script which builds the binary executable.
87          """
88          jbt = common.job_list.type()
89  
90 <        txt = jbt.writeScript_BuildExe(self.nj)
90 >        txt = jbt.wsBuildExe(self.nj)
91  
92          job = common.job_list[self.nj]
93          exe = job.type().executableName()
# Line 116 | Line 99 | class ScriptWriter:
99          """
100          Returns part of a job script which executes the application.
101          """
119        #jbt = common.job_list.type()
120
121        #jbt.writeScript_RunExe(script, self.nj)
102          return '$executable\n'
103  
104 <    def move_output(self, script,nj):
105 <        return
106 <
107 <    def registerResults(self, script,nj):
108 <        return
109 <
110 <    def tail(self, script, nj):
111 <        """ Write a tailer part of a job script."""
132 <
133 <        script.write('#\n')
134 <        script.write('# TAIL\n')
135 <        script.write('#\n')
136 <        script.write('pwd\n')
137 <        script.write('echo "ls -Al"\n')
138 <        script.write('ls -Al\n')
139 <        
140 <        #if common.use_jam:
141 <        #    script.write('list=`ls -Al` \n')
142 <        #    script.write('perl $RUNTIME_AREA/'+ common.run_jam +' --name='+common.output_jam+' --event=List_end --det="$list" \n')
143 <        #    pass
144 <  
145 <        script.write('#\n')
146 <
147 <        #TODO
148 <        #if common.flag_mksmry:
149 <        #    script.write('chmod u+x postprocess\n')
150 <        #    script.write('cat `ls -1 *.stdout` | ./postprocess | sort | uniq > sumry\n')
151 <        #    pass
152 <
153 <        #TODO
154 <        # summary file may need jobtype specific info, e.g.
155 <        # for CMS Oscar it needs Pool catalogues,
156 <        # so we delegate operations to the related jobtype object.
157 <        #common.job_list.type().writeScript_Tail(script, nj)
158 <    
159 <        #if common.flag_notify:
160 <        #    script.write('if [[ $executable_exit_status -eq 0 && $replica_exit_status -eq 0 ]]; then\n')
161 <        #    if common.flag_mksmry:
162 <        #        script.write('    cat sumry | mail -s "job_finished" '+
163 <        #                     common.email +'\n')
164 <        #    else:
165 <        #        script.write('    mail -s "job_finished" '+
166 <        #                     common.email +' <<EOF\n')
167 <        #        n1 = nj + 1
168 <        #        script.write('Job # '+`n1`+' finished\n')
169 <        #        script.write('EOF\n')
170 <        #        pass
171 <        #    script.write('fi\n')
172 <        #    pass
173 <
174 <        script.write('echo ">>>>>>>> End of job at date `date`" \n')
175 <        
176 <        #if common.use_jam:
177 <        #    script.write('perl $RUNTIME_AREA/'+ common.run_jam +' --name='+common.output_jam+' --event=exit --det="$exit_status" \n')
178 <        #    pass
179 <        
180 <        script.write('exit $exit_status\n')
181 <        return
182 <
104 >    def renameOutput_(self):
105 >        """
106 >        Returns part of a job script which renames output files.
107 >        """
108 >        jbt = common.job_list.type()
109 >        txt = '\n'
110 >        txt += jbt.wsRenameOutput(self.nj)
111 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines