ATLAS Offline Software
Loading...
Searching...
No Matches
Echo_tf.py
Go to the documentation of this file.
1#! /usr/bin/env python
2
3# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
5
7
8import sys
9import time
10
11# Setup core logging here
12from PyJobTransforms.trfLogger import msg
13msg.info('logging set in %s', sys.argv[0])
14
15from PyJobTransforms.transform import transform
16from PyJobTransforms.trfExe import echoExecutor
17from PyJobTransforms.trfDecorators import stdTrfExceptionHandler, sigUsrStackTrace
18
19import PyJobTransforms.trfArgs as trfArgs
20import PyJobTransforms.trfArgClasses as trfArgClasses
21
22# Always embed your transform inside a top level exception
23# handler. This ensures that uncaught exceptions are handled
24# with a modicum of decency and that the transform has the
25# chance to produce a job report and a sensible exit code.
26# These decorators do this.
27@stdTrfExceptionHandler
28@sigUsrStackTrace
29def main():
30
31 msg.info('This is %s', sys.argv[0])
32
33 trf = getTransform()
34
35 trf.parseCmdLineArgs(sys.argv[1:])
36 trf.execute()
37 trf.generateReport()
38
39 msg.info("%s stopped at %s, transform exit code %d", sys.argv[0], time.asctime(), trf.exitCode)
40 sys.exit(trf.exitCode)
41
43 trf = transform(executor = echoExecutor())
44 addMyArgs(trf.parser)
45 trfArgs.addTeaArguments(trf.parser)
46 trfArgs.addAthenaArguments(trf.parser)
47 return trf
48
49
50
51def addMyArgs(parser):
52 # Use arggroup to get these arguments in their own sub-section (of --help)
53 parser.defineArgGroup('Echo_trf', 'Echo_trf specific options')
54 parser.add_argument('--testInt', group='Echo_trf', type=trfArgClasses.argFactory(trfArgClasses.argInt), help='An integer')
55 parser.add_argument('--testFloat', group='Echo_trf', type=trfArgClasses.argFactory(trfArgClasses.argFloat), help='A float')
56 parser.add_argument('--testList', group='Echo_trf',
57 type=trfArgClasses.argFactory(trfArgClasses.argList), help='A string list', nargs='+')
58 parser.add_argument('--testIntList', group='Echo_trf', nargs='+',
59 type=trfArgClasses.argFactory(trfArgClasses.argIntList), help='A int list')
60 parser.add_argument('--testFile', group='Echo_trf', nargs='+',
61 type=trfArgClasses.argFactory(trfArgClasses.argFile, io='input'), help='Test file(s)')
62 parser.add_argument('--testSubstepList', group='Echo_trf', nargs='+',
63 type=trfArgClasses.argFactory(trfArgClasses.argSubstepList), help='A substep list')
64 parser.add_argument('--testSubstepInt', group='Echo_trf', nargs='+',
65 type=trfArgClasses.argFactory(trfArgClasses.argSubstepInt), help='A substep int')
66 parser.add_argument('--testSubstepBool', group='Echo_trf', nargs='+',
67 type=trfArgClasses.argFactory(trfArgClasses.argSubstepBool), help='A substep bool')
68
69
70
71if __name__ == '__main__':
72 main()
addMyArgs(parser)
Example of how to add some specific arguments to the transform.
Definition Echo_tf.py:51
getTransform()
Definition Echo_tf.py:42
main()
Definition Echo_tf.py:29
Main package for new style ATLAS job transforms.
Transform argument class definitions.
Transform execution functions.
Logging configuration for ATLAS job transforms.