Thursday, June 9, 2011

Athenaeum CLI JobConfig modifs via Groovy Slurp

I've implemented a possibility to modify JobConfig.xml file from the
Athenaeum CLI. There is a new argument -modifs which contains modification instruction
script string.
The syntax is very intuitive, it comes from the Groovy Slurp XML syntax.
athenaeum variable represents JobConfig.xml file to be modified.

Some examples:

// change email element
athenaeum.email="someone@cern.ch"

// change extract id attribute
athenaeum.extract.@id="newid"

// change logical collection physics condition
athenaeum.extract.logical_collections.collection_ref.physics_cond.@sql=
  'NLooseElectron>1 AND abs(LooseElectronPt1)>1000.'

// add a step element into profile element to describe this processing step
athenaeum.profile.appendNode {step (processor:"CLI-GroovyXMLSlurper",
                                    version:"1.2.3",
                                    ip:"123.123.123.123",
                                    time:"0")}

// more complex: for each collection with specified name: add RunNumber query to SQL
athenaeum.collections.collection.find
  {it.@name == "data10_7TeV_physics_MinBias_r1239_p134_READ"}.each
  {c -> c.query.@sql = (c.query.@sql + "RunNumber = 12345")}

No comments:

Post a Comment