Workflow parameters

Sep 29, 2010 at 6:02 PM

Hi Trident Support Team,

I want to know what are 'workflow parameters' and how do I get to use them in Trident, like set/get/update? Is this part implemented in the prodcut [I can see some textboxes in the UI],  Is there any way I can access these programmatically in my custom activities?

Thanks, Regards
Ashish Bhangale

Sep 30, 2010 at 4:33 PM
Edited Oct 4, 2010 at 12:33 PM

Hi Ashish,

We are looking into your question. We will get back to you as soon as possible.

Please let us know if you have any further questions/issues.
Thanks,
Trident Support Team

Oct 5, 2010 at 8:50 AM

Hi Ashish,

Please find the answers to your questions.

<<what are 'workflow parameters'>>
Workflow Parameters are the input/output parameters of activities which are required by a workflow for its successful execution.

You can follow below steps for marking a parameter of an activity as workflow parameter:

  1. Open Trident Workflow Composer
  2. Open workflow from left pane.
    For example: - Ocean Current workflow
  3. Right click on any input/output Activity parameter which has to be marked as workflow parameter.
  4. Click on “mark it as workflow input/output” based on the output direction of the parameter.

<<how do I get to use them in Trident, like set/get/update>>
You can access the Workflow Parameters using the following steps:

  1. Open Trident Workflow Composer
  2. Open workflow from left pane.
    For example: - Ocean Current workflow
  3. Right click on SequentialWorkflowActivity
  4. Click “Properties”
  5. On the property pane a Workflow properties windows appears, click on Workflow Parameters

<<there any way I can access these programmatically in my custom activities >>
Yes. You can use the Context Object in your custom activities for accessing the workflow parameters.

  •  The Scientific Workflow solution in Trident contains a class named Context (Navigate from ScientificWorkflow -> TridentContext -> Context ).
  •  The Context class contains a method named  BuildActivitySequence which recursively goes to the children and builds a dictionary of Activity Sequences.
  •  In a nutshell, we are splitting the entire Workflow as an Activity Sequence, where the Workflow is treated as a root activity and all the activity contained in it as its child activity.
  •  In Trident, we use a JobExecutor class for running the WF using the job object. (Navigate from ScientificWorkflow -> TridentExecutor-> WFExecutor->JobExecutor ).
  •  The JobExecutor class contains a method called CreateContext which creates the context object for the running WF instance.

You can refer the following steps to do this:

  1. While overriding the Execute method, create an object of type Context.
  2. In the JobExecutor class, we have a CreateContext method which accesses the BuildActivitySequence method.
  3. Use the ContextBuildActivitySequence method to access the workflow parameter, as of now we support only the output parameters.
  4. You will need the Job Id of the Workflow you are executing to access the workflow.

Please let us know if this answers your questions.
Regards,
Trident Support Team

Oct 7, 2010 at 8:50 AM

Hi Ashish,

Can you please let us know if the response answered your questions?

Thanks,
Trident Support Team

Oct 8, 2010 at 7:02 AM
Edited Oct 8, 2010 at 7:03 AM

Hi,

Thanks for the instructions!
I am working with Ashish on this. I have a few doubts and would appreciate your help with them.

I tried the following based on your instructions:
1) I made the output parameter of an activity, as a "workflow output" using the Trident Composer.

2)Regarding accessing this value programmatically, I did not understand point 3 clearly.

"3.Use the ContextBuildActivitySequence method to access the workflow parameter, as of now we support only the output parameters."

The method Context.BuildActivitySequence, needs an argument -> ActivitySequence rootSequence. I did the following:

ActivityInstance rootSeq = ActivityInstance.Load(guid, registryConnection);
Context.Create(registryConnection, rootSeq, guid);
Context.BuildActivitySequence(rootSeq.Activity.BaseSequence);
Context ctx = Context.Get();
ActivityInstance wfInstance = ctx.WFInstance;

I used the above worflow instance 'wfInstance' to get/set output using 'wfInstance.Outputs'. However, as you can see in the code above, I had to initialize registry connection and pass it as an argument. Is this the right way to do it?

Another way I used was, directly using rootSeq to get/set outputs.

ActivityInstance rootSeq = ActivityInstance.Load(guid, registryConnection);

           
In this case, I used 'rootSeq.Outputs' to set/get outputs.
In this case also, I had to initialize the registry connection and pass it as an argument.

Please let me know, if this the right way to do it.

We currently need set/get for input parameters as well, and will try to modify the source code to allow that.

Thanks for your help.

Thanks,
Kavitha

 

 

Oct 8, 2010 at 2:25 PM

Hi Kavita,

We are looking into your question. We will get back to you as soon as possible.

Please let us know if you have any further questions/issues.
Thanks,
Trident Support Team

Oct 13, 2010 at 7:52 AM
Hi Kavitha,
 
Sorry for the delay in response.
 
<<Accessing Workflow Outputs programmatically in a custom activity.>>
While executing workflow using TridentExecutor, the Context object will already be created. So you can you Context.Get() to get the context object.
Once you have the context object, you can use Context.WFInstance to retrieve the ActivityInstance of the workflow.
 
Context ctx = Context.Get();
ActivityInstance rootInstance = ctx.WFInstance;
 
If we use in this way there will be no need to initialize the registry connection. Also if you really need the registry connection for any other purpose, then you Use the Context.RegistryConenction property to retrieve the current registryConnection
 
this.registryConnection = ctx.Connection.Clone();
 
Once you have the ActivityInstance object you can use ctx.WFInstance.Outputs to access all the workflow outputs. Please note that once you have marked a parameter as workflow output, trident executor takes care of creating the workflow outputs. Please refer the WorkflowOutputSave service (https://tridentworkflow.svn.codeplex.com/svn/Trident/Product\/\ScientificWorkflow/Blackboard/Microsoft.Research.eResearch.RuntimeServices/WorkflowOutput/WorkflowOutputSaveService.cs) which has the implementation of this logic of saving workflow outputs.
 
<<Accessing Workflow Inputs programmatically in a custom activity.>>
ctx.WFInstance.ActivityInstanceParameters retrieves all the workflow inputs of the particular Job.
 
Hope this answers all your questions. Please let us know If you need any further information.
Thanks,
Trident Support Team
Oct 14, 2010 at 1:17 PM

Hi,

That was very helpful, Thanks for answering our questions.

Thanks,

Kavitha