ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/crab_help.py
Revision: 1.13
Committed: Fri Apr 14 11:32:55 2006 UTC (19 years ago) by slacapra
Content type: text/x-python
Branch: MAIN
Changes since 1.12: +69 -31 lines
Log Message:
update for Famos, RB and other stuff

File Contents

# User Rev Content
1 nsmirnov 1.1
2     ###########################################################################
3     #
4     # H E L P F U N C T I O N S
5     #
6     ###########################################################################
7    
8     import common
9    
10     import sys, os, string
11     import tempfile
12    
13     ###########################################################################
14     def usage():
15     usa_string = common.prog_name + """ [options]
16 slacapra 1.3
17     The most useful general options (use '-h' to get complete help):
18    
19 slacapra 1.4 -create n -- Create only n jobs. Default is 'all'. bunch_creation will become obsolete
20     -submit n -- Submit only n jobs. Default is 0. bunch_submission will become obsolete
21     -status [range] -- check status of all jobs: if range is defined, only of selected jobs
22     -getoutput [range] -- get back the output of all jobs: if range is defined, only of selected jobs
23     -kill [range] -- kill submitted jobs
24 fanzago 1.12 -cancelAndResubmit [range] -- kill and resubmit submitted jobs
25 slacapra 1.4 -clean -- gracefully cleanup the idrectory of a task
26     -testJdl [range] -- check if resources exist which are compatible with jdl
27     -postMortem [range] -- provide a file with information useful for post-mortem analysis of the jobs
28     -continue [dir] | -c [dir] -- Apply command to task stored in [dir].
29 nsmirnov 1.1 -h [format] -- Detailed help. Formats: man (default), tex, html.
30     -cfg fname -- Configuration file name. Default is 'crab.cfg'.
31 slacapra 1.4 -debug N -- set the verbosity level to N
32 nsmirnov 1.1 -v -- Print version and exit.
33    
34 slacapra 1.4 "range" has syntax "n,m,l-p" which correspond to [n,m,l,l+1,...,p-1,p] and all possible combination
35    
36 nsmirnov 1.1 Example:
37     crab.py -create 1 -submit 1
38     """
39     print usa_string
40     sys.exit(2)
41    
42     ###########################################################################
43     def help(option='man'):
44     help_string = """
45     =pod
46    
47     =head1 NAME
48    
49     B<CRAB>: B<C>ms B<R>emote B<A>nalysis B<B>uilder
50    
51 slacapra 1.3 """+common.prog_name+""" version: """+common.prog_version_str+"""
52 nsmirnov 1.1
53     This tool _must_ be used from an User Interface and the user is supposed to
54 slacapra 1.3 have a valid GRID certificate.
55 nsmirnov 1.1
56     =head1 SYNOPSIS
57    
58 slacapra 1.13 B<"""+common.prog_name+"""> [I<options>] [I<command>]
59 nsmirnov 1.1
60     =head1 DESCRIPTION
61    
62 slacapra 1.3 CRAB is a Python program intended to simplify the process of creation and submission into grid environment of CMS analysis jobs.
63 nsmirnov 1.1
64 slacapra 1.3 Parameters for CRAB usage and configuration are provided by the user changing the configuration file B<crab.cfg>.
65 nsmirnov 1.1
66 slacapra 1.3 CRAB generates scripts and additional data files for each job. The produced scripts are submitted directly to the Grid. CRAB makes use of BOSS to interface to the grid scheduler, as well as for logging and bookkeeping and eventually real time monitoring.
67 nsmirnov 1.1
68 slacapra 1.13 CRAB supports any ORCA based executable, including the user provided one, and deals with the output produced by the executable. CRAB provides an interface with CMS data discovery services (today RefDB and PubDB), which are completely hidden to the final user. It also splits a task (such as analyzing a whole dataset) into smaller jobs, according with user requirements. CRAB support also FAMOS based jobs.
69 nsmirnov 1.1
70 slacapra 1.13 CRAB web page is available at
71    
72     I<http://cmsdoc.cern.ch/cms/ccs/wm/www/Crab/>
73 slacapra 1.6
74 nsmirnov 1.1 =head1 BEFORE STARTING
75    
76 slacapra 1.3 =over 4
77    
78     =item B<A)>
79    
80     Develop your code in your ORCA working area (both I<scram> and I<scramv1> based ORCA are supported).
81 slacapra 1.13 Do anything which is needed to run interactively your executable, including the setup or run time environment (I<eval `scram(v1) runtime -sh|csh`>), a suitable I<.orcarc>, etc.
82 slacapra 1.3
83     =item B<B)>
84    
85     Source B<crab.(c)sh> from the CRAB installation area, which have been setup either by you or by someone else for you.
86     Modify the CRAB configuration file B<crab.cfg> according to your need: see below for a complete list. The most important parameters are the following:
87    
88     =over 4
89    
90     =item B<Mandatory!>
91    
92 slacapra 1.8 =item o dataset, owner to be accessed: also data_tiers if you want more than the one pointed by owner
93 slacapra 1.3
94     =item o the ORCA executable name (e.g. ExDigiStatistics): can be a user built executable or one available from the standard release (such as ExDigiStatistics)
95    
96     =item o the name of output file(s) produced by ORCA executable.
97    
98     =item o job splitting directives: the total number of events to analyze, the number of events for each job or the number of jobs and eventually the first event
99    
100     =item o the B<.orcarc> card to be used. This card will be modified by crab for data access and according to the job splitting. Use the very same cars you used in your interactive test: CRAB will modify what is needed.
101    
102     =item B<Might be useful:>
103    
104     =item o Comma separated list of files to be submitted via input sandbox. The files will be put in the working directory on WN. It's user responsibility to actually use them!
105    
106     =item o output_dir e log_dir, path of directory where crab will put the std_error and std_output of job. If these parameters are commented, error and output will be put into the directory where sh and jdl script are (crab_0_date_time).
107    
108     =item B<Optional:>
109    
110     =item o the name of UI directory where crab will create jobs. By default the name is "crab_data_time"
111    
112     =back
113    
114     =item B<C)>
115    
116 slacapra 1.13 As stated before, you need to have a valid grid certificate (see CRAB web page for instruction) to submit to the grid. You need also a valid proxy: if you don't have it (or if it is too short), CRAB will issues that command for you. From version 1_1_0 CRAB uses I<voms> and I<myproxy> server to renew the proxy length, so if your proxy expires while your job is on the grid, the proxy will be extended by the myproxy server, to which you have delegated, and your job will continue. The voms proxy lenght is I<24> hours, while the myproxy delegation extends for I<7> days.
117 slacapra 1.3
118     At CERN, you can use "lxplus" as a UI by sourcing the file B</afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.(c)sh>
119    
120     =back
121 nsmirnov 1.1
122     =head1 HOW TO RUN CRAB FOR THE IMPATIENT USER
123    
124     Please, read all anyway!
125 slacapra 1.3
126 slacapra 1.4 ~>crab.py -create 2
127 nsmirnov 1.1 create 2 jobs (no submission!)
128 slacapra 1.4
129     ~>crab.py -submit 2 -continue [ui_working_dir]
130     submit 2 jobs, the ones already created (-continue)
131    
132     ~>crab.py -create 2 -submit 2
133 nsmirnov 1.1 create _and_ submit 2 jobs
134    
135 slacapra 1.4 ~>crab.py -status
136     check the status of all jobs
137    
138     ~>crab.py -getoutput
139     get back the output of all jobs
140    
141     =head1 COMMAND
142    
143     =over 4
144    
145     =item B<-create n>
146    
147     Create n jobs: 'n' is either a positive integer or 'all' (default).
148     The maximum number of jobs depens on dataset and splittig directives: if more are asked for, a warning is issued and job are created up to the maximum possible. This set of identical jobs accessing the same dataset are defined as a task.
149     This command create a directory with default name is I<crab_0_date_time> (can be changed via ui_working_dir parameter, see below). Inside this directory it is placed whatever is needed to submit your jobs. Also the output of your jobs (once finished) will be place there (see after). Do not cancel by hand this directory: rather use -clean (see).
150     See also I<-continue>.
151    
152     =item B<-submit n>
153    
154     Submit n jobs: 'n' is either a positive integer or 'all'. Default is all.
155     This option must be used in conjunction with -create (to create and submit immediately) or with -continue, to submit previously created jobs. Failure to do so will stop CRAB and generate an error message.
156     See also I<-continue>.
157    
158     =item B<-continue [dir] | -c [dir]>
159    
160     Apply the action on the task stored on directory [dir]. If the task directory is the standard one (crab_0_date_time), the more recent in time is taken. Any other directory must be specified.
161     Basically all commands (but -create) need -continue, so it is automatically assumed, with exception of -submit, where it must be explicitly used. Of course, the standard task directory is used in this case.
162    
163     =item B<-status [range]>
164 nsmirnov 1.1
165 slacapra 1.4 Check the status of the jobs, in all states. If BOSS real time monitor is enabled, also some real time information are available, otherwise all the info will be available only after the output retrieval. See I<range> below for syntax.
166 nsmirnov 1.1
167 slacapra 1.4 =item B<-getoutput [range]>
168 nsmirnov 1.1
169 slacapra 1.4 Retrieve the output declared by the user via the output sandbox. By default the output will be put in task working dir under I<res> subdirectory. This can be changed via config parameters. See I<range> below for syntax.
170 nsmirnov 1.1
171 slacapra 1.4 =item B<-resubmit [range]>
172 nsmirnov 1.1
173 slacapra 1.4 Resubmit jobs which have been previously submitted and have been either I<killed> or are I<aborted>. See I<range> below for syntax.
174 nsmirnov 1.1
175 slacapra 1.4 =item B<-kill [range]>
176 nsmirnov 1.1
177 slacapra 1.4 Kill (cancel) jobs which have been submitted to the scheduler. A range B<must> be used in all cases, no default value is set.
178 nsmirnov 1.1
179 slacapra 1.4 =item B<-testJdl [range]>
180 nsmirnov 1.1
181 slacapra 1.4 Check if the job can find compatible resources. It's equivalent of doing I<edg-job-list-match> on edg.
182 nsmirnov 1.1
183 slacapra 1.4 =item B<-postMortem [range]>
184 nsmirnov 1.1
185 slacapra 1.4 Produce a file (via I<edg-job-logging-info -v 2>) which might help in undertanding grid related problem for a job.
186 nsmirnov 1.1
187 slacapra 1.13 =item B<-list [range]>
188    
189     Dump technical informations about jobs: for developers only.
190    
191 slacapra 1.4 =item B<-clean [dir]>
192 nsmirnov 1.1
193 slacapra 1.4 Clean up (i.e. erase) the task working directory after a check whether there are still running jobs. In case, you are notified and asked to kill them or retrieve their output. B<Warning> this will eventually delete also the output produced by the task (if any)!
194 nsmirnov 1.1
195 slacapra 1.4 =item B<-help [format] | -h [format]>
196 nsmirnov 1.1
197 slacapra 1.4 This help. It can be produced in three different I<format>: I<man> (default), I<tex> and I<html>.
198 nsmirnov 1.1
199 slacapra 1.4 =item B<-v>
200 nsmirnov 1.1
201 slacapra 1.4 Print the version and exit.
202 nsmirnov 1.1
203 slacapra 1.4 =item B<range>
204 nsmirnov 1.1
205 slacapra 1.13 The range to be used in many of the above commands has the following syntax. It is a comma separated list of jobs ranges, each of which may be a job number, or a job range of the form first-last.
206 slacapra 1.4 Example: 1,3-5,8 = {1,3,4,5,8}
207 nsmirnov 1.1
208 slacapra 1.6 =back
209    
210 slacapra 1.4 =head1 OPTION
211 nsmirnov 1.1
212 slacapra 1.6 =over 4
213    
214 slacapra 1.4 =item B<-cfg [file]>
215 nsmirnov 1.1
216 slacapra 1.4 Configuration file name. Default is B<crab.cfg>.
217 nsmirnov 1.1
218 slacapra 1.4 =item B<-debug [level]>
219 nsmirnov 1.1
220 slacapra 1.13 Set the debug level: high number for high verbosity.
221 nsmirnov 1.1
222 slacapra 1.6 =back
223    
224 slacapra 1.5 =head1 CONFIGURATION PARAMETERS
225    
226 slacapra 1.10 All the parameter describe in this section can be defined in the CRAB configuration file. The configuration file has different sections: [CRAB], [USER], etc. Each parameter must be defined in its proper section. An alternative way to pass a config parameter to CRAB is to to it via command line interface; the syntax is: crab.py -SECTION.key value . For example I<crab.py -USER.outputdir MyDirWithFullPath> .
227 slacapra 1.5 The parameters passed to CRAB at the creation step are stored, so they cannot be changed by changing the original crab.cfg . On the other hand the task is protected from any accidental change. If you want to change any parameters, this require the creation of a new task.
228 slacapra 1.6 Mandatory parameters are flagged with a *.
229 slacapra 1.5
230     B<[CRAB]>
231 slacapra 1.6
232 slacapra 1.13 =over 4
233 slacapra 1.5
234 slacapra 1.6 =item B<jobtype *>
235 slacapra 1.5
236 slacapra 1.13 The type of the job to be executed: I<orca> I<famos> jobtypes are supported
237 slacapra 1.6
238     =item B<scheduler *>
239    
240     The scheduler to be used: I<edg> is the grid one. In later version also other scheduler (local and grid) will be possible, including eg glite, condor-g, lsf, pbs, etc...
241 slacapra 1.5
242     =back
243    
244 slacapra 1.13 B<[ORCA]>
245 slacapra 1.6
246 slacapra 1.13 =over 4
247 slacapra 1.6
248     =item B<dataset *>
249    
250     The dataset the user want to analyze.
251    
252     =item B<owner *>
253    
254 slacapra 1.13 The owner name which the user want to access. These two parameter can be found using data discovery tool: for the time being, RefDB/PubDB. See production page (linked also from CRAB web page) for access to the list of available dataset/owner
255 slacapra 1.6
256     =item B<data_tier>
257    
258     The data tiers the user want to access: by deafult, only the tier corresponding to the given owner will be provided. If user needs more, he B<must> specify the full list.
259     Syntax: comma separated list, known tiers are I<Hits>,I<Digi>, I<DST>
260    
261     =item B<order_catalogs>
262    
263     Define the order of the catalogs which will be put in the generated .orcarc fragment: for expert use only.
264    
265     =item B<executable *>
266    
267     The ORCA executable the user want to run on remote site. This must be on the I<path> of the user at the time of the creation of the jobs, so it's mandatory to issue the usual I<eval `scramv1 runtim -(c)sh`> from user ORCA working area before creating jobs. A warning will be prompted if the executable is not found in the path.
268    
269     =item B<script_exe>
270    
271     Name of a script that the user want to execute on remote site: full path must be provided. The ORCA executable whcih is executed by the script must be declared in any case, since CRAB must ship it to the remote site. The script can do anything, but change directory before the ORCA executable start. On the remote WN, the full scram-based environment will be found.
272    
273     =item B<output_file *>
274    
275     Output files as produced by the executable: comma separated list of all the files. These are the file names which are produced by the executable also in the interactive environment. The output files will be modified by CRAB when returned in order to cope with the job splitting, by adding a "_N" to each file.
276    
277 slacapra 1.13 =item B<orcarc_file *>
278    
279     User I<.orcarc> file: if it is not in the current directory, full path is needed. Use the very same file you used for your interactive test: CRAB will modify it according to data requested and splitting directives.
280    
281     =back
282    
283     B<[FAMOS]>
284    
285     =over 4
286    
287     =item B<input_lfn>
288    
289     LFN of the input file registered into the LFC catalog
290    
291     =item B<events_per_ntuple>
292    
293     number of events per ntuple
294    
295     =item B<input_pu_lfn>
296    
297     LFN for the input pile-up ntuples (already registered to LFC)
298    
299     =item B<number_pu_ntuples>
300    
301     number of pile-up ntuples accessed per job
302    
303     =item B<executable>
304    
305     FAMOS executable: user must provide the executable into his personal scram area.
306    
307     =item B<script_exe>
308    
309     or the script that calls the executable...
310    
311     =item B<output_file>
312    
313     Output files produced by executable: comma separated list, can be empty but mut be present!
314    
315     =item B<orcarc_file>
316    
317     orcarc card provided by user (if not in current directory, the full path must to be provided) NB the file must exist (could be empty)
318    
319     =back
320    
321     B<[USER]>
322    
323     =over 4
324    
325 slacapra 1.6 =item B<additional_input_files>
326    
327     Any additional input file you want to ship to WN: comma separated list. These are the files which might be needed by your executable: they will be placed in the WN working dir. Please note that the full I<Data> directory of your private ORCA working are will be send to WN (if present).
328    
329     =item B<first_event>
330    
331     The first event the user want to analyze in the dataset. Default is 0.
332    
333     =item B<total_number_of_events *>
334    
335     The total number of events the user want to analyze. I<-1> means all available events. If first even is set, a gran total of (total available events)-(first event) will be analyzed.
336    
337     =item B<job_number_of_events *>
338    
339     Numer of event for each job. Either this or I<total_number_of_jobs> must be defined.
340    
341     =item B<total_number_of_jobs>
342    
343     Total numer of jobs in which the task will be splitted. It is incompatible with previous I<job_number_of_events>. If both are set, this card will be ignored and a warning message issued.
344    
345     =item B<ui_working_dir>
346    
347     Name of the working directory for the current task. By default, a name I<crab_0_(date)_(time)> will be used. If this card is set, any CRAB command which require I<-continue> need to specify also the name of the working directory. A special syntax is also possible, to reuse the name of the dataset provided before: I<ui_working_dir : %(dataset)s> . In this case, if eg the dataset is SingleMuon, the ui_working_dir will be set to SingleMuon as well.
348    
349     =item B<return_data *>
350    
351     The output produced by the ORCA executable on WN is returned (via output sandbox) to the UI, by issuing the I<-getoutput> command. B<Warning>: this option should be used only for I<small> output, say less than 10MB, since the sandbox cannot accomodate big files. Depending on Resource Broker used, a size limit on output sandbox can be applied: bigger files will be truncated. To be used in alternative to I<copy_data>.
352    
353     =item B<outputdir>
354    
355 slacapra 1.9 To be used together with I<return_data>. Directory on user interface where to store the ORCA output. Full path is mandatory, "~/" is not allowed: the defaul location of returned output is ui_working_dir/res .
356 slacapra 1.6
357     =item B<logdir>
358    
359 slacapra 1.9 To be used together with I<return_data>. Directory on user interface where to store the ORCA standard output and error. Full path is mandatory, "~/" is not allowed: the defaul location of returned output is ui_working_dir/res .
360 slacapra 1.6
361     =item B<copy_data *>
362    
363     The output (only the ORCA one, not the std-out and err) is copied to a Storage Element of your choice (see below). To be used as an alternative to I<return_data> and recomended in case of large output.
364    
365     =item B<storage_element>
366    
367     To be used together with I<copy_data>. Storage Element name.
368    
369     =item B<storage_path>
370    
371     To be used together with I<copy_data>. Path where to put output files on Storage Element. Full path is needed, and the directory must be writeable by all.
372    
373     =item B<register_data>
374    
375     To be used together with I<copy_data>. Register output files to RLS catalog: for advanced LCG users.
376    
377     =item B<lfn_dir>
378    
379     To be used together with I<register_data>. Path for the Logical File Name.
380    
381     =item B<use_central_bossDB>
382    
383     Use central BOSS DB instead of one for each task: the DB must be already been setup. See installation istruction for more details.
384    
385     =item B<use_boss_rt>
386    
387     Use BOSS real time monitoring.
388    
389     =back
390    
391 slacapra 1.5 B<[EDG]>
392 nsmirnov 1.1
393 slacapra 1.13 =over 4
394 slacapra 1.6
395     =item B<lcg_version>
396 nsmirnov 1.1
397 slacapra 1.6 Version of LCG middleware to be used.
398 nsmirnov 1.1
399 slacapra 1.13 =item B<RB>
400 slacapra 1.6
401 slacapra 1.13 Which RB you want to use instead of the default one. The ones available for CMS are I<CERN> and I<CNAF>: the configuration files needed to change the broker will be automatically downloaded from CRAB web page and used. If the files are already present on the working directory they will be used.
402 slacapra 1.6
403     =item B<requirements>
404    
405     Any other requirements to be add to JDL. Must be written in compliance with JDL syntax (see LCG user manual for further info). No requirement on Computing element must be set.
406    
407     =item B<max_cpu_time>
408    
409     Maximum CPU time needed to finish one job. It will be used to select a suitable queue on the CE. Time in minutes.
410    
411     =item B<max_wall_clock_time>
412    
413     Same as previous, but with real time, and not CPU one.
414    
415     =item B<CE_black_list>
416    
417     All the CE whose name contains the following strings (comma separated list) will not be considered for submission. Use the dns domain (eg fnal, cern, ifae, fzk, cnaf, lnl,....)
418    
419     =item B<CE_white_list>
420    
421     Only the CE whose name contains the following strings (comma separated list) will be considered for submission. Use the dns domain (eg fnal, cern, ifae, fzk, cnaf, lnl,....)
422    
423     =item B<virtual_organization>
424    
425     You don't want to change this: it's cms!
426    
427     =item B<retry_count>
428    
429     Number of time the grid will try to resubmit your job in case of grid related problem.
430    
431     =back
432    
433 nsmirnov 1.1 =head1 FILES
434    
435 slacapra 1.6 I<crab> uses a configuration file I<crab.cfg> which contains configuration parameters. This file is written in the INI-style. The default filename can be changed by the I<-cfg> option.
436 nsmirnov 1.1
437 slacapra 1.6 I<crab> creates by default a working directory 'crab_0_E<lt>dateE<gt>_E<lt>timeE<gt>'
438 nsmirnov 1.1
439     I<crab> saves all command lines in the file I<crab.history>.
440    
441 slacapra 1.6
442 nsmirnov 1.1 =head1 HISTORY
443    
444 slacapra 1.6 B<crab> is a tool for the CMS analysis on the grid environment. It is based on the ideas from CMSprod, a production tools implemented originally by Nikolai Smirnov.
445 nsmirnov 1.1
446     =head1 AUTHORS
447    
448     """
449     author_string = '\n'
450     for auth in common.prog_authors:
451     #author = auth[0] + ' (' + auth[2] + ')' + ' E<lt>'+auth[1]+'E<gt>,\n'
452     author = auth[0] + ' E<lt>' + auth[1] +'E<gt>,\n'
453     author_string = author_string + author
454     pass
455     help_string = help_string + author_string[:-2] + '.'\
456     """
457    
458     =cut
459     """
460    
461     pod = tempfile.mktemp()+'.pod'
462     pod_file = open(pod, 'w')
463     pod_file.write(help_string)
464     pod_file.close()
465    
466     if option == 'man':
467     man = tempfile.mktemp()
468     pod2man = 'pod2man --center=" " --release=" " '+pod+' >'+man
469     os.system(pod2man)
470     os.system('man '+man)
471     pass
472     elif option == 'tex':
473     fname = common.prog_name+'-v'+common.prog_version_str
474     tex0 = tempfile.mktemp()+'.tex'
475     pod2tex = 'pod2latex -full -out '+tex0+' '+pod
476     os.system(pod2tex)
477     tex = fname+'.tex'
478     tex_old = open(tex0, 'r')
479     tex_new = open(tex, 'w')
480     for s in tex_old.readlines():
481     if string.find(s, '\\begin{document}') >= 0:
482     tex_new.write('\\title{'+common.prog_name+'\\\\'+
483     '(Version '+common.prog_version_str+')}\n')
484     tex_new.write('\\author{\n')
485     for auth in common.prog_authors:
486     tex_new.write(' '+auth[0]+
487     '\\thanks{'+auth[1]+'} \\\\\n')
488     tex_new.write('}\n')
489     tex_new.write('\\date{}\n')
490     elif string.find(s, '\\tableofcontents') >= 0:
491     tex_new.write('\\maketitle\n')
492     continue
493     elif string.find(s, '\\clearpage') >= 0:
494     continue
495     tex_new.write(s)
496     tex_old.close()
497     tex_new.close()
498     print 'See '+tex
499     pass
500     elif option == 'html':
501     fname = common.prog_name+'-v'+common.prog_version_str+'.html'
502     pod2html = 'pod2html --title='+common.prog_name+\
503     ' --infile='+pod+' --outfile='+fname
504     os.system(pod2html)
505     print 'See '+fname
506     pass
507    
508     sys.exit(0)