def resolveGlobalVars(self): """This method will create global parameter list and then will resolve all instances of @{VARNAME} Be aware that parameters of that type are GLOBAL!!! are string and can not be dynamically change The scope: the resolution of that parameters apply from lower to upper object, for example if parameter use in module, then it checks module, then step, then workflow Comment: If varible linked it should not be used in a global list""" # reenforced global parameters on the level of Workflow if not self.parameters.find("PRODUCTION_ID"): self.parameters.append( Parameter( "PRODUCTION_ID", "00000000", "string", "", "", True, False, "Transformation ID taken from the ProductionManager", )) if not self.parameters.find("JOB_ID"): self.parameters.append( Parameter( "JOB_ID", "00000000", "string", "", "", True, False, "Job ID within Tranformation taken from the Transformation Manager", )) self.parameters.resolveGlobalVars() step_instance_number = 0 for inst in self.step_instances: # for each step instance we can define STEP_NUMBER step_instance_number = step_instance_number + 1 if not inst.parameters.find("STEP_NUMBER"): inst.parameters.append( Parameter( "STEP_NUMBER", "%s" % step_instance_number, "string", "", "", True, False, "Number of the StepInstance within the Workflow", )) if not inst.parameters.find("STEP_ID"): prod_ID = self.parameters.find("PRODUCTION_ID").getValue() job_ID = self.parameters.find("JOB_ID").getValue() inst.parameters.append( Parameter( "STEP_ID", "%s_%s_%d" % (prod_ID, job_ID, step_instance_number), "string", "", "", True, False, "Step instance ID", )) if not inst.parameters.find("STEP_INSTANCE_NAME"): inst.parameters.append( Parameter( "STEP_INSTANCE_NAME", inst.getName(), "string", "", "", True, False, "Name of the StepInstance within the Workflow", )) if not inst.parameters.find("STEP_DEFINITION_NAME"): inst.parameters.append( Parameter( "STEP_DEFINITION_NAME", inst.getType(), "string", "", "", True, False, "Type of the StepInstance within the Workflow", )) if not inst.parameters.find("JOB_ID"): inst.parameters.append( Parameter( "JOB_ID", "", "string", "self", "JOB_ID", True, False, "Job ID within Tranformation taken from the Transformation Manager", )) if not inst.parameters.find("PRODUCTION_ID"): inst.parameters.append( Parameter( "PRODUCTION_ID", "", "string", "self", "PRODUCTION_ID", True, False, "Type of the StepInstance within the Workflow", )) inst.resolveGlobalVars(self.step_definitions, self.parameters)
print 'Executing Module = ',str(type(self)) self.result=self.input1+self.input2 if self.debug: print 'inputs are', self.input1, self.input2 print 'Result is',self.result else: print str(type(self)), 'pass' def __del__(self): pass """ body3 = "from calendar import Calendar\n" op1 = Parameter("enable", "True", "bool", "", "", True, False, "if False execution disabled") op2 = Parameter("version", "1.25", "float", "", "", False, True, "we can get version of the module") #op3 = Parameter("message","\'this is ugly module\'","string","","",False,False,"message for the printing") op3 = Parameter("message", "@{inparam4}", "string", "", "", False, False, "message for the printing") op4 = Parameter("debug", "False", "bool", "", "", True, False, "allows to print additional information") op5 = Parameter("input1", "2", "int", "", "", True, False, "argument for addition") op6 = Parameter("input2", "5", "int", "", "", True, False, "argument for addition") op7 = Parameter("result", "0", "int", "", "", False, True, "argument for addition") md1 = ModuleDefinition('PrintOutput')
if not self.enable: print 'Module ',str(type(self)),'is disabled' return 1 print( 'Test application execution' ) print 'Module MODULE.getDescrShort() =', self.MODULE.getDescrShort() print 'Module MODULE_DEFINITION_NAME =', self.MODULE_DEFINITION_NAME print 'Module MODULE_INSTANCE_NAME =', self.MODULE_INSTANCE_NAME print 'Module STEP.getDescrShort() =', self.STEP.getDescrShort() print 'Module STEP_DEFINITION_NAME =', self.STEP_DEFINITION_NAME print 'Module STEP_INSTANCE_NAME =', self.STEP_INSTANCE_NAME return 1""" md1 = ModuleDefinition("TestAppModule") md1.addParameter( Parameter("enable", "True", "bool", "", "", True, False, "If False execution is disabled")) md1.setBody(bodyTestApp) md1.setDescrShort("Empty Module") md1.setDescription("Empty Module to do some testing") md1.setRequired("") md1.setOrigin("") md1.setVersion(0.1) sd1 = StepDefinition("TestAppStep") sd1.addModule(md1) mi1 = sd1.createModuleInstance("TestAppModule", "testappmod1") wf1 = Workflow("TestAppWF") wf1.addStep(sd1) si1 = wf1.createStepInstance("TestAppStep", "testappstep1") print(wf1.createCode()) # eval(compile(wf1.createCode(),'<string>','exec'))
from DIRAC.Core.Workflow.Parameter import * from DIRAC.Core.Workflow.Module import * from DIRAC.Core.Workflow.Step import * from DIRAC.Core.Workflow.Workflow import * from DIRAC.Core.Workflow.WorkflowReader import * #define Module 2 module2 = ModuleDefinition('GaudiApplication')#during constraction class creates duplicating copies of the params module2.setDescription('Gaudi Application module') module2.setBody('from WorkflowLib.Module.GaudiApplication import GaudiApplication\n') # we add empty parameters but linked up as default module2.addParameter(Parameter("DataType","","string","self","DataType",True, False, "data type")) module2.addParameter(Parameter("CONFIG_NAME","","string","self","CONFIG_NAME",True, False, "Configuration Name")) module2.addParameter(Parameter("CONFIG_VERSION","","string","self","CONFIG_VERSION",True, False, "Configuration Version")) module2.addParameter(Parameter("EVENTTYPE","","string","self","EVENTTYPE",True, False, "Event Type")) module2.addParameter(Parameter("appName","","string","self","appName",True, False, "Application Name")) module2.addParameter(Parameter("appVersion","","string","self","appVersion",True, False, "Application Version")) module2.addParameter(Parameter("appType","","string","self","appType",True,False,"Application Version")) module2.addParameter(Parameter("appLog","","string","self","appLog",True,False,"list of logfile")) module2.addParameter(Parameter("inputData","","jdl","self","inputData",True, False, "List of InputData")) module2.addParameter(Parameter("inputDataType","","string","self","inputDataType",True, False, "Input Data Type")) module2.addParameter(Parameter("NUMBER_OF_EVENTS","","string","self","NUMBER_OF_EVENTS",True, False, "number of events requested")) module2.addParameter(Parameter("optionsFile","","string","self","optionsFile",True,False,"Options File")) module2.addParameter(Parameter("optionsLine","","string","self","optionsLine",True,False,"Number of Event","option")) module2.addParameter(Parameter("systemConfig","","string","self","systemConfig",True,False,"Job Platform")) module2.addParameter(Parameter("poolXMLCatName","","string","self","poolXMLCatName",True,False,"POOL XML slice")) #define module 3 module3 = ModuleDefinition('LogChecker')#during constraction class creates duplicating copies of the params module3.setDescription('Check LogFile module')