-
Notifications
You must be signed in to change notification settings - Fork 10
Submit script with crab
This page demonstrates the use of the CMS Remote Analysis Builder (CRAB) with a custom script instead of cmsRun
First, lets set up the environment
cmsrel CMSSW_5_3_18
cd CMSSW_5_3_18/src
cmsenv
source /cvmfs/cms.cern.ch/crab/crab.sh
Next we need the script we want to run. This example will print 'Hello CRAB!' on the screen and create a ROOT file named 'testing.root'.
echo "# write something to the console
echo "Hello CRAB!"
# create a dummy file
touch testing.root" > run.sh
chmod a+x run.sh
Finally, we need to create a CRAB config in order to submit our script to the grid. The example below tells CRAB which script to run and what output files to expect.
echo "[CRAB]
jobtype = cmssw
scheduler = remoteGlidein
use_server = 0
[CMSSW]
output_file = testing.root
datasetpath=None
pset=None
number_of_jobs=1
allow_NonProductionCMSSW = 1
[USER]
script_exe = run.sh
ui_working_dir = dummy
copy_data = 0
return_data = 1" > crab.cfg
Everything should be now ready to submit our script to the grid
crab -create -cfg crab.cfg
crab -submit -c dummy
Now it is time to wait. You can check the status of your job via
crab -status -c dummy
Once the job is done, it is time to get the output
crab -get -c dummy
should put all the output files into dummy/res
.
The standard output should contain our echo
:
cat dummy/res/CMSSW_1.stdout | grep CRAB
env var CRAB_UNIQUE_JOB_ID set to: kreczko_dummy_7qp08n_1_1_Yhj
# LIMITS USED BY CRAB WATCHDOG:
Hello CRAB!
CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line.
# LIMITS USED BY CRAB WATCHDOG:
and our test ROOT file should be in this folder as well
ls -lah dummy/res/
total 32K
drwxr-xr-x 2 phxlk users 4.0K Jul 13 16:38 .
drwxr-xr-x 6 phxlk users 4.0K Jul 13 16:24 ..
-rwx------ 1 phxlk users 0 Jul 13 16:26 CMSSW_1.stderr
-rwx---r-- 1 phxlk users 16K Jul 13 16:36 CMSSW_1.stdout
-rw------- 1 phxlk users 804 Jul 13 16:33 Watchdog_1.log.gz
-rw------- 1 phxlk users 568 Jul 13 16:36 crab_fjr_1.xml
-rw------- 1 phxlk users 0 Jul 13 16:26 testing_1_1_Yhj.root
If you see the above, everything worked as it should!
If you have a look at the script CRAB produces in the previous example you can see the following:
cat dummy/job/CMSSW.sh | grep run.sh
mv $RUNTIME_AREA/run.sh .
/usr/bin/time -f "%U %S %P" -o cpu_timing.txt $executable run.sh $NJob $AdditionalArgs > executable.out 2>&1
Our script has been called with the job number ($NJob
) as the first parameter followed by zero or more additional parameters ($AdditionalArgs
). These additional parameters can be set using a comma separated list under the [USER]
section:
script_arguments= a,b,c
Inside the script the job number will be available as $1 and all following parameters as $2 etc.
Not available (yet).