Job Option Module

From Daya Bay
Jump to navigation Jump to search
Offline Documentation: [Offline Category] [FAQ] [Howto] [Reference] [Manual]

Offline Documentation
This article is part
of the Offline Documentation
Other pages...

Offline Category
How Tos
Getting Started
Software Installation

See also...

General Help on this Wiki

Job Option Modules (JOMs) are used to customize the standard job. They are Python modules that follow several conventions.

Basics of JOMs

At the most basic level a JOM is just a listing of configuration code with no other structure. This code is executed when the module is imported by Modules are loaded in the order in which they are listed on the command line. For simple configurations this may be enough.

Special methods of JOMs

To provide for more structure a JOM can have two special methods that will be called by

The configure() method

After all modules have been loaded each is checked for the existence of a configure() method. If one exists it is called, again in the order that the modules are listed on the command line.

The configure() method's signature should be:

def configure(argv = None):

You module may then use argv to receive any command line arguments.

def configure(argv = None):
    if argv: parse_args(argv)

You may call any kind of configuration code from configure() that you might call at top level. In particular, you can register any (C++) algorithms that the job should run. This is done like:

def configure(argv = None): 
    from Gaudi.Configuration import ApplicationMgr
    from MyPackage.MyPackageConf import MyAlgorithm
    theApp = ApplicationMgr()
    myalg = MyAlgorithm()
    myalg.Property = ....

The run() method

After all modules have been loaded and any configure() methods have been called the modules are checked for the existence of a run() method. This method is called after all configuration has been done but just before any algorithms are called. The main reason a JOM may want to implement this method is to create an instance of a Python algorithm and add it to the list to run in the job. Note as the ordering so far should indicate, all Python algorithms will follow any C++ ones.

The run() method follows this signature:

def run(app):

An example of adding a Python algorithm is given:

def run(app):
    myalg = MyPythonAlg()
Offline Software Documentation: [Offline Categories] [FAQ] [Offline Manual Category]