ATLAS Offline Software
PandaJobRunner.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 """
5 PandaJobRunner is a JobRunner for running jobs on the grid using pathena.
6 
7 Written by Juerg Beringer (LBNL) in 2009.
8 """
9 __author__ = 'Juerg Beringer'
10 __version__ = '$Id: PandaJobRunner.py 345959 2011-02-15 15:20:18Z gwilliam $'
11 
12 
13 from JobRunner import JobRunner
14 import os
15 
16 
17 # Default template of job submission script
18 gridSubmitScript = """#!/bin/sh
19 echo ''
20 echo "Setting up release %(release)s"
21 %(cmdsetup)s
22 echo ''
23 echo 'Setting up standard grid environment ...'
24 source /afs/cern.ch/atlas/offline/external/GRID/ddm/DQ2Clients/setup.sh
25 voms-proxy-init -voms atlas
26 source /afs/cern.ch/atlas/offline/external/GRID/DA/panda-client/latest/etc/panda/panda_setup.sh
27 echo ''
28 echo "Creating grid job submission directory (`date`) ..."
29 griddir=$TestArea/gridsubmit/%(jobname)s
30 mkdir -p $griddir
31 cd $griddir
32 echo ''
33 echo "Copying files (`date`) ..."
34 %(cmdjobpreprocessing)s
35 cp -p %(configfile)s .
36 %(cmdcopyfiles)s
37 echo ''
38 echo "Creating POOL file catalog (`date`) ..."
39 %(cmddefinepoolcatalog)s
40 echo ''
41 echo "Running pathena (`date`) ..."
42 pathena `basename %(configfile)s` %(joboptionpath)s --extOutFile %(outputfilestring)s --inDS %(inputds)s --outDS %(griduser)s.%(jobname)s --nFilesPerJob %(filesperjob)s --nFiles %(maxjobs)s --site %(gridsite)s
43 echo "Postprocessing (`date`) ..."
44 %(cmdjobpostprocessing)s
45 # Deliberately not removing grid job submit directory under $TestArea
46 # cd ..
47 # rm -rf $griddir
48 """
49 
50 
52  """PandaJobRunner - run jobs on the grid using pathena"""
53 
54  def __init__(self,**params):
55  """Constructor (takes any number of parameters as an argument)."""
56  JobRunner.__init__(self)
57 
58  # Set user-specified parameters only after PandaJobRunner defaults
59  self.setParam('inputds','','Input dataset name (for grid jobs)',insertAtFront=True)
60  self.setParam('griduser','','User part of grid job name, e.g. JuergBeringer',insertAtFront=True)
61  self.setParam('gridsite','AUTO','Site name where jobs are sent (default:AUTO)',insertAtFront=True)
62  self.setParam('script',gridSubmitScript)
63  self.setParam('addinputtopoolcatalog',False)
64  for k in params.keys():
65  self.setParam(k,params[k])
66  self.checkParams()
67 
68  def submitJob(self,jobConfig):
69  """Submit a JobRunner job as a grid job."""
70  scriptfile = jobConfig['scriptfile']
71  logfile = jobConfig['logfile']
72  os.system('%s 2>&1 | tee %s' % (scriptfile,logfile))
73  return None
python.PandaJobRunner.PandaJobRunner
Definition: PandaJobRunner.py:51
python.PandaJobRunner.PandaJobRunner.submitJob
def submitJob(self, jobConfig)
Definition: PandaJobRunner.py:68
python.PandaJobRunner.PandaJobRunner.__init__
def __init__(self, **params)
Definition: PandaJobRunner.py:54
python.JobRunner.JobRunner.checkParams
def checkParams(self)
Definition: JobRunner.py:210
python.JobRunner.JobRunner
Definition: JobRunner.py:99
python.JobRunner.JobRunner.setParam
def setParam(self, name, value=None, description=None, isSpecial=None, insertAtFront=False)
Definition: JobRunner.py:158