...
Variables can be defined within the <task> or <process> tag.
Code Block | |||||||
---|---|---|---|---|---|---|---|
| |||||||
<variables> <var name="configdir">${jobdirroot}/config</var> <var name="mcSrcIdfile">${outdir}/${pipeline.task}-${sixdigstream}_mcsrcId.txt</var> <var name="jobdirroot">/nfs/farm/g/glast/u26/MC-tasks/${pipeline.task}/</var> <var name="outdir">${jobdirroot}/output/${sixdigstream}</var> <var name="scDatafileLD">${LDprefix}/scData:run-${sixdigstream}</var> <var name="mcSrcIdfileLD">${LDprefix}/mcSrcId:run-${sixdigstream}</var> <var name="scDatafile">${outdir}/${pipeline.task}-${sixdigstream}_scData_0000.fits</var> <var name="eventfile">${outdir}/${pipeline.task}-${sixdigstream}_events_0000.fits</var> <var name="LDprefix">/ServiceChallenge/${pipeline.task}</var> <var name="sixdigstream">${format(pipeline.stream,"%06d")}</var> <var name="eventfileLD">${LDprefix}/events:run-${sixdigstream}</var> </variables> |
...
If it is required for a batch job to access a variable from a previous process this can be achieved by explicitly setting a variable in the process which defines the job.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<process name="stepB"> <notation>Scriptlet Test Step B</notation> <variables> <var name="DERIVED">Stream ${pipeline.stream} ${pipeline.getProcessInstance("stepA").getVariable("message")}</var> </variables> <job> pipeline-set message "Hello from batch: ${DERIVED}" </job> <depends> <after process="stepA"/> </depends> </process> |
...
The following example shows many of the features discussed above.
Code Block | |||||||
---|---|---|---|---|---|---|---|
| |||||||
<?xml version="1.0" encoding="UTF-8"?> <pipeline xmlns="http://glast-ground.slac.stanford.edu/pipeline" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://glast-ground.slac.stanford.edu/pipeline http://glast-ground.slac.stanford.edu/Pipeline-II/schemas/2.0/pipeline.xsd"> <task name="ScriptletTest" version="2.2" type="Data"> <notation>Just Testing</notation> <process name="step1"> <notation>Scriptlet Test Step 1</notation> <!-- <script language="python"> <![CDATA[ pipeline.setVariable("message","Hello from Step1") for i in range(10,12): pipeline.createSubstream("TestSubtask",i) ]]> </script> !--> <job> pipeline-set message "Hello from step1" pipeline-createStream TestSubtask 11 pipeline-createStream TestSubtask 12 "test=33,xyz=Hello" </job> <createsSubtasks> <subtask>TestSubtask</subtask> </createsSubtasks> </process> <process name="step2"> <notation>Scriptlet Test Step 2</notation> <script language="python"> <![CDATA[ step1 = pipeline.getProcessInstance("step1") print "The message from ", step1.getName(), " stream ", step1.getStream(), " is ", step1.getVariable("message") test = pipeline.getSubstream("TestSubtask",11) stepa = test.getProcessInstance("stepA") print "The message from ", stepa.getName(), " stream ", stepa.getStream(), " is ", stepa.getVariable("message") tests = pipeline.getSubstreams("TestSubtask") for test in tests: step = test.getProcessInstance("stepB") print "The message from ", step.getName(), " stream ", step.getStream(), " is ", step.getVariable("message") ]]> </script> <depends> <after process="TestSubtask.stepB"/> </depends> </process> <task name="TestSubtask" type="Data"> <notation>Just Testing</notation> <process name="stepA"> <notation>Scriptlet Test Step A</notation> <script language="python"> <![CDATA[ pipeline.setVariable("message","Hello from stepA") ]]> </script> </process> <process name="stepB"> <notation>Scriptlet Test Step B</notation> <variables> <var name="DERIVED">Stream ${pipeline.stream} ${pipeline.getProcessInstance("stepA").getVariable("message")}</var> </variables> <job> pipeline-set message "Hello from batch: ${DERIVED}" </job> <depends> <after process="stepA"/> </depends> </process> </task> </task> </pipeline> |