RStDGanga410
Ganga Version 4.1.0
The instructions here tell you how to setup and use the Ganga shell that is based on python and allows you to create a job object and examine its attributes. After the basics of getting the shell going are explained, a test "hello world" job is given with the job run locally, on LSF and then on the Grid. After this, an Athena Hello World job is explained, again for local running for LSF and for the Grid.
The Ganga Shell: Getting Ganga installed and running
- Setup Ganga
- Login on LXPLUS
- LSF and LCG UI only on lxplus
- Install Ganga
You may either use the alias method or add to your path. The PATH environment variable can become too long so you choose.
- Alias Method
- csh
Modify your .cshrc to contain
- alias ganga /afs/cern.ch/sw/ganga/install/slc3_gcc323/4.1.0/bin/ganga
- sh
Modify your .zshrc to contain
- alias ganga=/afs/cern.ch/sw/ganga/install/slc3_gcc323/4.1.0/bin/ganga
- PATH Method
- csh
Modify your .cshrc to contain
- setenv PATH /afs/cern.ch/sw/ganga/install/slc3_gcc323/4.1.0/bin/:$PATH
- sh
Modify your .zshenv to contain
- export PATH=/afs/cern.ch/sw/ganga/install/slc3_gcc323/4.1.0/bin/:$PATH
- Configure Ganga
- Create configuration file
- Edit configuration file
- emacs ~/.gangarc
- Configuration section: normally the first, we are using the second.
- RUNTIME_PATH = GangaAtlas
- LCG section
- SETUP = /afs/...
- VirtualOrganisation = atlas
- Try it out: Click Here for a Screen Dump
- Play with the Shell
- It's Python. Well actually IPython, a part of scientific python and has a better python prompt.
- With some some shortcuts
- Tab expand for shell and python
- Some shell commands work directly
- Others can be run with an !
- Jobs are a python object
- Help available
- Helper fucntions
- backends()
- applications()
- ganga --help
- ~/__Ganga4__
- File workspace where input/output is stored.
- Local job registry: a place hwere job objects are stored
Hello World Job
- Create a Generic Job and print the object: Click Here for a Screen Dump
- Configure it
- One option
In [4]: j.application.exe='/bin/echo'
In [5]: j.application.env={'MESSAGE':'Hello World'}
In [6]: j.application.args=['$MESSAGE']
- Another way
In [4]: j.application.exe='/bin/echo'
In [5]: j.application.args=['Hello World']
- Run it Click Here for a Screen Dump of all this
- Locally
- LSF
- j2=j.copy()
- j2.backend=LSF()
- j2.submit
- LCG
- j3=j.copy()
- j3.backend=LCG()
- j3.submit()
- Look at the result
- Try the other option for specifying args Click Here for a Screen Dump of this alternative jobs
- j4=Job()
- j4.application.exe='/bin/echo'
- j4.application.args=['Hello World']
- j4.backend=LCG()
- print j4
- j4.submit()
- outfile4 = file(j4.outputdir+'/stdout')
- print outfile4.read()
- Useful Hints
- List of your jobs Click Here for a Screen Dump of the commands below
- p jobs
p is a shorthand for print
- jobs
- Kill a job
- See the status of a job
- Clean up all jobs
- Try also tab-expand on j
- print j.id Screen Dump
- for jj in jobs.ids(0,150): print jobs[jj].id,jobs[jj].name Screen Dump
- for jj in range(100):
... jj=Job() Screen Dump This example created 100 jobs. One could put addition items into the loop to distinguish jobs and submit them all.
- for id in range(30):
... jobs[id].kill()
- Use a specific Grid Site: Examples of successes and failures
- j120=j4.copy()
- j120.backend.CE='mu6.matrix.sara.nl:2119/jobmanager-pbs-atlas'
- The Sandbox
- Input
- ls ~/gangadir/workspace/Local/1/input
- Output
- ls ~/gangadir/workspace/Local/1/output
Athena Jobs
Scenario
User wants to run his own algorithm on AOD data
- Algorithm is sent with the job
- tar file of the user area
- Standard LCG data management
- LCG is used directly
- Prodsys in the near future
Assumptions
- User is a Physicist that ...
- Knows CMT
- Knows how to run Athena
- Does not need to know much on the grid
- Ganga supports the user to get his algorithm on the grid
- The algorithm is run by a Transformation
- Again: it will be the same as used by ProdSys
- A lot of work hs been done by ProdSys group to support an Analysis Transformation
- User has just to configure the transformation
- Our example
- PAT Example
- Package: AnalysisExamples
- Job Options: ttbarExample_jobOptions.py
- AOD Dataset
- rome.004100.recov10.T1_McAtNLO_top
- Versions
- ATLAS Release 11.0.4
- AnalysisExample-00-11-05
- Prepare the CMT Setup
- ~/cmthome/requirements
- set CMTSITE CERN
- macro ATLAS_DIST_AREA "/afs/cern.ch/atlas/software/dist"
- macro ATLAS_TEST_AREA "$HOME/offline" \
Tutorial "$HOME/offline/Tutorial"
- use AtlasLogin AtlasLogin-* $(ATLAS_DIST_AREA)
- No problem if you use a different way to configure your enviroment. Just set it up before you start Ganga
- Source the CMT setup
- source ~/cmthome/setup.sh -tag=11.0.4 (Add it to your .zshrc.)
- Determine the latest version of AnalysisExamples
- ls /afs/cern.ch/atlas/software/dist/11.0.4/PhysicsAnalysis/AnalysisCommon/AnalysisExamples
- You see that it is: AnalysisExamples-00-11-05
- Go to your work area and check out your algorithm
- cd
- mkdir offline
- cd offline
- mkdir 11.0.4
- cd 11.0.4
- cmt co -r AnalysisExamples-00-11-05 PhysicsAnalysis/AnalysisCommon/AnalysisExamples (Screen Dump)
- cd PhysicsAnalysis/AnalysisCommon/AnalysisExamples/AnalysisExamples-00-11-05/cmt
- source setup.sh (Add sourcing of this to your .zshrc.)
- gmake -j2 (Screen Dump)
- Now go for coffee...
- Within Ganga you can do the same
- cmt setup 11.0.4 opt
- cd PhysicsAnalysis/AnalysisCommon/AnalysisExamples/AnalyisExamples-00-11-05/cmt
- Setup
- gmake -
- Athena Job
- You could run your job with the Executable application handler
- There is a special Athena application handler which makes youre life much easier
- This concept maps directly to the Production System transformations
Running the Jobs
- Run Athena Hello World on LSF
- Go to the run directory
- cd ~/offline/11.0.4/PhysicsAnalysis/AnalysisCommon/AnalysisExamples/AnalysisExamples-00-11-05/run
- Start ganga Screen Dump
- Create Job
- Create Application object and configure it: this creates a tar file of the user area. Screen Dump
- jj.application=Athena()
- jj.application.prepare()
- Select a job option file like HelloWorldOptions.py:
- jj.application.option_file='HelloWorldOptions.py'
- Specify input
- Select backend
- Submit job (Screen Dump)
- Examine Results Screen Dump
- Run Athena Hello World on the Grid
- Set up the environment variables for the right replica catalog. Add it to your .zshrc.
- export LFC_HOST=lfc-atlas-test.cern.ch
- export LCG_CATALOG_TYPE=lfc
- Set up the grid. Add it to your .zshrc.
- source /afs/cern.ch/project/gd/LCG-share/sl3/etc/profile.d/grid_env.sh
- Go to the run directory
- cd ~/offline/11.0.4/PhysicsAnalysis/AnalysisCommon/AnalysisExamples/AnalysisExamples-00-11-05/run
- Start ganga Screen Dump
- Create Job
- Create Application object and configure it: this creates a tar file of the user area. Screen Dump
- j.application=Athena()
- j.application.prepare()
- Select a job option file like HelloWorldOptions.py:
- j.application.option_file='HelloWorldOptions.py'
- Specify input
- Select backend
- Submit job (Screen Dump)
- Examine Results Screen Dump The job proxy expired.
- Run Athena with input and output on LSF
- Create Job
- Create Application object and configure it: this creates a tar file of the user area.
- j2.application=Athena()
- j2.application.prepare() Screen Dump
- Select a job option file
- j2.application.option_file='ttbarExample_jobOptions.py'
- Specify input
- j2.inputdata=ATLASCastorDataset()
- j2.inputdata.set_dataset_type('rome-aod')
- j2.inputdata.list_datasets() Screen Dump
- j2.inputdata.get_dataset('rome.004100.recov10.T1_McAtNLO_top',0,10) Screen Dump
- Define output data
- j2.application.output.files=['ttbar.ntuple.root','ttbar.hist.root']
- Select backend
- Submit job
- Examine Results
- p j2 Screen Dump
- outfile2=file(j2.outputdir+'/stdout')
- print outfile2.read() Screen Dump
- Output is at: /castor/cern.ch/atlas/scratch/$USER/ganga/$JOBID (Screen Dump). It is useful to consult the Castor Workbook to see how to maniuplate files. My output is not there -- the job crashes in cmt setup.
- Run Athena with input and output on the Grid
- Create Job
- Create Application object and configure it: this creates a tar file of the user area.
- j3.application=Athena()
- j3.application.prepare()
- Select a job option file
- j3.application.option_file='ttbarExample_jobOptions.py'
- Specify input
- j3.inputdata=ATLASDataset()
- j3.inputdata.lfn=['rome.004100.recov10.T1_McAtNLO_top._00001.AOD.pool.root']
The number 00001 can range from 00001 to 00010.
- Define output data
- j3.application.output.files=['ttbar.ntuple.root','ttbar.hist.root']
- Select backend
- Submit job
- Examine result
- Error Hint: The indicating "Cannot plan: BrokerHelper: no compatible resources". is in fact due to a misspelling of the filename. So if you get this error, check your spelling.
Major updates:
--
RichardStDenis - 19 Oct 2005
%RESPONSIBLE%
%REVIEW%