-
Notifications
You must be signed in to change notification settings - Fork 5
How to create and run a workflow from script_124059881
nxi edited this page Apr 9, 2015
·
1 revision
Created by Tony Lam, last modified on Jul 15, 2009
GumTree Workflow API allows user to create and execute workflow from the scripting support at runtime. Let's assume we have a very simple workflow with single task element. The following Python code will do the trick:
This example is equivalent to configuring a workflow with the following workflow XML configuration:
JEPP Only
It is even possible to create dynamic task to script any script in the workflow. See this example:
# Creates a new workflow workflow = WorkflowFactory.createEmptyWorkflow() # Adds a pause task pauseTask = PauseTask() pauseTask.setSleepTime(5) workflow.addTask(pauseTask) # Run this workflow workflow.run() # Obtains the run results result = workflow.getRunResults()
<workflow> <task classname="org.gumtree.workflow.ui.tasks.PauseTask="> <dataModel class="org.gumtree.workflow.ui.models.SingleNumberDataModel"> <number class="int">5</number> </dataModel> </task> </workflow>
It is even possible to create dynamic task to script any script in the workflow. See this example:
# Create workflow from org.gumtree.workflow.ui.util import WorkflowFactory from au.gov.ansto.bragg.nbi.ui.tasks import ScriptablePythonTask workflow = WorkflowFactory.createEmptyWorkflow() # Configure and add a python script task task = ScriptablePythonTask() task.setScriptExecutor(__executor__) task.setFunctionName(execute.func_name) workflow.addTask(task) # Execute workflow.run() result = workflow.getRunResults() print result.get(0)
Document generated by Confluence on Apr 01, 2015 00:11
Home | Developer Guide | Copyright © 2013 ANSTO